mirror of
https://github.com/gabehf/Tdarr_Plugins.git
synced 2026-03-14 17:55:55 -07:00
commit
d42be26b8a
1 changed files with 25 additions and 19 deletions
|
|
@ -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`,
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue