I have an image frame 1920x1080 and a video with the same resolution.

I want to resize video by 80% of its resolution and center it, and then overlay it with image frame. So the final video result is 1920x1080

How i can do that?


You can try this.

ffmpeg -i input_video -loop 1 -i input_image -t video_duration -filter_complex "[0:v]scale=iw*80/100:ih*80/100[vo];[1:v][vo]overlay=(main_w-overlay_w)/2:(main_h-overlay_h)/2,setpts=PTS-STARTPTS[outv]" -c:v libx264 -map [outv] output_video

Here you have to use filter_complex and map for overlaying and do the scaling, etc. 0:v refers to the input video and it's width and height being scaled to be 80% of its original. 1:v refers to the input image and it is overlay with the scaled video to the centre of the image. loop will loop the image through out the video duration and -t will limit the duration of the output video to seconds you want.

If you need original audio available in the output video use -map 0:a before specifying the output file.

ffmpeg -i input_video -loop 1 -i input_image -t video_duration -filter_complex "[0:v]scale=iw*80/100:ih*80/100[vo];[1:v][vo]overlay=(main_w-overlay_w)/2:(main_h-overlay_h)/2,setpts=PTS-STARTPTS[outv]" -c:v libx264 -map [outv] -map 0:a -c:a copy output_video

Hope this will help you!

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.