From 6545f701325be131e81dc472ab05c3d1114df529 Mon Sep 17 00:00:00 2001 From: HaveAGitGat <43864057+HaveAGitGat@users.noreply.github.com> Date: Mon, 27 Nov 2023 05:35:09 +0000 Subject: [PATCH] Add -strict -2 for truehd --- methods/library/actions/transcodeAddAudioStream.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/methods/library/actions/transcodeAddAudioStream.js b/methods/library/actions/transcodeAddAudioStream.js index 171beb7..448510a 100644 --- a/methods/library/actions/transcodeAddAudioStream.js +++ b/methods/library/actions/transcodeAddAudioStream.js @@ -24,6 +24,12 @@ module.exports = function transcodeAddAudioStream( audioCodec = "mp3"; } + let extraArgs = ""; + + if (audioEncoder === 'truehd') { + extraArgs = "-strict -2"; + } + //Step 1: Check if the file already has the required stream codec/langtag/channel count var hasStreamAlready = file.ffProbeData.streams.filter((stream) => { @@ -122,7 +128,7 @@ module.exports = function transcodeAddAudioStream( }; } else { return { - preset: `,-map 0:v -map 0:${highestChannelCount.index} -map 0:a -map 0:s? -map 0:d? -c copy -c:a:0 ${audioEncoder} -ac ${channelCount} -max_muxing_queue_size 9999`, + preset: `,-map 0:v -map 0:${highestChannelCount.index} -map 0:a -map 0:s? -map 0:d? -c copy -c:a:0 ${audioEncoder} -ac ${channelCount} -max_muxing_queue_size 9999 ${extraArgs}`, processFile: true, note: `The required channel count ${channelCount} is lower than the highest available channel count (${highestChannelCount.channels}). Adding! \n`, }; @@ -155,7 +161,7 @@ module.exports = function transcodeAddAudioStream( }; } else { return { - preset: `,-map 0:v -map 0:${highestChannelCount.index} -map 0:a -map 0:s? -map 0:d? -c copy -c:a:0 ${audioEncoder} -ac ${highestChannelCount.channels} -max_muxing_queue_size 9999`, + preset: `,-map 0:v -map 0:${highestChannelCount.index} -map 0:a -map 0:s? -map 0:d? -c copy -c:a:0 ${audioEncoder} -ac ${highestChannelCount.channels} -max_muxing_queue_size 9999 ${extraArgs}`, processFile: true, note: `The required channel count (${channelCount}) is higher than the highest channel available in specified lang tag (${highestChannelCount.channels}). Adding lower channel track. \n`, }; @@ -229,7 +235,7 @@ module.exports = function transcodeAddAudioStream( }; } else { return { - preset: `,-map 0:v -map 0:${highestChannelCount.index} -map 0:a -map 0:s? -map 0:d? -c copy -c:a:0 ${audioEncoder} -ac ${channelCount} -max_muxing_queue_size 9999`, + preset: `,-map 0:v -map 0:${highestChannelCount.index} -map 0:a -map 0:s? -map 0:d? -c copy -c:a:0 ${audioEncoder} -ac ${channelCount} -max_muxing_queue_size 9999 ${extraArgs}`, processFile: true, note: `The required channel count ${channelCount} is lower than the highest available channel count (${highestChannelCount.channels}). Adding! \n`, }; @@ -260,7 +266,7 @@ module.exports = function transcodeAddAudioStream( }; } else { return { - preset: `,-map 0:v -map 0:${highestChannelCount.index} -map 0:a -map 0:s? -map 0:d? -c copy -c:a:0 ${audioEncoder} -ac ${highestChannelCount.channels} -max_muxing_queue_size 9999`, + preset: `,-map 0:v -map 0:${highestChannelCount.index} -map 0:a -map 0:s? -map 0:d? -c copy -c:a:0 ${audioEncoder} -ac ${highestChannelCount.channels} -max_muxing_queue_size 9999 ${extraArgs}`, processFile: true, note: `The required channel count (${channelCount}) is higher than the highest channel available in specified lang tag (${highestChannelCount.channels}). Adding lower channel track. \n`, };