There are tons of Python FFmpeg wrappers out there but they seem to lack complex filter support. ffmpeg-python
works well for simple as well as complex signal graphs.
Flip a video horizontally:
import ffmpeg
stream = ffmpeg.input('input.mp4')
stream = ffmpeg.hflip(stream)
stream = ffmpeg.output(stream, 'output.mp4')
ffmpeg.run(stream)
Or if you prefer a fluent interface:
import ffmpeg
(ffmpeg
.input('input.mp4')
.hflip()
.output('output.mp4')
.run()
)
FFmpeg is extremely powerful, but its command-line interface gets really complicated really quickly - especially when working with signal graphs and doing anything more than trivial.
Take for example a signal graph that looks like this:
The corresponding command-line arguments are pretty gnarly:
< 7FD4 div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ffmpeg -i input.mp4 \ -filter_complex "\ [0]trim=start_frame=10:end_frame=20[v0];\ [0]trim=start_frame=30:end_frame=40[v1];\ [v0][v1]concat=n=2[v2];\ [1]hflip[v3];\ [v2][v3]overlay=eof_action=repeat[v4];\ [v4]drawbox=50:50:120:120:red:t=5[v5]"\ -map [v5] output.mp4">ffmpeg -i input.mp4 \
-filter_complex "\
[0]trim=start_frame=10:end_frame=20[v0];\
[0]trim=start_frame=30:end_frame=40[v1];\
[v0][v1]concat=n=2[v2];\
[1]hflip[v3];\
[v2][v3]overlay=eof_action=repeat[v4];\
[v4]drawbox=50:50:120:120:red:t=5[v5]"\
-map [v5] output.mp4