Merge pull request #257 from HaveAGitGat/log_fixes

dca/truehd
This commit is contained in:
HaveAGitGat 2022-01-23 03:14:52 +01:00 committed by GitHub
commit d42be26b8a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,43 +1,49 @@
/* eslint-disable */
module.exports = function transcodeStandardiseAudioCodecs(file, audioEncoder) { module.exports = function transcodeStandardiseAudioCodecs(file, audioEncoder) {
//Function required responses // Function required responses
// preset // preset
// processFile // processFile
// note // note
try { try {
var audioIdx = -1; let audioIdx = -1;
var hasNonSpecifiedAudioCodecStream = false; let hasNonSpecifiedAudioCodecStream = false;
var ffmpegCommandInsert = ""; let ffmpegCommandInsert = '';
var audioCodec = audioEncoder; let audioCodec = audioEncoder;
if (audioEncoder == "dca") { if (audioEncoder === 'dca') {
audioCodec = "dts"; audioCodec = 'dts';
} }
if (audioEncoder == "libmp3lame") { if (audioEncoder === 'libmp3lame') {
audioCodec = "mp3"; audioCodec = 'mp3';
} }
for (var i = 0; i < file.ffProbeData.streams.length; i++) { for (let i = 0; i < file.ffProbeData.streams.length; i += 1) {
try { try {
if (file.ffProbeData.streams[i].codec_type.toLowerCase() == "audio") { if (file.ffProbeData.streams[i].codec_type.toLowerCase() === 'audio') {
audioIdx++; audioIdx += 1;
} }
} catch (err) {} } catch (err) {
// err
}
try { try {
if ( if (
file.ffProbeData.streams[i].codec_type.toLowerCase() == "audio" && file.ffProbeData.streams[i].codec_type.toLowerCase() === 'audio'
file.ffProbeData.streams[i].codec_name != audioCodec && file.ffProbeData.streams[i].codec_name !== audioCodec
) { ) {
ffmpegCommandInsert += ` -c:a:${audioIdx} ${audioEncoder}`; ffmpegCommandInsert += ` -c:a:${audioIdx} ${audioEncoder}`;
hasNonSpecifiedAudioCodecStream = true; hasNonSpecifiedAudioCodecStream = true;
} }
} catch (err) {} } catch (err) {
// err
}
} }
if (hasNonSpecifiedAudioCodecStream === true) { if (hasNonSpecifiedAudioCodecStream === true) {
if (['dca', 'truehd'].includes(audioEncoder)) {
ffmpegCommandInsert += ' -strict -2';
}
return { return {
preset: `,-map 0:v -map 0:a -map 0:s? -map 0:d? -c copy ${ffmpegCommandInsert}`, preset: `,-map 0:v -map 0:a -map 0:s? -map 0:d? -c copy ${ffmpegCommandInsert}`,
processFile: true, processFile: true,
@ -46,13 +52,13 @@ module.exports = function transcodeStandardiseAudioCodecs(file, audioEncoder) {
} }
return { return {
preset: "", preset: '',
processFile: false, processFile: false,
note: `File does not have any audio streams which aren't in ${audioCodec} \n`, note: `File does not have any audio streams which aren't in ${audioCodec} \n`,
}; };
} catch (err) { } catch (err) {
return { return {
preset: "", preset: '',
processFile: false, processFile: false,
note: `library.actions.transcodeStandardiseAudioCodecs error: ${err} \n`, note: `library.actions.transcodeStandardiseAudioCodecs error: ${err} \n`,
}; };