TTrimpx

FFmpeg Tutorial

Everyday FFmpeg Video Filters, With Tested Commands

Resize, fit, crop, rotate, mirror and change frame rate. Each command below was run and its output checked.

How we checked these commands: every command on this page was run with FFmpeg 8.1.2 on macOS on 24 October 2026, on short generated test clips, and the output was inspected with ffprobe (resolution, frame rate, duration, streams). Results on your files can differ if your FFmpeg build or input files are different.

Video filters are added with -vf followed by the filter name and its options. Several filters can be chained with commas, for example -vf "scale=1280:-2,hflip". Any command that uses -vf re-encodes the video, so the picture is compressed again. Adding -c:a copy keeps the audio untouched. The filter options are described in the official FFmpeg Filters Documentation.

Put quotes around any filter option that contains brackets, commas or spaces. Without them, shells like zsh and bash read the brackets themselves and the command fails before FFmpeg even starts. We hit exactly this with an unquoted crop expression in zsh (no matches found).

1. Resize to 1920 pixels wide and keep the aspect ratio

ffmpeg -i input.mp4 -vf scale=1920:-2 -c:a copy output-1080p.mp4

-2 tells FFmpeg to work out the height from the aspect ratio and round it to an even number. Use -2 rather than -1. In our test, a 1000×562 clip scaled with scale=1920:-1 came out 1079 pixels high, and the H.264 encoder (libx264) refused the odd height and wrote no file. With -2 it produced 1920×1080. A 1280×720 test clip also came out 1920×1080.

2. Fit into a fixed box without stretching (for example 480×320)

ffmpeg -i input.mp4 -vf "scale=480:320:force_original_aspect_ratio=decrease,pad=480:320:(ow-iw)/2:(oh-ih)/2" -c:a copy output-480x320.mp4

A plain scale=480:320 squeezes a 16:9 video into a 3:2 frame and distorts it. Here, force_original_aspect_ratio=decrease shrinks the video until it fits inside the box, and pad centres it with black bars. Our 1280×720 test clip came out 480×320 with bars above and below.

3. Crop the centre of the frame

ffmpeg -i input.mp4 -vf "crop=1280:720:(in_w-1280)/2:(in_h-720)/2" -c:a copy center-crop.mp4

The four values are output width, output height, and the x and y position of the top-left corner. in_w and in_h are the input size, so this takes a 1280×720 window from the middle. A 1920×1080 test clip came out 1280×720. The crop size must not be larger than the input.

4. Rotate a vertical phone video 90°

ffmpeg -i vertical.mp4 -vf "transpose=1" -c:a copy rotated.mp4

transpose=1 rotates 90° clockwise and transpose=2 rotates 90° counter-clockwise. Our 1080×1920 test clip came out 1920×1080. If your phone video only looks rotated because of a rotation flag in its metadata, check it in a player first. Recent FFmpeg versions apply that flag automatically when re-encoding, so adding transpose as well may turn the picture too far.

5. Mirror the picture

ffmpeg -i input.mp4 -vf hflip -c:a copy mirrored.mp4

hflip mirrors left to right and vflip flips top to bottom. Size and duration stay the same.

6. Change the frame rate

ffmpeg -i input.mp4 -vf fps=24 -c:a copy output-24fps.mp4

The fps filter drops or duplicates frames to reach the new rate. It does not create smooth in-between frames. A 30 fps test clip came out at 24 fps with the same 4-second duration.

Related guides