Hands-on ffmpeg examples showing how CRF, GOP length, profile, pixel format, HDR flags, VMAF, and presets appear as real command-line options.
Let's connect the theory to real tools. ffmpeg is the Swiss Army knife that virtually every codec engineer uses every day. Here you will see how the concepts you have learned appear as actual options. Filters passed with -vf, such as resizing and cropping, are covered in Chapter 17.
ffmpeg -i input.mov \
-c:v libx264 -preset medium \
-crf 23 \ # Ch. 2 CRF: target for perceived quality (lower = higher quality)
-profile:v high -level 4.1 \ # Ch. 5: sets the compatibility range
-g 60 -keyint_min 60 \ # Ch. 10: GOP length (keyframe interval)
-pix_fmt yuv420p \ # Ch. 1: chroma format
output.mp4ffmpeg -i input_hdr.mov \
-c:v libx265 -preset slow -crf 20 \
-pix_fmt yuv420p10le \ # Ch. 1: 10-bit
-color_primaries bt2020 \ # Ch. 1: CICP - color primaries
-color_trc smpte2084 \ # Ch. 1: CICP - PQ transfer function
-colorspace bt2020nc \ # Ch. 1: CICP - matrix
-x265-params hdr10=1 \ # real HDR10 also needs master-display and max-cll values set separately
output_hevc.mp4ffmpeg -i output.mp4 -i input.mov \
-lavfi libvmaf="model=version=vmaf_v0.6.1" \
-f null -
# Example output:
# VMAF score: 94.32 ← the Chapter 2 rule of thumb: around 93 or higher is generally said to be hard to tell apartffprobe -v error -show_format -show_streams input.mp4 | grep -E \
"codec_name|pix_fmt|color_|bit_rate|r_frame_rate"Presets such as -preset medium and -preset slow are knobs that control the search range of the RDO from Chapter 3. slow actually tries more mode and block-partition candidates and picks the best one, which makes it slower. fast narrows the candidates quickly with heuristics, trading a little quality and compression efficiency for speed. This is why the same CRF value gives different file sizes and quality depending on the preset.
How much file size and time actually change with the preset is measured in the x265 preset measurement, and the CRF recommender helps you find the CRF value for a target VMAF from measured data. The order in which to choose preset and rate control continues in Chapter 18.
The de facto industry-standard open-source tools for video processing and analysis.
A setting that controls the encoder's RDO search range (the speed vs. compression efficiency trade-off).
What does the encoder's preset option (fast/medium/slow, etc.) actually control?