[ACCEPTED]-FFMPEG 2 Videos transcoded and side by side in 1 frame?-transcode

Accepted answer
Score: 34

The result can be achieved with the combination 12 of scale, pad and overlay filters as the 11 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 10 by half, and padded to its original size. The 9 second video is shrunk by two thirds and 8 overlayed on the right half (padding area) of 7 the first one.

The shorter video can be 6 faded out; otherwise, it last frame will 5 be display till the end of the combined 4 video.

The result bit rate can be set with 3 -b:v option. Also, video sizes and positions 2 can be specified in pixels for pad, scale 1 and overlay filters.

Score: 2

In order to have one video take up the full 7 left half of the output video and the other 6 video take up the full right half of the 5 output video AND to have the correct audio, I 4 will expand upon @Dmitry Shkuropatsky's 3 answer. This took me like 5 or more minutes 2 to figure out, and I used ffmpeg version 1 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 in fade=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 of movie=. This is a problem if -i is a video with no audio and you want to use the audio from movie=. The second ffmpeg command copies the video stream from output.mp4 and the audio stream from right.mp4 into output_with_audio.mp4.

More Related questions