mirror of
https://github.com/gabehf/Tdarr_Plugins.git
synced 2026-03-09 15:38:19 -07:00
tidy
This commit is contained in:
parent
d28272f6d4
commit
9c8ac98728
60 changed files with 5481 additions and 5980 deletions
|
|
@ -1,77 +1,59 @@
|
|||
|
||||
|
||||
module.exports = function transcodeStandardiseAudioCodecs(file, audioEncoder) {
|
||||
//Function required responses
|
||||
// preset
|
||||
// processFile
|
||||
// note
|
||||
|
||||
try {
|
||||
var audioIdx = -1;
|
||||
var hasNonSpecifiedAudioCodecStream = false;
|
||||
var ffmpegCommandInsert = "";
|
||||
var audioCodec = audioEncoder;
|
||||
|
||||
//Function required responses
|
||||
// preset
|
||||
// processFile
|
||||
// note
|
||||
|
||||
try {
|
||||
|
||||
var audioIdx = -1
|
||||
var hasNonSpecifiedAudioCodecStream = false
|
||||
var ffmpegCommandInsert = ''
|
||||
var audioCodec = audioEncoder
|
||||
|
||||
if (audioEncoder == 'dca') {
|
||||
audioCodec = 'dts'
|
||||
}
|
||||
|
||||
if (audioEncoder == 'libmp3lame') {
|
||||
audioCodec = 'mp3'
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
for (var i = 0; i < file.ffProbeData.streams.length; i++) {
|
||||
|
||||
|
||||
try {
|
||||
if (file.ffProbeData.streams[i].codec_type.toLowerCase() == "audio") {
|
||||
audioIdx++
|
||||
}
|
||||
} catch (err) { }
|
||||
|
||||
|
||||
try {
|
||||
if (file.ffProbeData.streams[i].codec_type.toLowerCase() == "audio" && file.ffProbeData.streams[i].codec_name != audioCodec) {
|
||||
|
||||
ffmpegCommandInsert += ` -c:a:${audioIdx} ${audioEncoder}`
|
||||
hasNonSpecifiedAudioCodecStream = true
|
||||
|
||||
}
|
||||
} catch (err) { }
|
||||
}
|
||||
|
||||
|
||||
if (hasNonSpecifiedAudioCodecStream === true) {
|
||||
|
||||
return {
|
||||
preset: `,-map 0:v -map 0:a -map 0:s? -map 0:d? -c copy ${ffmpegCommandInsert}`,
|
||||
processFile: true,
|
||||
note: `File has audio streams which aren't in ${audioCodec} \n`
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return {
|
||||
preset: '',
|
||||
processFile: false,
|
||||
note: `File does not have any audio streams which aren't in ${audioCodec} \n`
|
||||
}
|
||||
|
||||
|
||||
|
||||
} catch (err) {
|
||||
|
||||
return {
|
||||
preset: '',
|
||||
processFile: false,
|
||||
note: `library.actions.transcodeStandardiseAudioCodecs error: ${err} \n`
|
||||
}
|
||||
|
||||
if (audioEncoder == "dca") {
|
||||
audioCodec = "dts";
|
||||
}
|
||||
}
|
||||
|
||||
if (audioEncoder == "libmp3lame") {
|
||||
audioCodec = "mp3";
|
||||
}
|
||||
|
||||
for (var i = 0; i < file.ffProbeData.streams.length; i++) {
|
||||
try {
|
||||
if (file.ffProbeData.streams[i].codec_type.toLowerCase() == "audio") {
|
||||
audioIdx++;
|
||||
}
|
||||
} catch (err) {}
|
||||
|
||||
try {
|
||||
if (
|
||||
file.ffProbeData.streams[i].codec_type.toLowerCase() == "audio" &&
|
||||
file.ffProbeData.streams[i].codec_name != audioCodec
|
||||
) {
|
||||
ffmpegCommandInsert += ` -c:a:${audioIdx} ${audioEncoder}`;
|
||||
hasNonSpecifiedAudioCodecStream = true;
|
||||
}
|
||||
} catch (err) {}
|
||||
}
|
||||
|
||||
if (hasNonSpecifiedAudioCodecStream === true) {
|
||||
return {
|
||||
preset: `,-map 0:v -map 0:a -map 0:s? -map 0:d? -c copy ${ffmpegCommandInsert}`,
|
||||
processFile: true,
|
||||
note: `File has audio streams which aren't in ${audioCodec} \n`,
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
preset: "",
|
||||
processFile: false,
|
||||
note: `File does not have any audio streams which aren't in ${audioCodec} \n`,
|
||||
};
|
||||
} catch (err) {
|
||||
return {
|
||||
preset: "",
|
||||
processFile: false,
|
||||
note: `library.actions.transcodeStandardiseAudioCodecs error: ${err} \n`,
|
||||
};
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue