mirror of
https://github.com/gabehf/Tdarr_Plugins.git
synced 2026-03-10 07:50:29 -07:00
Add new action
This commit is contained in:
parent
372f374079
commit
d60e0c17ad
4 changed files with 85 additions and 21 deletions
76
methods/library/actions/transcodeStandardiseAudioCodecs.js
Normal file
76
methods/library/actions/transcodeStandardiseAudioCodecs.js
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
|
||||
|
||||
module.exports = function transcodeStandardiseAudioCodecs(file, audioEncoder) {
|
||||
|
||||
|
||||
try {
|
||||
|
||||
var audioIdx = -1
|
||||
var hasNonSpecifiedAudioCodecStream = false
|
||||
var ffmpegCommandInsert = ''
|
||||
|
||||
|
||||
//Function required responses
|
||||
// preset
|
||||
// processFile
|
||||
// note
|
||||
|
||||
|
||||
|
||||
var audioCodec = audioEncoder
|
||||
|
||||
if (audioEncoder == 'dca') {
|
||||
audioCodec = 'dts'
|
||||
}
|
||||
|
||||
|
||||
|
||||
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