I'm a new user of FFmpeg, and I want to insert a logo on two videos (one video overlay another) with one command.

For example, I have a background video (1), a video in scaling (2) and a logo (3P, and I want to create a video that has “3 on 2 on 1” in one command.

In normal, I have to do step by step: scale video (2), then overlay this video on background video (3), and finally overlay the logo (1) on top. I think these steps can decrease the final video quality due to re-encode 3 times.

1st step:

ffmpeg -i input.mp4 -filter:v scale=1280:720 -c:a copy output1.mp4

2nd step:

ffmpeg -loop 1 -i background.mp4 -i output1.mp4 -filter_complex "[1]scale=1280:720[inner];[0][inner]overlay=70:70:shortest=1[out]" -map "[out]" -map 1:a -c:a copy -y output2.mp4

3rd step:

ffmpeg -i output2.mp4 -i logo.png -filter_complex "[0:v][1:v]overlay=10:10:enable=not(between'(t\,10\,15)')" -codec:a copy -preset medium output3.mp4

Thank you so much for your help.


Use this command:

ffmpeg -stream_loop -1 -i background.mp4 -i input.mp4 -i logo.png
-filter_complex "[1]scale=1280:720[inner];[0][inner]overlay=70:70:shortest=1[vid];
                 [vid][2]overlay=10:10:enable='not(between(t\,10\,15))'[out]" -map "[out]" -map 1:a -c:a copy -y output.mp4

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.