Rough note on ffmpeg: Merge Two Videos Side by Side 1


The following command will create a video from two input files and place them side by side using the hstack filter.

ffmpeg -i left.mp4 -i right.mp4 -filter_complex hstack output.mp4;

More information on the hstack filter:

11.104 hstack
Stack input videos horizontally.
All streams must be of same pixel format and of same height.
Note that this filter is faster than using overlay and pad filter to create same output.
The filter accepts the following option:
inputs
Set number of input streams. Default is 2.
shortest
If set to 1, force the output to terminate when the shortest input terminates. Default value is 0

You can use the vstack filter in case you want to place the one video above the other.

This post is also available in: Greek


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

One thought on “Rough note on ffmpeg: Merge Two Videos Side by Side

  • George

    To add a delay to one of the two videos, add the parameter -itsoffset right before the -i parameter for the video which you want to add the delay.
    Example:
    ffmpeg -i left.mp4 -itsoffset 2.34 -i right.mp4 -filter_complex hstack output.mp4;
    The above command will delay right.mp4 by 2.34 seconds.