10

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

0

1 Answer 1

38

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.

2
  • 1
    This is a great answer, I especially like that it includes the arguments to pad to make images of different sizes all centered, instead of in the upper left corner :)
    – cxrodgers
    Aug 28, 2021 at 1:47
  • What a great answer, the generic pad command was exactly what I was looking for! Nov 10, 2023 at 21:20

Not the answer you're looking for? Browse other questions tagged .