Hello, and thanks in advance for any help.
I was gifted a UHD Blu-ray but don't have a 4K TV, so I figured I'd do the color conversion and resizing losslessly with VirtualDub2-UtVideo then shrivel that as I normally would with MeGUI-AviSynth. Unfortunately, after several days and many hours, I can't for the life of me figure out how to tonemap BT.2020 to BT.709. I've tried everything from the seemingly obvious
to HDRTools plugin andCode:ColorMatrix(Mode="Rec.2020->Rec.709")
with no noticeable change in the video's colors. Please, can anyone offer a solution (or a link to a tutorial)?Code:ConvertYUVtoXYZ(Color=1) ConvertXYZtoYUV(pColor=1)
Ahhh, here's a test clip.
+ Reply to Thread
Results 1 to 18 of 18
Last edited by LouieChuckyMerry; 4th Jun 2023 at 16:31. Reason: Link To Test Clip
Search the forum for "tonemap" lots of discussion.
It was mentioned that Handbrake\Vidcoder seemed to do it if you select bt.709 in Filters\Colorspace
Here's an Avisynth example:
lwlibavvideosource("C:\Users\Public\Videos\Mamma Mia_sample2_HEVC_HDR_re-encode.mp4") ConvertBits(10) # Use 12 for 12-bit z_ConvertFormat(pixel_type="RGBPS",colorspace_op="2020ncl:st2084:2020:l=>rgb:linear:2020:l", dither_type="none") # Choose one of these: DGReinhard() #DGHable() z_ConvertFormat(pixel_type="YV12",colorspace_op="rgb:linear:2020:l=>709:709:709:l",dither_type="ordered")
Thanks for your reply, davexnet. Honest, I searched for many hours, and on more than this forum. I've looked into HandBrake but am running Win 7, so the latest version is rather old (plus, the only "lossless" options are either x264 or x265 with a CRF of 0 which, after more searching, makes me wonder if it's actually lossless). I'd prefer VirtualDub2/UtVideo for the first pass, and appreciate your above script, but it seems the syntax is off because, even after trying to correct it, I receive error messages that I'm unable to overcome. Unfortunately I'm Extremely CLI Challenged, so ffmeg is too daunting (I'll search for a GUI, though). Anyway, if I find a solution that seems acceptable I'll post it here so that others searching for a solution can find one (hence, the title of my post which, to be fair, is probably technically incorrect ).
Trying to change title of post... "Preview Changes" shows the new title... Sigh...
Last edited by LouieChuckyMerry; 5th Jun 2023 at 20:19. Reason: Still Trying...
The syntax is fine, you may have some external filters missing, eg. DGTonemap and possibly L-Smash Works (for LWLibavvideosource)
older releases of Lsmash here:
Last edited by davexnet; 5th Jun 2023 at 22:42.
Thanks again for your help, davexnet. I already index with L-Smash Works and have DGTonemap in my Plugins folder; however, when I attempt to run your script in VirtualDub2 I receive the error message "There is no function named 'z_ConvertFormat'."
Edit: Maybe I need to manually load DGTonemap? I'll try...
EditEdit: Nope, same error message. Here's my script (using AviSynth+):
LoadPlugin("FilePath\LSMASHSource.dll") LoadPlugin("FilePath\DGTonemap.dll") LWLibavVideoSource("FilePath.mkv", format="YUV420P8") SetFilterMTMode("Default_MT_Mode",2) ConvertBits(10) # Use 12 for 12-bit z_ConvertFormat(pixel_type="RGBPS",colorspace_op="2020ncl:st2084:2020:l=>rgb:linear:2020:l", dither_type="none") # Choose one of these: DGReinhard() #DGHable() z_ConvertFormat(pixel_type="YV12",colorspace_op="rgb:linear:2020:l=>709:709:709:l",dither_type="ordered") PreFetch(5)
Last edited by LouieChuckyMerry; 6th Jun 2023 at 20:49. Reason: A Thought; And, More Information
davexnet: Thank you, I'll try to carve out some time tonight to add AVSResize to my Plugins folder (I need to wait for an encode to finish).
ProWo: Wow, excellent timing (and thanks for your reply). I went hunting for an FFMpeg GUI yesterday and settled on clever FFMpeg-GUI for my first to try (thanks for your GUI, too; I especially appreciated the set up guide upon first opening), so thank you also for the above picture. After color conversion and resizing I plan to encode the result with my usual AviSynth script using MeGUI (denoising, sharpening, debanding, etc.), so I'd like to do the first bit losslessly. I'd normally use VirtualDub2/UtVideo; do you have a recommendation for a lossless codec in clever FFMPeg-GUI?
Last edited by LouieChuckyMerry; 7th Jun 2023 at 13:31. Reason: Information; Information
Use x264 crf 0
Last edited by ProWo; 10th Jun 2023 at 16:07. Reason: typo
ProWo: Thanks a bunch for your help; I really appreciate it .
ProWo: What an awesome GUI . And the choice of color is a very nice touch. Thanks again .
That did it, thank you very much.
Having some time this weekend I ran some tests on a short clip to compare six different methods of tonemapping:
1) AviSynth[davexnet's Above Script + Downscaling]
2) clever FFMpeg-GUI[Reinhard + Downscaling]
3) clever FFMpeg-GUI[Hable + Downscaling]
4) HandBrake[Colorspace BT.709 + Downscaling]
5) Avidemux[Reinhard + Downscaling]
6) Avidemux[Hable + Downscaling]
I didn't note speed because not every method displays that information and I did no fine-tuning of the settings because not every method allowed for that. Here are the results (in the above order):
[Attachment 71652 - Click to enlarge]
[Attachment 71653 - Click to enlarge]
[Attachment 71654 - Click to enlarge]
[Attachment 71655 - Click to enlarge]
[Attachment 71656 - Click to enlarge]
[Attachment 71657 - Click to enlarge]
[Attachment 71658 - Click to enlarge]
[Attachment 71659 - Click to enlarge]
[Attachment 71660 - Click to enlarge]
[Attachment 71661 - Click to enlarge]
[Attachment 71662 - Click to enlarge]
[Attachment 71663 - Click to enlarge]
To my eyes the results with HandBrake are the worst, but to be fair I'm running Win 7 and the last version of HandBrake I can use, 1.4.2, is verrrrrry old. I also think the davexnet's AviSynth script is not so good but, again to be fair, I don't know enough to make the necessary adjustments (although I'm sure davexnet does ). Clever FFMpeg-GUI with Hable is a bit dark, but it's results with Reinhard look good. Avidemux's two results are quite similar but I find the Hable a bit too bright. So, down to clever FFMpeg-GUI with Reinhard and Avidemux with Reinhard I'd pick clever FFMpeg-GUI for the indoor scene, given it's light from candles and through stained glass, but Avidemux for the outdoor scene. Both clever FFMpeg and Avidemux's settings are tweakable so I'd do some more testing until happy (or I could beg ProWo for some advice ).
EDIT: I just noticed that I failed to downscale a couple of the test clips but it seems to me that that shouldn't affect the colors (but, hey, I've been wrong many times before).
Last edited by LouieChuckyMerry; 11th Jun 2023 at 16:19. Reason: Grammar; Syntax; Resolution