Convert consumer video formats to DNxHD or DNxHR

Converting common consumer device video codecs, like h264 and h265, to DNxHD or DNxHR for fast editing.

Changed

The DNxHD ("Digital Nonlinear Extensible High Definition") and DNxHR ("Digital Nonlinear Extensible High Resolution") are lossy video codecs that are intended to be usable as both an intermediate format suitable for use while editing and as a presentation format. Usually using a MXF or QuickTime MOV container.

As an example for why you might like to convert video files to DNxHD or DNxHR we give DaVinci Resolve. DaVinci Resolve is a professional video editing application by BlackMagic Design. The "Basic" version is available for Linux, Mac and Windows environment for free. It supports various professional video codecs, but unlike consumer editors it does lack in support for consumer video formats under Linux for some reason. For example, the common h264 and h265 encoded videos produced by most consumer devices (phones, GoPro, camcorders, etc) will be imported with audio only under Linux (In version 15 and 16 of Resolve Free).

Fortunately the solution to this issues is quite simple, even if a bit space and time consuming, by converting the video files to a DNxHD or DNxHR with FFmpeg. DNxHD is a more editor friendly format as every frame is compressed separately instead of relying on previous frames and therefore the editing software can easily seek frame accurately in the video without need to decompress any intermediate frames. It is still a lossy format so take that into account when choosing the bitrate, larger is obviously better, downside is the space requirement. This way obviously leads to much larger files, meaning you need quite a lot of disk space for the converted videos.

DNxHD

DNxHD support Full HD (1920x1080) and HD (1280x720) frame sizes only. DNxHD also is very strict about video frame size, pixel format and framerate. The ffmpeg output format must match precisely one of the DNxHD profiles below:

DNxHD profiles for Full HD, 1920x1080, 1080p

DNxHD profiles
Frame size Bitrate Pixel Format FPS GB/Minute
1920x1080p 175Mbps yuv422p10 24 (24000/1001) 1.26 GB
1920x1080p 185Mbps yuv422p10 25 1.38 GB
1920x1080p 365Mbps yuv422p10 50 2.7 GB
1920x1080p 440Mbps yuv422p10 60 (60000/1001) 3.3 GB
1920x1080p 115Mbps yuv422p 24 (24000/1001) 0.84 GB
1920x1080p 120Mbps yuv422p 25 0.9 GB
1920x1080p 145Mbps yuv422p 30 (30000/1001) 1 GB
1920x1080p 240Mbps yuv422p 50 1.8 GB
1920x1080p 290Mbps yuv422p 60 (60000/1001) 2.1 GB
1920x1080p 175Mbps yuv422p 24 (24000/1001) 1.2 GB
1920x1080p 185Mbps yuv422p 25 1.38 GB
1920x1080p 220Mbps yuv422p 30 (30000/1001) 1.62 GB
1920x1080p 365Mbps yuv422p 50 2.7 GB
1920x1080p 440Mbps yuv422p 60 (60000/1001) 3.3 GB
1920x1080p 36Mbps yuv422p 24 (24000/1001) 0.24 GB
1920x1080p 36Mbps yuv422p 25 0.24 GB
1920x1080p 45Mbps yuv422p 30 (30000/1001) 0.3 GB
1920x1080p 75Mbps yuv422p 50 0.54 GB
1920x1080p 90Mbps yuv422p 60 (60000/1001) 0.66 GB
1920x1080p 350Mbps yuv422p10 24 (24000/1001)  
1920x1080p 390Mbps yuv422p10 25  
1920x1080p 440Mbps yuv422p10 30 (30000/1001)  
1920x1080p 730Mbps yuv422p10 50  
1920x1080p 880Mbps yuv422p10 60 (60000/1001)  

DNxHD profiles for HD, 1280x720, 720p

DNxHD profiles
Frame size Bitrate Pixel Format FPS GB/Minute
1280x720p 90Mbps yuv422p10 24 (24000/1001)  
1280x720p 90Mbps yuv422p10 25  
1280x720p 180Mbps yuv422p10 50  
1280x720p 220Mbps yuv422p10 60 (60000/1001)  
1280x720p 90Mbps yuv422p 24 (24000/1001)  
1280x720p 90Mbps yuv422p 25  
1280x720p 110Mbps yuv422p 30 (30000/1001)  
1280x720p 180Mbps yuv422p 50  
1280x720p 220Mbps yuv422p 60 (60000/1001)  
1280x720p 60Mbps yuv422p 24 (24000/1001)  
1280x720p 60Mbps yuv422p 25  
1280x720p 75Mbps yuv422p 30 (30000/1001)  
1280x720p 120Mbps yuv422p 50  
1280x720p 145Mbps yuv422p 60 (60000/1001)  

How to pick the output format ?

The output DNxHD frame format (Resolution and FPS) must match the video format of the source, so make sure you choose a suitable format from the above table.

For example if your input video is a Full HD 1920x1080, 25 FPS then you can choose output bit rates of 120, 185 or 46 Mbps. Choose the bit rate depending on how good quality you need for whatever you need to do with the DNxHD video, the bigger bit rate the more space the output video will take.

Example commands for converting to DNxHD with FFmpeg

Examples
Description FFmpeg command line
Input: MP4, Full HD, 50fps
Output: DNxHD 1920x1080p, yuv422p, 75Mbps, 50fps, Uncompressed PCM audio

ffmpeg -i input-video.mp4 -c:v dnxhd -vf "fps=50/1,format=yuv422p" -b:v 75M -c:a pcm_s16le output-video.mov
 
Hardware accelerated decoding of h264
Input: MP4, Full HD, 50fps
Output: DNxHD 1920x1080p, yuv422p, 75Mbps, 50fps, Uncompressed PCM audio
ffmpeg -c:v h264_cuvid -i input-video.mp4 -c:v dnxhd -vf "fps=50/1,format=yuv422p" -b:v 75M -c:a pcm_s16le output-video.mov

DNxHR

DNxHR is a more modern variant and much easier to use as FFmpeg will take of details like bit rate so conversion is much easier. It supports 422 and 444 colorspaces in 8-bit, 10-bit and 12-bit variants, FFmpeg only support up to 10-bits (pixel formats yuv422p, yuv422p10le and yuv444p10le)

DNxHR Profiles

Profile Description FFmpeg option ~GB/minute
LB Low Bandwidth (8-bit 4:2:2) dnxhr_lb 4K, 25fps: 1GB
SQ Standard Quality (8-bit 4:2:2) dnxhr_sq 4K, 25fps: 3.5GB
HQ High Quality (8-bit 4:2:2) dnxhr_hq 4K, 25fps: 5GB
HQX High Quality (12-bit 4:2:2) dnxhr_hqx  
444 Finishing Quality (12-bit 4:4:4) dnxhr_444  

Example commands for converting to DNxHR with FFmpeg

Examples
Description FFmpeg command line
Input: MP4, 4K, 25fps
Output: DNxHR, HQ, 4K, 25fps, Uncompressed PCM audio

ffmpeg -i input-video.mp4 -c:v dnxhd -profile:v dnxhr_hq -pix_fmt yuv422p -c:a pcm_s16le output-video.mov
 
Hardware accelerated decoding of h264
Input: MP4, Full HD, 50fps
Output: DNxHD 1920x1080p, yuv422p, 75Mbps, 50fps, Uncompressed PCM audio
ffmpeg -c:v h264_cuvid -i input-video.mp4 -c:v dnxhd -profile:v dnxhr_hq -pix_fmt yuv422p -c:a pcm_s16le output-video.mov