|
|
|
@ -1,40 +1,43 @@
|
|
|
|
/* 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) {
|
|
|
|
@ -46,13 +49,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`,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|