How to Encode XDCAM HD422 MXF in FFmpeg

This article provides a straightforward, step-by-step guide on how to encode video to the broadcast-standard XDCAM HD422 format in an MXF container using FFmpeg. You will learn the exact command-line parameters required for video, audio, and container mapping to ensure compliance with television broadcast delivery specifications.

The Standard FFmpeg Command

To encode a video to XDCAM HD422 (50 Mbps, 1080i or 1080p, MPEG-2 Long GOP) inside an MXF container, use the following FFmpeg command:

ffmpeg -i input.mp4 -c:v mpeg2video -pix_fmt yuv422p -b:v 50M -maxrate 50M -bufsize 38M -g 12 -bf 2 -profile:v 0 -level:v 2 -color_primaries bt709 -color_trc bt709 -colorspace bt709 -c:a pcm_s24le -ar 48000 -f mxf output.mxf

Parameter Breakdown

To ensure your output file meets strict broadcast QC (Quality Control) standards, it is essential to understand what each flag does:

  • -c:v mpeg2video: Specifies the MPEG-2 video encoder, which is the underlying codec for XDCAM.
  • -pix_fmt yuv422p: Sets the chroma subsampling to 4:2:2, a requirement for the "HD422" specification.
  • -b:v 50M -maxrate 50M -bufsize 38M: Sets the constant video bitrate to 50 Mbps. The buffer size (-bufsize) ensures the bitrate remains stable and compliant with hardware decoders.
  • -g 12: Sets the Group of Pictures (GOP) size. For 25fps (PAL) and 50i/50p video, 12 is standard. For 29.97fps (NTSC) or 60i, use -g 15.
  • -bf 2: Specifies 2 B-frames, which is standard for XDCAM Long GOP structures.
  • -profile:v 0 -level:v 2: Sets the MPEG-2 profile to Main Profile @ High Level (4:2:2).
  • -color_primaries bt709 -color_trc bt709 -colorspace bt709: Forces the color space metadata to Rec. 709 (standard HD).
  • -c:a pcm_s24le: Encodes the audio as uncompressed 24-bit PCM (little-endian), which is the standard audio codec for MXF broadcast delivery.
  • -ar 48000: Sets the audio sample rate to 48 kHz.
  • -f mxf: Forces the output container format to MXF.

Encoding Interlaced Video (1080i)

Broadcast television often requires interlaced video (usually top-field first). If your source is interlaced, or if you need to output an interlaced master, add the interlaced flags to your command:

ffmpeg -i input.mp4 -c:v mpeg2video -pix_fmt yuv422p -b:v 50M -maxrate 50M -bufsize 38M -g 12 -bf 2 -profile:v 0 -level:v 2 -flags +ildct+ilme -top 1 -color_primaries bt709 -color_trc bt709 -colorspace bt709 -c:a pcm_s24le -ar 48000 -f mxf output.mxf
  • -flags +ildct+ilme: Enables interlaced discrete cosine transform (DCT) and interlaced motion estimation.
  • -top 1: Sets the field order to Top Field First (TFF).

Mapping Discrete Mono Audio Channels

XDCAM HD422 specifications often require 4 or 8 discrete mono audio tracks rather than a single stereo track. You can split a stereo input into two separate mono streams in the MXF file using the following command:

ffmpeg -i input.mp4 -c:v mpeg2video -pix_fmt yuv422p -b:v 50M -maxrate 50M -bufsize 38M -g 12 -bf 2 -profile:v 0 -level:v 2 -filter_complex "[0:a]channelsplit=channel_layout=stereo[left][right]" -map 0:v -map "[left]" -map "[right]" -c:a pcm_s24le -ar 48000 -f mxf output.mxf

This command uses -filter_complex to split the stereo input channel into two mono tracks, then maps the video (-map 0:v) and each individual audio track (-map "[left]" and -map "[right]") sequentially into the MXF container.