2

This question already has an answer here:

I have a video that I want to upscale but I don't want to lose the aspect ratio of the original video.

My source file resolution is 864 x 692 and I want to upscale it to 1280 x 720

I found this on superuser but honestly I could not understand how to do it.

If you can help me build a ffmpeg command that is suited to my case it will really help me.

Thank you

Update I used this guide and I got close to whatever I wanted to do https://superuser.com/a/690211

marked as duplicate by llogan ffmpeg Jul 30 '18 at 18:26

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

9

You have two main options to make it fit after using scale: pad or crop. Take a look at these examples and the documentation for each filter.

pad

This will pillarbox the image.

enter image description here

ffmpeg -i input -vf "scale=-1:720,pad=1280:ih:(ow-iw)/2" output

A more generic command that will work for all input file aspect ratios will use force_original_aspect_ratio=1 as an option to scale:

ffmpeg -i input -vf "scale=w=1280:h=720:force_original_aspect_ratio=1,pad=1280:720:(ow-iw)/2:(oh-ih)/2" output

crop

This will cut off the top and bottom.

enter image description here

ffmpeg -i input -vf "scale=1280:-1,crop=iw:720" output

A more generic command that will work for all input file aspect ratios will use force_original_aspect_ratio=2 as an option to scale:

ffmpeg -i input -vf "scale=w=1280:h=720:force_original_aspect_ratio=2,crop=1280:720" output

Use your player

If you don't want to bother with re-encoding, then any player worth using should allow you to do this upon playback. Example using ffplay:

ffplay -vf "scale=-1:720,pad=1280:ih:(ow-iw)/2" input

Or see "Video Effects" in VLC.

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