FFMPEG 2 Videos transcoded and side by side in 1 frame?
The result can be achieved with the combination of scale, pad and overlay filters as the following:
ffmpeg.exe -i LeftInput.mp4 -vf "[in] scale=iw/2:ih/2, pad=2*iw:ih [left];
movie=RightInput.mp4, scale=iw/3:ih/3, fade=out:300:30:alpha=1 [right];
[left][right] overlay=main_w/2:0 [out]" -b:v 768k Output.mp4
Here the first video is shrunk by half, and padded to its original size. The second video is shrunk by two thirds and overlayed on the right half (padding area) of the first one.
The shorter video can be faded out; otherwise, it last frame will be display till the end of the combined video.
The result bit rate can be set with -b:v
option. Also, video sizes and positions can be specified in pixels for pad, scale and overlay filters.
In order to have one video take up the full left half of the output video and the other video take up the full right half of the output video AND to have the correct audio, I will expand upon @Dmitry Shkuropatsky's answer. This took me like 5 or more minutes to figure out, and I used ffmpeg version 3.4 (Copyright (c) 2000-2017):
>ffmpeg -i left.webm -vf "[in] scale=iw/2:ih/2, pad=2*iw:ih [left]; movie=right.mp4, scale=iw/2:ih/2, fade=alpha=1 [right]; [left][right] overlay=main_w/2:0 [out]" -c:a aac -b:v 3800k output.mp4
>ffmpeg -i output.mp4 -i right.mp4 -c copy -map 0:0 -map 1:1 -shortest output_with_audio.mp4
Changes:
- No fadeout
I successfully removed the fade out option/argument because it was causing me problems. If you want to use fade out then maybe change the numbers infade=out:300:30:alpha=1
for your specific case. - Left video filling the whole left half and right video filling the whole right half
Instead of the right half only being two thirds full with the right video I changed it to be fully full with the video for the right half. - Fixed audio problems
I ran the second FFmpeg command because the first one (with all the-vf
stuff) seems to only use the audio from the contents of-i
and not the contents ofmovie=
. This is a problem if-i
is a video with no audio and you want to use the audio frommovie=
. The second ffmpeg command copies the video stream fromoutput.mp4
and the audio stream fromright.mp4
intooutput_with_audio.mp4
.