Saturday, April 24, 2021

How to concatenate videos with ffmpeg

This one works for me:

ffmpeg -i input1.mp4 -i input2.webm -i input3.mov \
-filter_complex "[0:v:0][0:a:0][1:v:0][1:a:0][2:v:0][2:a:0]concat=n=3:v=1:a=1[outv][outa]" \
-map "[outv]" -map "[outa]" output.mkv


Reference: https://trac.ffmpeg.org/wiki/Concatenate

It assumes the videos have the same size and TBR. To transpose a video when one is vertical and another is horizontal, see here.
When video TBRs are different, it may come up with the strange message:

"More than 1000 frames duplicated"

When this happens, try adding "-vsync 2" to the command. Reference: https://stackoverflow.com/questions/62822889/ffmpeg-filter-complex-concat-never-completes. It worked for me.

No comments:

Post a Comment