Knide
Knide

Reputation: 131

FFmpeg side by side video (widescreen) and play each video one by one

new to ffmpeg, I've already did this to combine 3 or more videos that I have into 1 video:

ffmpeg -i left.mp4 -i center.mp4 -i right.mp4 -filter_complex "[0:v:0][1:v:0][2:v:0]hstack=inputs=3" -c:v libx264 -tune film -crf 16 -b:a 256k output.mp4

Now what I am having trouble with is the videos have different play times (in seconds) what I want to achieve is have them all side by side (working with the code above) then have left.mp4 play first (with it's own audio) once done, center.mp4 plays (has own audio), and when done too, right.mp4 plays (has own audio) as well and the video is over.

Can someone enlighten me on how to achieve this? Thank you!

Upvotes: 1

Views: 624

Answers (1)

llogan
llogan

Reputation: 134173

Add the tpad and concat filters. Example where each input is 10 seconds long:

ffmpeg -i left.mp4 -i center.mp4 -i right.mp4 -filter_complex "[1:v]tpad=start_duration=10:start_mode=clone[v1];[2:v]tpad=start_duration=20:start_mode=clone[v2];[0:v:0][v1][v2]hstack=inputs=3,format=yuv420p[v];[0:a][1:a][2:a]concat=n=3:v=0:a=1[a]" -map "[v]" -map "[a]" -c:v libx264 -tune film -crf 16 -b:a 256k -movflags +faststart output.mp4

This will freeze frame the first frame of each video until it begins. If you want a solid color instead change start_mode=clone to start_mode=add.

Upvotes: 2

Related Questions