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:

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

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.