Is it possible to resize my videos to make them smaller with FFmpeg?

I have an original video dimensions of 1024x576, now I want to resize the video to 720x480 to meet the requirement.

How can I do this?

migrated from stackoverflow.com Jul 26 '13 at 13:48

This question came from our site for professional and enthusiast programmers.

  • ffmpeg may be deprecated, see here and here – nutty about natty Jun 29 '15 at 9:57
  • 10
    @nuttyaboutnatty The "deprecated" messages applied only to the old, dead, fake "ffmpeg" from the Libav fork, not ffmpeg from FFmpeg which returned in 15.04. – llogan Jun 29 '15 at 18:28
up vote 132 down vote accepted

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.

  • 1
    I tried ffmpeg -i output.mkv -filter:v scale=720:-1 -acodec copy -threads 12 output_shrink.mkv (in ffmpeg version 0.8.6-6:0.8.6-0ubuntu0.12.10.1) but got the error Unrecognized option 'filter:v' – doug65536 Apr 26 '13 at 15:41
  • 5
    After digging through the man page for ffmpeg several times I found that instead of -filter:v, the option appears to have been changed to -vf. – doug65536 Apr 26 '13 at 15:51
  • 2
    @doug65536 -filter:v and -vf are both fine. The Ubuntu version you were using is broken and outdated—it's not really FFmpeg's ffmpeg, but the binary supplied by Libav (the FFmpeg fork) under the same name. – slhck Jul 26 '13 at 6:41
  • 1
    @MightyPork probably your ffmpeg build is outdated - what problems happen?. Anyway, this really helped me (with ffmpeg version 2.4.10) to reduce the size of some massive videos to free up some space - thanks! – Wilf Jun 24 '15 at 21:32
  • 4
    '-c' is short for -codec, ':a' specifies audio stream(s), 'copy' specifies the copy codec, which copies the stream(s) (in this case audio) without reencoding. Basically the audio streams will pass through. This is common when you are only manipulating the video stream. – jimhark Feb 5 '16 at 23:27

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 Eg. lets say reduce the width/height yo half you can do-

ffmpeg -i input.avi -vf scale="iw/1: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

protected by Community May 13 '14 at 12:42

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

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