Vertically or horizontally stack (mosaic) several videos using ffmpeg?

后端 未结 3 1794
野性不改
野性不改 2020-11-22 13:00

I have two videos of the same exact length, and I would like to use ffmpeg to stack them into one video file.

How can I do this?

3条回答
  •  名媛妹妹
    2020-11-22 13:35

    See this answer to this question for a newer, simpler way to do this.


    Old version:
    You should be able to do this using the pad, movie and overlay filters in FFmpeg. The command will look something like this:

    ffmpeg -i top.mov -vf 'pad=iw:2*ih [top]; movie=bottom.mov [bottom]; \
      [top][bottom] overlay=0:main_h/2' stacked.mov
    

    First the movie that should be on top is padded to twice its height. Then the bottom movie is loaded. Then the bottom movie is overlaid on the padded top movie at an offset of half the padded movie's height.

提交回复
热议问题