HDR bt.2020 to SDR bt.709 conversion
Hello, I have trouble converting a 4K HDR video into a HD SDR one. Basically it plays much too dark and reddish in VLC (on macOS). The ffprobe output is this video is at the bottom of the post I first tried applying a curve filter to boost the dark tones. I works not too bad, but the reddish shift is still, if not amplified. Then I browsed the web and found a filter set that looks popular (I mean copied/pasted on many different pages): -vf zscale=t=linear:npl=100,format=gbrpf32le,zscale=p=bt709, \ tonemap=tonemap=hable,zscale=t=bt709:m=bt709:r=tvformat=yuv420p But, well, it doesn't solve anything... Using "gamma" instead of "hable" gives a higher luminosity, but there's still a strong red shift. I tried many different things with the zscale filter, but the problem is that I don't fully understand the effect of the different parameters, although I'm not completly unfamiliar with the color profiles. It seems to me that all of this deals mainly the luminosity, and little with the chrominance. I have also found a page that describes how to convert from the bt.2020 to bt709 profile, with a link to download a LUT file. https://www.binarytides.com/color-grading-hlg-videos-with-ffmpeg/ https://nopixels.net/articles/hlg-to-rec709/ So I tried the filter lut3d=nopixels_net_hlg2020_to_rec709.cube, with various combinations of the zscale filter, but could not obtain anything correct at the end. I always have reddish, or very reddish, or pinkish, color shifts... I'm a bit lost, now... Any help appreciated ! =============================================================== *****$ ffprobe in0.mkv ffprobe version 4.4.4 Copyright (c) 2007-2023 the FFmpeg developers built with Apple LLVM version 9.1.0 (clang-902.0.39.2) configuration: --prefix=/opt/local --cc=/usr/bin/clang --mandir=/opt/local/share/man --enable-audiotoolbox --disable-indev=jack --disable-libjack --disable-libopencore-amrnb --disable-libopencore-amrwb --disable-libxcb --disable-libxcb-shm --disable-libxcb-xfixes --enable-opencl --disable-outdev=xv --enable-sdl2 --disable-securetransport --enable-videotoolbox --enable-avfilter --enable-avresample --enable-fontconfig --enable-gnutls --enable-libass --enable-libbluray --enable-libdav1d --enable-libfreetype --enable-libfribidi --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-librsvg --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libzimg --enable-libzvbi --enable-lzma --enable-pthreads --enable-shared --enable-swscale --enable-zlib --enable-libaom --enable-libsvtav1 --arch=x86_64 --enable-x86asm --enable-gpl --enable-libvidstab --enable-libx264 --enable-libx265 --enable-libxvid --enable-postproc libavutil 56. 70.100 / 56. 70.100 libavcodec 58.134.100 / 58.134.100 libavformat 58. 76.100 / 58. 76.100 libavdevice 58. 13.100 / 58. 13.100 libavfilter 7.110.100 / 7.110.100 libavresample 4. 0. 0 / 4. 0. 0 libswscale 5. 9.100 / 5. 9.100 libswresample 3. 9.100 / 3. 9.100 libpostproc 55. 9.100 / 55. 9.100 Input #0, matroska,webm, from 'in0.mkv': Metadata: encoder : libebml v1.4.0 + libmatroska v1.6.2 creation_time : 2021-03-09T20:53:48.000000Z Writing frontend: StaxRip v1.7.0.3 Duration: 00:49:10.18, start: 0.000000, bitrate: 4963 kb/s Chapters: [...] Stream #0:0: Video: hevc (Main 10), yuv420p10le(tv, bt2020nc/bt2020/smpte2084), 3840x2160, SAR 1:1 DAR 16:9, 23.98 fps, 23.98 tbr, 1k tbn, 23.98 tbc (default) Metadata: BPS-eng : 4003363 DURATION-eng : 00:49:09.197000000 NUMBER_OF_FRAMES-eng: 70710 NUMBER_OF_BYTES-eng: 1475838552 _STATISTICS_WRITING_APP-eng: mkvmerge v50.0.0 ('Awakenings') 64-bit _STATISTICS_WRITING_DATE_UTC-eng: 2021-03-09 20:53:48 _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES [...]
On Sun, 22 Oct 2023 at 00:39, pehache <pehache.7@gmail.com> wrote:
Hello,
I have trouble converting a 4K HDR video into a HD SDR one. Basically it plays much too dark and reddish in VLC (on macOS). The ffprobe output is this video is at the bottom of the post
I first tried applying a curve filter to boost the dark tones. I works not too bad, but the reddish shift is still, if not amplified.
Then I browsed the web and found a filter set that looks popular (I mean copied/pasted on many different pages):
-vf zscale=t=linear:npl=100,format=gbrpf32le,zscale=p=bt709, \ tonemap=tonemap=hable,zscale=t=bt709:m=bt709:r=tvformat=yuv420p
But, well, it doesn't solve anything... Using "gamma" instead of "hable" gives a higher luminosity, but there's still a strong red shift.
I tried many different things with the zscale filter, but the problem is that I don't fully understand the effect of the different parameters, although I'm not completly unfamiliar with the color profiles. It seems to me that all of this deals mainly the luminosity, and little with the chrominance.
I have also found a page that describes how to convert from the bt.2020 to bt709 profile, with a link to download a LUT file. https://www.binarytides.com/color-grading-hlg-videos-with-ffmpeg/ https://nopixels.net/articles/hlg-to-rec709/
So I tried the filter lut3d=nopixels_net_hlg2020_to_rec709.cube, with various combinations of the zscale filter, but could not obtain anything correct at the end. I always have reddish, or very reddish, or pinkish, color shifts...
I'm a bit lost, now... Any help appreciated !
=============================================================== *****$ ffprobe in0.mkv ffprobe version 4.4.4 Copyright (c) 2007-2023 the FFmpeg developers built with Apple LLVM version 9.1.0 (clang-902.0.39.2) configuration: --prefix=/opt/local --cc=/usr/bin/clang --mandir=/opt/local/share/man --enable-audiotoolbox --disable-indev=jack --disable-libjack --disable-libopencore-amrnb --disable-libopencore-amrwb --disable-libxcb --disable-libxcb-shm --disable-libxcb-xfixes --enable-opencl --disable-outdev=xv --enable-sdl2 --disable-securetransport --enable-videotoolbox --enable-avfilter --enable-avresample --enable-fontconfig --enable-gnutls --enable-libass --enable-libbluray --enable-libdav1d --enable-libfreetype --enable-libfribidi --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-librsvg --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libzimg --enable-libzvbi --enable-lzma --enable-pthreads --enable-shared --enable-swscale --enable-zlib --enable-libaom --enable-libsvtav1 --arch=x86_64 --enable-x86asm --enable-gpl --enable-libvidstab --enable-libx264 --enable-libx265 --enable-libxvid --enable-postproc libavutil 56. 70.100 / 56. 70.100 libavcodec 58.134.100 / 58.134.100 libavformat 58. 76.100 / 58. 76.100 libavdevice 58. 13.100 / 58. 13.100 libavfilter 7.110.100 / 7.110.100 libavresample 4. 0. 0 / 4. 0. 0 libswscale 5. 9.100 / 5. 9.100 libswresample 3. 9.100 / 3. 9.100 libpostproc 55. 9.100 / 55. 9.100 Input #0, matroska,webm, from 'in0.mkv': Metadata: encoder : libebml v1.4.0 + libmatroska v1.6.2 creation_time : 2021-03-09T20:53:48.000000Z Writing frontend: StaxRip v1.7.0.3 Duration: 00:49:10.18, start: 0.000000, bitrate: 4963 kb/s Chapters: [...] Stream #0:0: Video: hevc (Main 10), yuv420p10le(tv, bt2020nc/bt2020/smpte2084), 3840x2160, SAR 1:1 DAR 16:9, 23.98 fps, 23.98 tbr, 1k tbn, 23.98 tbc (default) Metadata: BPS-eng : 4003363 DURATION-eng : 00:49:09.197000000 NUMBER_OF_FRAMES-eng: 70710 NUMBER_OF_BYTES-eng: 1475838552 _STATISTICS_WRITING_APP-eng: mkvmerge v50.0.0 ('Awakenings') 64-bit _STATISTICS_WRITING_DATE_UTC-eng: 2021-03-09 20:53:48 _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES [...]
Please provide a sample of the input file and uncut output of the ffmpeg command line in use.
Le 22/10/2023 à 01:20, Dennis Mungai a écrit :
Please provide a sample of the input file and uncut output of the ffmpeg command line in use.
Here is a 60 sec. piece of the input video, extracted with ffmpeg -ss 75 -i in0.mkv -map 0:0 -c copy in1.mkv http://pehache.free.fr/TEMP/in1.mkv Here is what it looks like in VLC (this is a macOS screenshot, not from the VLC capture tool): http://pehache.free.fr/TEMP/vlc.png And what it should look like (natural colors and much more detailed shadows): http://pehache.free.fr/TEMP/web.png My main problem is the color shift. Playing with the luminosity is not that difficult (even simply with the curve filter if needed). About the ffmpeg text output, I've just cut the irrelevant parts (information about audio and subtitle tracks, and about chapters)
On Sun, 22 Oct 2023, 13:02 pehache, <pehache.7@gmail.com> wrote:
Le 22/10/2023 à 01:20, Dennis Mungai a écrit :
Please provide a sample of the input file and uncut output of the ffmpeg command line in use.
Here is a 60 sec. piece of the input video, extracted with ffmpeg -ss 75 -i in0.mkv -map 0:0 -c copy in1.mkv
http://pehache.free.fr/TEMP/in1.mkv
Here is what it looks like in VLC (this is a macOS screenshot, not from the VLC capture tool): http://pehache.free.fr/TEMP/vlc.png
And what it should look like (natural colors and much more detailed shadows): http://pehache.free.fr/TEMP/web.png
My main problem is the color shift. Playing with the luminosity is not that difficult (even simply with the curve filter if needed).
About the ffmpeg text output, I've just cut the irrelevant parts (information about audio and subtitle tracks, and about chapters)
Looking into it.
participants (2)
-
Dennis Mungai -
pehache