I want to mimic the following ffmpeg command with ffmpeg-python
ffmpeg -y -i in.mp4 -t 30 -filter_complex "fps=10,scale=-1:-1:flags=lanczos[x];[0:v]palettegen[y];[x][y]paletteuse" out.gif
So far, this is what I've got:
in_stream = ffmpeg.input(src, ss=start_time, t=(stop_time-start_time))
scale_input = in_stream
if fps >= 1:
stream = ffmpeg.filter(in_stream['v'], 'fps', fps)
scale_input = stream
stream = ffmpeg.filter(scale_input, 'scale', output_width, output_height, 'lanczos')
palette = ffmpeg.filter(in_stream['v'], 'palettegen')
#stream = ffmpeg.filter(stream, palette, 'paletteuse') ???
stream.output(dst).run()
I checked, the palette generates well if I output it as a png. However, I can't find how to use it through the multi-input command paletteuse
, as filters only take one stream as an input in ffmpeg-python. I tried concatenating them with ffmpeg.concat()
which is the only method I found to make one stream from two but I think it is non-sense (and it doesn't work anyway).
Any idea?