In this how-to, we show you how to resize video with the ffmpeg command line utility and the scale filter 1)
ffmpeg permits to set the dimension of a video to -1 in order to preserve aspect ratio
Once, you have installed ffmpeg, you can resize:
ffmpeg -i output.mp4 -vf "scale=960:-1" output_960.mp4
ffmpeg -i output.mp4 -vf "scale=-1:300" output_300.mp4
Note that you can also resize an image
ffmpeg -i input.jpg -vf scale=320:-2 output_320.png
You may encounter this error height not divisible by 2.
If you encounter the above error, you may want to use the following expression 2)
scale=640:trunc(ow/a/2)*2
where ow is the width of the output. </note>
On the width:
ffmpeg -i input.mp4 -vf "scale=trunc(iw/4)*2:-1" output_down_2.mp4
On the height
ffmpeg -i input.mp4 -vf "scale=iw:ih/2:0:0" output_down_2.mp4
Where iw and ih means the width and height of the input video.
You can achieve this with the force_original_aspect_ratio option. It has two possible values:
Example 3)
ffmpeg -i input.jpg -vf scale=w=320:h=240:force_original_aspect_ratio=decrease output_320.png