Configure Blu-ray GOP and Buffer in FFmpeg
Authoring Blu-ray-compliant video requires strict adherence to
specific Group of Pictures (GOP) structures and Video Buffer Verifier
(VBV) settings to ensure compatibility with hardware players. This guide
provides the exact FFmpeg command-line parameters and configurations
needed to meet these stringent hardware standards, focusing on keyframe
placement, closed GOP enforcement, and buffer constraints using the
libx264 encoder.
The Compliant FFmpeg Command
To encode a 1080p video at 23.976 fps (or 24 fps) for Blu-ray, use the following standardized FFmpeg command:
ffmpeg -i input.mp4 -c:v libx264 -pix_fmt yuv420p -profile:v high -level 4.1 \
-preset slow -b:v 30M -maxrate 40M -bufsize 30M \
-bluray-compat 1 -g 24 -keyint_min 1 -sc_threshold 0 \
-bf 3 -b-pyramid strict -flags +cgop -nal-hrd vbr \
-an output.264Detailed Parameter Breakdown
To achieve strict Blu-ray compatibility, your FFmpeg command must address three main categories: general compatibility flags, GOP structure constraints, and VBV buffer limits.
1. General Blu-ray Compatibility Flags
-bluray-compat 1: This is a critical helper flag inlibx264that automatically enables several internal settings required for Blu-ray compliance (such as limiting references frames and modifying slice spacing).-profile:v high -level 4.1: Restricts the H.264 profile and level. Level 4.1 is the maximum allowed level for 1080p Blu-ray playback.-pix_fmt yuv420p: Enforces the YUV 4:2:0 chroma subsampling method required by the Blu-ray specification.
2. Strict GOP Structure Settings
Blu-ray players require predictable keyframe intervals and
self-contained GOPs. * -g 24: Sets the
maximum GOP size (keyframe interval). For 23.976 fps or 24 fps content,
the GOP size must not exceed 24 (effectively 1 second). For 29.97 fps or
59.94 fps, adjust this to 30 or 60
respectively. * -keyint_min 1: Sets the
minimum GOP size. * -sc_threshold 0:
Disables scene-change detection. This prevents FFmpeg from inserting
extra, non-conforming I-frames at scene cuts, ensuring a completely
fixed and predictable GOP structure. *
-flags +cgop: Enforces “Closed GOP”
structures. This ensures that B-frames in one GOP do not reference
P-frames in a previous GOP, which is mandatory for Blu-ray seamless
branching and seeking. * -bf 3: Limits the
maximum number of consecutive B-frames to 3. *
-b-pyramid strict: Restricts B-frame
referencing hierarchy to the strict mode allowed by the Blu-ray
specification.
3. VBV Buffer and Bitrate Limits
The Blu-ray hardware buffer must never underflow or overflow. You
must define these limits explicitly using the Hypothetical Reference
Decoder (HRD) model. * -maxrate 40M: Sets
the maximum instantaneous bitrate to 40 Mbps (40,000 kbps), which is the
physical read limit for video on standard Blu-ray discs. *
-bufsize 30M: Sets the VBV buffer size to
30 Mbps. This controls how much data the hardware player can buffer to
smooth out spikes in high-complexity scenes. *
-nal-hrd vbr: Enables HRD signaling in the
output bitstream. This is a strict hardware requirement for players to
allocate and verify memory buffers correctly during playback. If you are
using a constant bitrate (CBR) encoding method, change this value to
cbr.