How to resize a video to make it smaller with FFmpeg

The most basic example is this:

ffmpeg -i input.avi -s 720x480 -c:a copy output.mkv

Using the scale filter will provide more flexibility:

ffmpeg -i input.avi -filter:v scale=720:-1 -c:a copy output.mkv

The -1 will tell ffmpeg to automatically choose the correct height in relation to the provided width to preserve the aspect ratio. -1 can also be used for width if you provide a given height.


One downside of scale when using libx264 is that this encoder requires even values and scale may automatically choose an odd value resulting in an error: width or height not divisible by 2. You can tell scale to choose an even value for a given height (720 in this example):

scale="trunc(oh*a/2)*2:720"

...or a given width (1280 in this example):

scale="1280:trunc(ow/a/2)*2"

Note that your ffmpeg build could complain about not recognizing -c or -filter options. It also may not support scale. In that case you should use a newer ffmpeg, which you can download as a static build, or compile yourself.


I use following commands to do rescaling for videos and images. For fixed width and height -

ffmpeg -i input.avi -vf scale="720:480" output.avi

and if you want to retain aspect ratio just give height as -1 and it will automatically resize based on the width -

ffmpeg -i input.avi -vf scale="720:-1" output.avi

If you want to scale based on input size e.g. lets say reduce the width/height to half you can do -

ffmpeg -i input.avi -vf scale="iw/2:ih/2" output.avi

NOTE :

iw : input width
ih : input height

Static build can be downloaded from - https://johnvansickle.com/ffmpeg/

Documentation : https://ffmpeg.org/ffmpeg.html#filter_005foption

Tags:

Ffmpeg