To preserve HDR metadata, ensure the output matches the input's color primaries and transfer characteristics. In mpv player, press Shift + I to verify playback metadata (pix_fmt, color_primaries).
Using FFmpeg: Use -map_metadata 0 to copy existing HDR metadata.
Using Av1an: You must manually specify HDR values. First, check the chroma sample position using ffprobe. If unspecified, use topleft (the HDR10 standard).
# Check chroma sample position
ffprobe -show_streams -select_streams v:0 4k_HDR_input.m2ts
# Av1an example with HDR metadata
av1an -i input.mkv -e svt-av1 -v "--crf 22 --preset 3 --enable-qm 1 --qm-min 5 --chroma-qm-min 5 --keyint 320 --ac-bias 1.0 --tune 0 --chroma-sample-position topleft --color-primaries bt2020 --transfer-characteristics smpte2084 --matrix-coefficients bt2020-ncl --mastering-display G(0.170000,0.790000)B(0.131000,0.046000)R(0.708000,0.292000)WP(0.312700,0.329000)L(1000.000000,0.000100) --content-light 501,230" -w 6 -m lsmash -c ffmpeg -l log -a "-an" -o "4k HDR output.mkv"