Av1an
Av1an copied to clipboard
HDR encoding
How i can converting an hevc with HDR source file to a vp9 or av1 video without loss the HDR ? I have tried vpx, aoe and SVT-AV1, all with 4:2:0 10 bits settings. Do you have any solution ?
You need to specify HDR primaries and transfer characteristics like here:https://github.com/master-of-zen/Av1an/blob/master/docs/Encoders/aomenc.md#flags-used-for-most-native-10-bit-hdr-content
Thank, I'm going to try that. How I can do the same thing with vp9 ?
I used https://developers.google.com/media/vp9/hdr-encoding to get some idea of the settings. Note that you need to convert between ffmpeg and vpx cli parameters to work with av1an
I used https://developers.google.com/media/vp9/hdr-encoding to get some idea of the settings. Note that you need to convert between ffmpeg and vpx cli parameters to work with av1an
I can't find any way of translating this parameters into vpx parameters
I just add an example below in case this could be helpful to someone, because it was hard to discover the common HDR encoding parameters when I needed them too.
HDR parameters varies depending on the encoder used. The example below is done using SVT-AV1 encoder.
Example of HDR encode with SVT-AV1 + av1an :
av1an -i input.mkv -p 1 -w 2 -e svt-av1 -o encode.mkv -v " --rc 0 --crf 21 --preset 6 --film-grain 0 --input-depth 10 --lookahead 120 --keyint -2 --color-range 0 --color-primaries 9 --transfer-characteristics 16 --matrix-coefficients 9 -w 3840 -h 2024 --pass 0 --enable-hdr 1 --mastering-display G(0.265,0.68)B(0.15,0.05)R(0.68,0.31)WP(0.3117,0.328)L(1000.0,0.005) --content-light 895+,495" -m lsmash -l ERROR -r
Using SVT-AV1 encoder, here are the parameters related to the HDR metadata : --enable-hdr And here are the parameters to write metadata for HDR videos : --content-light AND --mastering-display
According to the SVT-AV1 documentation :
- --enable-hdr : Enable writing of HDR metadata in the bitstream if set to 1
- --content-light : Set content light level in the format of "max_cll,max_fall"
- --mastering-display : Mastering display metadata in the format of "G(x,y)B(x,y)R(x,y)WP(x,y)L(max,min)"
The exemple also contains typical transfer caracteristics and color primaries value when encoding most common HDR videos : -color-primaries 9 --transfer-characteristics 16 --matrix-coefficients 9
Caution : values of these special metadata parameters and caracteristics are specific to the video file you intend to encode, so the parameters showned above in the exemple cannot be copy-pasted for your encode, you need to find the specific values for this metadatas by inspecting the video file you intend to encode.
SVT-AV1 uses a different format for mastering display than other tools, so here is a little python script (found on reddit), that allows generating the mastering-display parameter values wth the SVT-AV1 syntax and also useful to extract content light values from the original video file like this :
python hdrinfo.py video.mkv
The python script : hdrinfo.zip (the script requires ffprobe to be installed on your environment)