ffmpeg overlay video on another video in specific time
11,440
You have to use the enable
option:
ffmpeg -i D:\ffmpeg\base_video.mp4 -i D:\ffmpeg\top_video.avi -filter_complex \
"[0:0][1:0]overlay=enable='between(t\,45,50)'[out]" \
-shortest -map [out] -map 0:1 \
-pix_fmt yuv420p -c:a copy -c:v libx264 -crf 18 D:\ffmpeg\final_video.mp4
To delay the start of the top video, use the setpts filter.
ffmpeg -i D:\ffmpeg\base_video.mp4 -i D:\ffmpeg\top_video.avi -filter_complex \
"[1]setpts=PTS-STARTPTS+10/TB[top];
[0:0][top]overlay=enable='between(t\,10,15)'[out]" \
-shortest -map [out] -map 0:1 \
-pix_fmt yuv420p -c:a copy -c:v libx264 -crf 18 D:\ffmpeg\final_video.mp4
Related videos on Youtube
Author by
BOB
Looking for pursue my career in a work environment that will utilize and reinforce my technical skills and abilities and also to apply and gain new cutting edge skills and experience in a rapidly changing field
Updated on September 18, 2022Comments
-
BOB almost 2 years
I have video with duration 01:30 min and i have another video with duration 00:50 sec i want to overlay the second video on the top of the first video at 00:45 to 00:50
i'm trying to use this command but it doesn't work
ffmpeg -i D:\ffmpeg\base_video.mp4 -i D:\ffmpeg\top_video.avi -filter_complex "[0:0][1:0]overlay[out]" -shortest -map [out] -map 0:1 -pix_fmt yuv420p -c:a copy -c:v libx264 -crf 18 D:\ffmpeg\final_video.mp4
any suggestions please?
Thanks
-
BOB about 8 yearsThanks @Mulvya that's works fine but there is another problem founded if i overlay the video from 00:00 to 00:05 that's works fine but if i choose another time such as 00:10 to 00:15 it's overlay the last frame only from the top video, so how we can solve this issue
-
BOB about 8 yearsI think that's happen because the both video start play at 00:00 and the top video appears only at the specific time so i need to make the top video start playing at 00:10 not at 00:00
-
BOB about 8 yearshey bro, can i overlay more than one video in specific time with the same way? i'm search about it but i didn't find a good way to solve this issue
-
Gyan about 8 yearsAdd another overlay filter, where first input is the output of the previous overlay filter e.g.
[out][2:v]overlay[out2]
-
BOB about 8 yearsThanks bro, i understand this solution, but can i do it in one command?