My question is simple: how do I convert HDR vp9.2 videos downloaded from YouTube into HEVC (better if 10 bits) HDR videos?

Yesterday I tried this command, which is the only one I could find in Google:

ffmpeg  -i ../4K-HDR\ Videos/The\ World\ in\ HDR\ in\ 4K\ \(ULTRA\ HD\)-2160p\ 60fps.mkv -c:v libx265 -x265-params "colorprim=bt2020:transfer=smpte-st-2084:colormatrix=bt2020nc:master-display=G(13250,34500)B(7500,3000)R(34000,16000)WP(15635,16450)L(10000000,10):max-cll=0,0"  output.mkv

It does convert to HEVC (not sure about the 10 bits) but I loose the HDR. Also it's probably overcomplicated for nothing. Any simple ffmpeg params that convert from HDR to HDR? Thanks.


I have got the answer from user priivt8 in this post in macrumors. First one needs a late version ffmpeg that supports high bit-depth HEVC encoding, like v3.4.1 here.

Then this is the command:

ffmpeg -i <infile> \
-c:a copy \
-c:v libx265 \
-tag:v hvc1 \
-crf 22 \
-pix_fmt yuv420p10le \
-x265-params "colorprim=bt2020:transfer=smpte2084:colormatrix=bt2020nc" \


"-i <infile>" <infile> must be replace with the full file name of the video in input
"\-c:a copy" copies the audio
"-c:v libx265" tells ffmpeg to convert to HEVC
"-tag:v hvc1" seems mandatory for Apple devices using quickTime and the like
"-crf 22" is the compression. Lower the value, better the picture and higher the size
"-pix_fmt yuv420p10le" for YCrCB 4:2:0 10-bits HDR
"-x265-params" are the HEVC parameters for color range etc
"<outfile>.mkv" is the file in output. Replace <outfile> with the name you like. The extensions (.mkv) tells ffmpeg to which container convert the video.

I converted it to a mkv file, so there won't be issues adding any audio from the original YouTube video. one may use ".m4v" for videos recognised by Apple devices.

The converted video now plays fine, with HDR BT.2020 in both Apple TV 4K (using Infuse Pro) and Sony's Video in my Bravia with Android TV 7.0.

One may add to ffmpeg the option

-r 30

To reduce the frame rate from 60fps to 30fps (so it can be played by iTunes in the Apple TV 4K).

  • 1
    Notice that FFmpeg doesn't do a good gob with fractions, so for 29.97fps you should use 3000/1001, for 23.976 use 24000/1001, and for 59.94, 60000/1001. – Rodrigo Polo Jan 30 '18 at 11:26

Here's my "foolproof" version:

ffmpeg -i source.webm -c:v libx265 -x265-params "level=5.2:colorprim=bt2020:colormatrix=bt2020nc:transfer=smpte2084" -crf 12 -preset medium -c:a copy output.mkv

It works on all YouTube HDR videos (downloaded using youtube-dl -f 337+bestaudio).

This (-crf 12) will give you around 18000-28000k video bitrate for a 4K video. I usually use -preset ultrafast when in a hurry, though. :)

I don't need to set -pix_fmt yuv420p10le, etc. because this will inherit the settings from the VP9 source file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.