ffmpeg-python icon indicating copy to clipboard operation
ffmpeg-python copied to clipboard

Convert -vf to filter_complex, extra escape characters are added

Open x674 opened this issue 3 years ago • 1 comments

Please help me how to get rid of reflective characters in the filter? I am trying to make such a filter . -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" But in the final line, escape characters are added to the argument.

import ffmpeg

stream = ffmpeg.input('D:\\Projects\\Python\\webmBotPython\\16468991399960.webm')

stream = ffmpeg.filter(stream, 'scale', 'trunc(iw/2)*2:trunc(ih/2)*2')

stream = ffmpeg.output(stream, 'D:\\Projects\\Python\\webmBotPython\\1.mp4',vcodec='h264_nvenc')

ffmpeg.compile(stream)

Output string

['ffmpeg', '-i', 'D:\\Projects\\Python\\webmBotPython\\16468991399960.webm',
 '-filter_complex', '[0]scale=trunc(iw/2)*2\\\\\\\\\\\\:trunc(ih/2)*2[s0]', '-map', '[s0]', '-vcodec', 'h264_nvenc',
 'D:\\Projects\\Python\\webmBotPython\\1.mp4']

Although I expect to see

['ffmpeg', '-i', 'D:\\Projects\\Python\\webmBotPython\\16468991399960.webm',
 '-filter_complex', '[0]scale=trunc(iw/2)*2:trunc(ih/2)*2[s0]', '-map', '[s0]', '-vcodec', 'h264_nvenc',
 'D:\\Projects\\Python\\webmBotPython\\1.mp4']

x674 avatar Mar 11 '22 12:03 x674

I just had the same problem. This should do the trick:

ffmpeg.filter(stream, 'scale', 'trunc(iw/2)*2','trunc(ih/2)*2')

fsdsabel avatar May 28 '22 07:05 fsdsabel