[FFmpeg-user] Merge two videos into one with side-by-side composition

John Crossman johncrossman at berkeley.edu
Mon Jun 10 23:00:41 CEST 2013


Thank you, Lou! I'll give it a try and report results.


On Mon, Jun 10, 2013 at 12:57 PM, Lou <lou at lrcd.com> wrote:

> On Mon, 10 Jun 2013 09:27:22 -0700
> John Crossman <johncrossman at berkeley.edu> wrote:
>
> > Is there ffmpeg documentation on how to merge two videos into one with
> > side-by-side composition?
> >
> > The following is an example of what I'm after. Jump to 0:30:
> > http://www.youtube.com/watch?v=0AJWmt5A62Y
>
> You can use the pad [1] and overlay [2] video filters to place your
> videos:
>
> ffmpeg -i input1 -i input2 -filter_complex \
> "[0:v:0]pad=iw*2:ih[bg]; [bg][1:v:0]overlay=w" output
>
> The overlay docs states:
>
>   Be aware that frames are taken from each input video in timestamp
>   order, hence, if their initial timestamps differ, it is a a good
>   idea to pass the two inputs through a setpts=PTS-STARTPTS filter to
>   have them begin in the same zero timestamp, as it does the example
>   for the movie filter.
>
> Resulting in:
>
> ffmpeg -i input1 -i input2 -filter_complex \
> "[0:v]setpts=PTS-STARTPTS, pad=iw*2:ih[bg]; \
> [1:v]setpts=PTS-STARTPTS[fg]; [bg][fg]overlay=w" output
>
> By default only one audio stream will be used, so if you want to combine
> both input audio streams into one output audio stream you can use the
> amerge [3] and pan [4] audio filters. My example has one stereo audio
> stream per input and the output will have one combined stereo audio
> stream:
>
> ffmpeg -i input1 -i input2 -filter_complex \
> "[0:v]setpts=PTS-STARTPTS, pad=iw*2:ih[bg]; \
> [1:v]setpts=PTS-STARTPTS[fg]; [bg][fg]overlay=w; \
> amerge,pan=stereo:c0<c0+c2:c1<c1+c3" output
>
> This combination of filters is not the only method to do this, and I
> may have forgotten something, so feel free to experiment.
>
> [1] http://ffmpeg.org/ffmpeg-filters.html#pad
> [2] http://ffmpeg.org/ffmpeg-filters.html#overlay-1
> [3] http://ffmpeg.org/ffmpeg-filters.html#amerge
> [4] http://ffmpeg.org/ffmpeg-filters.html#pan
> _______________________________________________
> ffmpeg-user mailing list
> ffmpeg-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-user
>



-- 
*John Crossman*
Educational Technology Services
UC Berkeley

Work: (510) 725-2969
Personal: (510) 681-5483


More information about the ffmpeg-user mailing list