From 03329da35b7778c296cf591cf1e6c7b813da649a Mon Sep 17 00:00:00 2001 From: HaveAGitGat <43864057+HaveAGitGat@users.noreply.github.com> Date: Wed, 25 May 2022 08:56:59 +0100 Subject: [PATCH] If mp4, only set video stream first, skip other stream ordering --- ...arr_Plugin_00td_action_re_order_all_streams_v2.js | 12 +++++++++--- ...arr_Plugin_00td_action_re_order_all_streams_v2.js | 4 ++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Community/Tdarr_Plugin_00td_action_re_order_all_streams_v2.js b/Community/Tdarr_Plugin_00td_action_re_order_all_streams_v2.js index 9639b9a..21881b2 100644 --- a/Community/Tdarr_Plugin_00td_action_re_order_all_streams_v2.js +++ b/Community/Tdarr_Plugin_00td_action_re_order_all_streams_v2.js @@ -102,9 +102,15 @@ const plugin = (file, librarySettings, inputs, otherArguments) => { + 'This may be due to a corrupt file or permissions issue when scanning the file.'); } - if (file.container === 'mp4' && file.ffProbeData.streams[0].codec_type === 'video') { - response.infoLog += 'File is mp4 and already has the video stream in the correct order!' - + ' Due to FFmpeg issues when reordering streams in mp4 files, other stream ordering will be skipped'; + if (file.container === 'mp4' && file.fileMedium === 'video') { + if (file.ffProbeData.streams[0].codec_type === 'video') { + response.infoLog += 'File is mp4 and already has the video stream in the correct order!' + + ' Due to FFmpeg issues when reordering streams in mp4 files, other stream ordering will be skipped'; + return response; + } + response.processFile = true; + response.infoLog += 'File is mp4 and contains video but video is not first stream, remuxing'; + response.preset = ',-map 0:v? -map 0:a? -map 0:s? -map 0:d? -map 0:t? -c copy'; return response; } diff --git a/tests/Community/Tdarr_Plugin_00td_action_re_order_all_streams_v2.js b/tests/Community/Tdarr_Plugin_00td_action_re_order_all_streams_v2.js index 9dd2de4..96ca95f 100644 --- a/tests/Community/Tdarr_Plugin_00td_action_re_order_all_streams_v2.js +++ b/tests/Community/Tdarr_Plugin_00td_action_re_order_all_streams_v2.js @@ -148,11 +148,11 @@ const tests = [ }, output: { processFile: true, - preset: ' -c copy -map 0:1 -map 0:4 -map 0:2 -map 0:0 -map 0:3 -map 0:5 -map 0:6', + preset: ',-map 0:v? -map 0:a? -map 0:s? -map 0:d? -map 0:t? -c copy', container: '.mp4', handBrakeMode: false, FFmpegMode: true, - infoLog: 'Streams are not in the correct order!', + infoLog: 'File is mp4 and contains video but video is not first stream, remuxing', }, }, ];