FFMPEG: Overlaying scaled video over image

I am trying to produce video containing static image and smaller video which would be overlaid on top of it. Dimensions and position of overlay video are dynamically sent to the server script which runs FFMPEG, so I need to scale video before overlaying it. So, numeric values I used are just for test. Original video has dimensions 72:48px. I tried command like this:

ffmpeg -i background.jpg -vf "movie=overlay.mp4, scale=128:96 [inner]; [in][inner] overlay=70:70 [out]" -y output.mp4

However, it just instantly produces an empty video. If, on the other hand, I try inserting -loop 1 right after ffmpeg command, the processing of video seems to take endless time and it never finishes.

What I am trying to achieve is to avoid creating scaled video first. Is it possible and what am I doing wrong?

1 Answer

Use

ffmpeg -loop 1 -i background.jpg \ -vf "movie=overlay.mp4,scale=128:96[inner];[in][inner]overlay=70:70:shortest=1[out]" \ -y output.mp4

The image needs to be looped, but that will create an unending stream, so the shortest argument in the overlay filter stops the filter when the movie ends.


With the overlay's audio included

ffmpeg -loop 1 -i background.jpg -i overlay.mp4 \ -filter_complex "[1]scale=128:96[inner];[0][inner]overlay=70:70:shortest=1[out]" \ -map "[out]" -map 1:a -c:a copy -y output.mp4
2

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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

You Might Also Like