How to Encode DNxHR to MXF with FFmpeg
This guide provides a straightforward, step-by-step tutorial on how to encode and wrap DNxHR video into an MXF container using FFmpeg. You will learn the exact command-line syntax, understand the required parameters for different DNxHR profiles, and discover how to structure your commands to ensure maximum compatibility with professional non-linear editors (NLEs) like Avid Media Composer, DaVinci Resolve, and Adobe Premiere Pro.
The Basic FFmpeg Command
To write a DNxHR video to an MXF container, you must use the
dnxhd video encoder flag in FFmpeg, specify the appropriate
DNxHR profile, and set the output extension to .mxf.
Here is the standard command for a High Quality (HQ) 8-bit output:
ffmpeg -i input.mp4 -c:v dnxhd -profile:v dnxhr_hq -pix_fmt yuv422p -c:a pcm_s16le output.mxfCommand Breakdown:
-i input.mp4: Specifies your source input file.-c:v dnxhd: Selects the DNxHD/DNxHR video encoder. (FFmpeg uses the same encoder library for both).-profile:v dnxhr_hq: Tells the encoder to use the DNxHR High Quality profile.-pix_fmt yuv422p: Sets the pixel format to 8-bit YUV 4:2:2, which is required for the HQ profile.-c:a pcm_s16le: Encodes the audio to uncompressed 16-bit PCM, which is the standard audio format for MXF broadcast containers.output.mxf: Defines the output container format as MXF.
Choosing the Right DNxHR Profile
DNxHR supports various profiles depending on your quality needs and
color bit-depth. You must pair the correct profile flag
(-profile:v) with its supported pixel format
(-pix_fmt).
| DNxHR Profile | Quality Level | Bit-Depth / Color | FFmpeg Profile Flag | FFmpeg Pixel Format Flag |
|---|---|---|---|---|
| DNxHR LB | Low Bandwidth | 8-bit 4:2:2 | -profile:v dnxhr_lb |
-pix_fmt yuv422p |
| DNxHR SQ | Standard Quality | 8-bit 4:2:2 | -profile:v dnxhr_sq |
-pix_fmt yuv422p |
| DNxHR HQ | High Quality | 8-bit 4:2:2 | -profile:v dnxhr_hq |
-pix_fmt yuv422p |
| DNxHR HQX | High Quality (10-bit) | 10-bit 4:2:2 | -profile:v dnxhr_hqx |
-pix_fmt yuv422p10le |
| DNxHR 444 | High Quality (Cinema) | 10-bit 4:4:4 | -profile:v dnxhr_444 |
-pix_fmt yuv444p10le |
Advanced Command Examples
Encoding to 10-bit DNxHR HQX (High Quality Extended)
If you are working with HDR or log footage and need to preserve 10-bit color depth, use the following command:
ffmpeg -i input.mp4 -c:v dnxhd -profile:v dnxhr_hqx -pix_fmt yuv422p10le -c:a pcm_s24le output.mxfNote: This command uses -c:a pcm_s24le to export
24-bit audio, which matches the professional 10-bit video
workflow.
Handling Specific Frame Rates and Scaling
When conforming footage for a broadcast delivery specification, you may need to force a specific frame rate (e.g., 23.976 fps) and scale the resolution to 4K UHD (3840x2160):
ffmpeg -i input.mp4 -vf "scale=3840:2160" -r 24000/1001 -c:v dnxhd -profile:v dnxhr_sq -pix_fmt yuv422p -c:a pcm_s16le output.mxf-vf "scale=3840:2160": Scales the video to UHD resolution.-r 24000/1001: Forces a precise frame rate of 23.976 fps.