HaveAGitGat / Tdarr_Plugins

Tdarr Plugins
GNU General Public License v3.0
140 stars 158 forks source link

ffmpegCommand10BitVideo doesn't work with ffmpegCommandSetVideoEncoder(av1) #672

Open HaveAGitGat opened 4 months ago

HaveAGitGat commented 4 months ago

https://github.com/HaveAGitGat/Tdarr/issues/1032

Describe the bug When using this flow my ffmpeg commands will fail if the original file is 10 bit, the reason is that ffmpegCommand10BitVideo will inject -profile:v:0 main10 but this is not supported with libsvtav1 image

To Reproduce Use ffmpegCommand10BitVideo with ffmpegCommandSetVideoEncoder in av1 mode

Expected behavior From the documentation, set 10 bit should add something like -pix_fmt yuv420p10le

I'm currently using tdarr node on Windows 11 with ffmpeg version 7.0.1-full_build

HaveAGitGat commented 4 months ago

@Maxmystere should be fixed with: https://github.com/HaveAGitGat/Tdarr_Plugins/pull/676/files

Maxmystere commented 4 months ago

Seeing your change does the mean the SetEncoder has to always be called before Set10Bit ?

taltamir commented 2 weeks ago

@Maxmystere should be fixed with: https://github.com/HaveAGitGat/Tdarr_Plugins/pull/676/files

I looked at the code linked and it very clearly does not fix it. old code

if (stream.codec_type === 'video') {
            stream.outputArgs.push('-profile:v:{outputTypeIndex}', 'main10');
            if (stream.outputArgs.some(function (row) { return row.includes('qsv'); }) && os_1.default.platform() !== 'win32') {
                stream.outputArgs.push('-vf', 'scale_qsv=format=p010le');
            }

followed immediately by new code

            else if (stream.outputArgs.some(function (row) { return row.includes('libsvtav1'); })) {
                stream.outputArgs.push('-pix_fmt:v:{outputTypeIndex}', 'yuv420p10le');
            }

you have in order: if if else if

where the new code is the else if at the end. but the problem is that the two initial if are true and add wrong commands.

to look into them in more depth

  1. if video add main10 profile:v:0
  2. if not windows add scale_qsv=format=p010le
  3. else if libsvtav1 add yuv420p10le

where number 3 is new.

the biggest problem is number 1. it is always true since it is always video and it causes ffmpeg to error out when trying to encode libsvtav1. it needs to be false when libsvtav1 instead of being true for all video. actually I am pretty sure it should not be for all video but for specific codecs that actually have "main10". which AFAIK is just h264 and h265.

number 2 produces wrong syntax that gets auto corrected to the correct syntax by ffmpeg.

then number 3 has a 2nd copy of the correct syntax... whether number 2 or number 3 is used depends on whether or not you are running windows... it should not, it should depend on whether or not you are running libsvtav1

taltamir commented 2 weeks ago

Also, to be honest this 10 bit command should be integrated into ffmpeg command: set video encoder where each encoder should have a dropdown with whatever valid color bit depths are available for it. for av1 it should be 8bit, 10bit, or 12bit.