FFmpeg Video Filters Halving Video Resolution

Halving Video Resolution

AS
Aman Saurav
| Jan 24, 2025 |
6 min read
#video #scaling

Reducing the resolution of a video is a classic compression technique. Reducing both width and height by half reduces the total pixel count by 75%.

Using the Scale Filter

ffmpeg -i input.mp4 -vf "scale=iw/2:ih/2" output.mp4
  • -vf: Video Filter.
  • scale: The resizing filter.
  • iw: Input Width variable.
  • ih: Input Height variable.

So iw/2:ih/2 tells FFmpeg to calculate the new size dynamically based on the input source.

Handling Odd Dimensions

If your video width is an odd number (e.g., 1921), dividing by 2 gives a fraction, which some codecs (like H.264) hate. To fix this, create a dimension divisible by 2:

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

Using -2 for height tells FFmpeg to calculate the height automatically to preserve aspect ratio, while ensuring the resulting value is divisible by 2.