Reputation: 999
Using ffmpeg command line I want to overlay 2 different videos on top of another (main video) at different time for different duration. I have successfully overlayed 1 video over the main video at specific time and for specific duration using following command:
ffmpeg -i main.mp4 -i first.mp4 \
-filter_complex "[1:v]setpts=PTS-32/TB[a]; \
[0:v][a]overlay=enable=gte(t\,5):eof_action=pass[out]; \
[1] scale=480:270 [over]; [0][over] overlay=400:400" \
-map [out] -map 0:a \
-c:v libx264 -crf 18 -pix_fmt yuv420p \
-c:a copy \
output.mp4
How can i modify the same command to apply the same operations on two secondary videos at the same time?
Upvotes: 4
Views: 2389
Reputation: 92928
Corrected version of your command:
ffmpeg -i main.mp4 -i first.mp4 \
-filter_complex "[1:v]setpts=PTS-32/TB,scale=480:270[a]; \
[0:v][a]overlay=400:400:enable=gte(t\,5):eof_action=pass[out]" \
-map [out] -map 0:a \
-c:v libx264 -crf 18 -pix_fmt yuv420p \
-c:a copy \
output.mp4
For two secondary videos,
ffmpeg -i main.mp4 -i first.mp4 -i second.mp4 \
-filter_complex "[1:v]setpts=PTS-32/TB,scale=480:270[a]; \
[2:v]setpts=PTS-32/TB,scale=480:270[b]; \
[0:v][a]overlay=400:400:enable=gte(t\,5):eof_action=pass[out0]; \
[out0][b]overlay=400:400:enable=gte(t\,5):eof_action=pass[out]" \
-map [out] -map 0:a \
-c:v libx264 -crf 18 -pix_fmt yuv420p \
-c:a copy \
output.mp4
You'll have to adjust the PTS, scale, position and timing of 2nd overlay to see it doesn't overlap with first one.
Upvotes: 2