简体   繁体   中英

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!

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM