How to convert a video with ffmpeg into the DNxHD / DNxHR format?
This is a picky encoder so you have to choose proper parameters including:
- frame rate
- pixel format / color space
- width x height / resolution / frame size
- bitrate
See the Valid DNxHD parameters below for accepted values.
DNxHD example
This example will scale to 1280x720, choose a frame rate of 30000/1001 (aka "29.97"), and a pixel format of YUV 4:2:2 planar.
ffmpeg -i input -c:v dnxhd -vf "scale=1280:720,fps=30000/1001,format=yuv422p" -b:v 110M -c:a pcm_s16le output.mov
-
If your input file already conforms to some of the accepted parameters then you don't have to manually declare them.
-
Output format container for DNxHD is typically MXF or MOV.
DNxHR example
DNxHR is for resolutions bigger than 1080p such as 2K, 4K, and 8K.
Example for DNxHR HQX, 10-bit 4:2:2, 4K (4096x2160), 24 fps:
ffmpeg -i input -c:v dnxhd -vf "scale=4096:2160,fps=24,format=yuv422p10le" -profile:v dnxhr_hqx -b:v 746M -c:a pcm_s16le output.mov
The -profile:v
output option is required to select the DNxHR profile, such as -profile:v dnxhr_hq
.
Accepted values for -profile:v
are: dnxhd
, dnxhr_444
, dnxhr_hqx
, dnxhr_hq
, dnxhr_sq
, dnxhr_lb
.
- DNxHR LB:
dnxhr_lb
- Low Bandwidth. 8-bit 4:2:2 (yuv422p
). Offline Quality. - DNxHR SQ:
dnxhr_sq
- Standard Quality. 8-bit 4:2:2 (yuv422p
). Suitable for delivery format. - DNxHR HQ:
dnxhr_hq
- High Quality. 8-bit 4:2:2 (yuv422p
). - DNxHR HQX:
dnxhr_hqx
- High Quality. 10-bit 4:2:2 (yuv422p10le
). UHD/4K Broadcast-quality delivery. - DNxHR 444:
dnxhr_444
- Finishing Quality. 10-bit 4:4:4 (yuv444p10le
). Cinema-quality delivery.
The above list was adapted from DNxHR codec.
Valid DNxHD parameters
ffmpeg
will fail if you provide incorrect values, but it can provide a list of what is accepted. (For DNxHR, scroll down to Valid DNxHR parameters section below.)
You can show the list with the following "dummy" command:
$ ffmpeg -loglevel error -f lavfi -i testsrc2 -c:v dnxhd -f null -
Frame size: 1920x1080p; bitrate: 175Mbps; pixel format: yuv422p10
Frame size: 1920x1080p; bitrate: 185Mbps; pixel format: yuv422p10
Frame size: 1920x1080p; bitrate: 365Mbps; pixel format: yuv422p10
Frame size: 1920x1080p; bitrate: 440Mbps; pixel format: yuv422p10
Frame size: 1920x1080p; bitrate: 115Mbps; pixel format: yuv422p
Frame size: 1920x1080p; bitrate: 120Mbps; pixel format: yuv422p
Frame size: 1920x1080p; bitrate: 145Mbps; pixel format: yuv422p
Frame size: 1920x1080p; bitrate: 240Mbps; pixel format: yuv422p
Frame size: 1920x1080p; bitrate: 290Mbps; pixel format: yuv422p
Frame size: 1920x1080p; bitrate: 175Mbps; pixel format: yuv422p
Frame size: 1920x1080p; bitrate: 185Mbps; pixel format: yuv422p
Frame size: 1920x1080p; bitrate: 220Mbps; pixel format: yuv422p
Frame size: 1920x1080p; bitrate: 365Mbps; pixel format: yuv422p
Frame size: 1920x1080p; bitrate: 440Mbps; pixel format: yuv422p
Frame size: 1920x1080i; bitrate: 185Mbps; pixel format: yuv422p10
Frame size: 1920x1080i; bitrate: 220Mbps; pixel format: yuv422p10
Frame size: 1920x1080i; bitrate: 120Mbps; pixel format: yuv422p
Frame size: 1920x1080i; bitrate: 145Mbps; pixel format: yuv422p
Frame size: 1920x1080i; bitrate: 185Mbps; pixel format: yuv422p
Frame size: 1920x1080i; bitrate: 220Mbps; pixel format: yuv422p
Frame size: 1440x1080i; bitrate: 120Mbps; pixel format: yuv422p
Frame size: 1440x1080i; bitrate: 145Mbps; pixel format: yuv422p
Frame size: 1280x720p; bitrate: 90Mbps; pixel format: yuv422p10
Frame size: 1280x720p; bitrate: 180Mbps; pixel format: yuv422p10
Frame size: 1280x720p; bitrate: 220Mbps; pixel format: yuv422p10
Frame size: 1280x720p; bitrate: 90Mbps; pixel format: yuv422p
Frame size: 1280x720p; bitrate: 110Mbps; pixel format: yuv422p
Frame size: 1280x720p; bitrate: 180Mbps; pixel format: yuv422p
Frame size: 1280x720p; bitrate: 220Mbps; pixel format: yuv422p
Frame size: 1280x720p; bitrate: 60Mbps; pixel format: yuv422p
Frame size: 1280x720p; bitrate: 75Mbps; pixel format: yuv422p
Frame size: 1280x720p; bitrate: 120Mbps; pixel format: yuv422p
Frame size: 1280x720p; bitrate: 145Mbps; pixel format: yuv422p
Frame size: 1920x1080p; bitrate: 36Mbps; pixel format: yuv422p
Frame size: 1920x1080p; bitrate: 45Mbps; pixel format: yuv422p
Frame size: 1920x1080p; bitrate: 75Mbps; pixel format: yuv422p
Frame size: 1920x1080p; bitrate: 90Mbps; pixel format: yuv422p
Frame size: 1920x1080p; bitrate: 350Mbps; pixel format: yuv444p10, gbrp10
Frame size: 1920x1080p; bitrate: 390Mbps; pixel format: yuv444p10, gbrp10
Frame size: 1920x1080p; bitrate: 440Mbps; pixel format: yuv444p10, gbrp10
Frame size: 1920x1080p; bitrate: 730Mbps; pixel format: yuv444p10, gbrp10
Frame size: 1920x1080p; bitrate: 880Mbps; pixel format: yuv444p10, gbrp10
Frame size: 960x720p; bitrate: 42Mbps; pixel format: yuv422p
Frame size: 960x720p; bitrate: 60Mbps; pixel format: yuv422p
Frame size: 960x720p; bitrate: 75Mbps; pixel format: yuv422p
Frame size: 960x720p; bitrate: 115Mbps; pixel format: yuv422p
Frame size: 1440x1080p; bitrate: 63Mbps; pixel format: yuv422p
Frame size: 1440x1080p; bitrate: 84Mbps; pixel format: yuv422p
Frame size: 1440x1080p; bitrate: 100Mbps; pixel format: yuv422p
Frame size: 1440x1080p; bitrate: 110Mbps; pixel format: yuv422p
Frame size: 1440x1080i; bitrate: 80Mbps; pixel format: yuv422p
Frame size: 1440x1080i; bitrate: 90Mbps; pixel format: yuv422p
Frame size: 1440x1080i; bitrate: 100Mbps; pixel format: yuv422p
Frame size: 1440x1080i; bitrate: 110Mbps; pixel format: yuv422p
Valid DNxHR parameters
See pages 111-112 of Avid High-Resolution Workflows Guide.
Important Notes about Frame Rate
-
Frame rate is missing from the list that is generated from this command.
ffmpeg
will blindly accept any frame rate for this encoder, and Avid software will reportedly accept it (unconfirmed), but the DNxHD bitrate is supposed to be matched to specific frame rates only. For maximum compatibility I recommended only using the proper bitrate/frame rate combination. So use the command above to get the proper bitrates and pixel formats accepted byffmpeg
, and cross reference with the List of Avid DNxHD resolutions or the DNxHD White Paper (page 9) for the proper frame rates. -
The frame rates listed in the links above are using inaccurate rounded approximations. The proper values are listed below; the incorrect alias is to the left and the proper value is to the right.
Wrong Correct 29.97 30000/1001 59.94 60000/1001 23.967 24000/1001
So instead of
fps=29.97
usefps=30000/1001
, or instead of-r 29.97
use-r 30000/1001
.
More options
For additional encoder specific options, and a list of supported pixel formats, refer to:
ffmpeg -h encoder=dnxhd
Alpha / transparency
The FFmpeg DNxHD/DNxHR encoder does not support alpha.
Errors
ff_frame_thread_encoder_init failed
Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
Conversion failed!
This means that your frame rate, width, height, pixel format, and/or bitrate are incorrect. Refer to Valid DNxHD parameters above for accepted values.
pixel format is incompatible with DNxHD profile
Choose a proper pixel format using the format filter. See the DNxHD example above.
Related videos on Youtube
sharkant
i like White chocolate with almonds from ALDI, vangelis, hong kong Pop Music from the 80s and early 90s, star trek the classic series, blue led lights at night. I dislike social pressure, being not as intelligent and good looking as i wished to be, the headache and Tinnitus i suffer from 24/7. I am a White male from Germany, suffering from agoraphobia, bound to a Limit of locomotion within a radius of about 1 km , but it depends on specific environmental Features. i am a single, i have a few friends, but i am alone most of the time.
Updated on September 18, 2022Comments
-
sharkant almost 2 years
I am following a tutorial on how to work with cinelerra-cv, in the very beginning it was said, that the very first step in working with cinelerra, is to convert whatever video clip one has into the dnxhd format. It was just said, not explained how to do it.
After some research, I came across ffmpeg, but I have no idea how to use it with regard to dnxhd, with the little knowledge I gathered about ffmpeg, my guess how to do it would be:
ffmpeg -i <video-clip> -vcodec dnxhd <video-clip-in-dnxhd>
however, this does not work, and the examples I have seen on converting into dnxhd with ffmpeg I do not understand, they seemed each time having some different tags without explaining why to use them.
-
Admin about 7 yearsdeb-indus.org/tuto/ffmpeg-howto.htm#Encoding_VC-3 would suggest
ffmpeg -i <input_file> -vcodec dnxhd -b <bitrate> -an output.mov
-
Admin about 7 yearsthanks, I ve seen this one before and I was like: Do I have to specify a bitrate and does it have to have no sound (-an)? ....i mean can one only work in cinelerra with dnxhd videoclips which have no sound?
-
Admin about 7 years
-b <int> : Set video bitrate in bit/s ( default = 200k ).
so I would assume you must add a bitrate since 200k is not a valid option. But the-an
I would drop :) -
Admin about 7 yearsdoes the bitrate depend on the source file or the file into which one wants to convert? ....i mean if i just try using 200 could it work?
-
Admin about 7 yearsNo. You need to specify the bitrate for this particular encoder.
-
-
tatsu almost 4 yearsI don't understand. why does this work :
ffmpeg -i input.mkv -c:v dnxhd -vf "scale=1280:720,fps=60000/1001,format=yuv422p" -b:v 110M -c:a pcm_s16le output.mov
but this doesn't :ffmpeg -i input.mkv -c:v dnxhd -vf "scale=1920:1080,fps=60000/1001,format=yuv422p" -b:v 110M -c:a pcm_s16le output.mov
?? Not putting the scale argument doesn't work. not putting fps doesn't either. I have 1080p 60fps footage. I'm not interested in scaling it down or reducing the framerate I just want to shove it into davinci resolve's mouth so I can edit and upload to youtube and get on with my life. -
tatsu almost 4 yearsok so increasing the bitrate to 185M (
-b:v 185M
) did the trick. this might help people -
tatsu almost 4 yearsso a shorter version of the command is this :
ffmpeg -i input.mkv -c:v dnxhd -b:v 185M -c:a pcm_s16le output.mov
-
llogan almost 4 years@tatsu Good to see you figured it out. It's a picky format, so it will only accept certain combinations. The example in the answer is a "worse case scenario" just to show how to change the resolution, fps, pixel format, and bitrate. I should add some simpler examples.
-
Aaron Esau about 3 yearsFor some reason both of the example commands slightly desaturate and lower the contrast of my footage
-
Aaron Esau about 3 yearsExample: i.imgur.com/vO9ifHI.png where the original video is to the left, and the transcoded video is to the right
-
llogan about 3 years@AaronEsau Can you show your command and the complete log? You can use a pastebin site and provide the link in a comment.