Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > VapourSynth

Reply
 
Thread Tools Search this Thread Display Modes
Old 14th March 2018, 01:15   #1  |  Link
Selur
Registered User
 
Selur's Avatar
 
Join Date: Oct 2001
Location: Germany
Posts: 7,259
ToneMap -> color artifacts

when using:
Code:
# Imports
import vapoursynth as vs
core = vs.get_core()
# Loading Plugins
core.std.LoadPlugin(path="G:/Hybrid/64bit/vsfilters/Support/fmtconv.dll")
core.std.LoadPlugin(path="G:/Hybrid/64bit/vsfilters/ColorFilter/ToneMap/tonemap.dll")
core.std.LoadPlugin(path="G:/Hybrid/64bit/vsfilters/SourceFilter/LSmashSource/vslsmashsource.dll")
# Loading C:\Users\Selur\Desktop\Sample2.mkv using LWLibavSource
clip = core.lsmas.LWLibavSource(source="C:/Users/Selur/Desktop/Sample2.mkv", format="YUV420P10", cache=0)
# making sure input color matrix is set as 2020ncl
clip = core.resize.Point(clip, matrix_in_s="2020ncl")
# making sure frame rate is set to 24000/1001
clip = core.std.AssumeFPS(clip, fpsnum=24000, fpsden=1001)
# Making sure input color range is set to TV (limited) range.
clip = core.std.SetFrameProp(clip=clip, prop="_ColorRange", intval=1)
# adjustmentint bit depth for ToneMap
clip =  core.fmtc.bitdepth(clip, bits=32)
# color adjustment using ToneMap
clip = core.tonemap.Hable(clip=clip)
clip = core.resize.Bilinear(clip=clip, format=vs.YUV420P8, matrix_s="709", matrix_in_s="2020ncl", range_in_s="full",range_s="limited")
# resizing clip to 1920x1080
clip = core.fmtc.resample(clip=clip, kernel="spline16", w=1920, h=1080, interlaced=False, interlacedd=False)
# adjusting output color from: YUV420P16 to YUV420P8 for x264Model (i420)
clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P8)
# Output
clip.set_output()
I get color artifacts, especially visible at frame 190+
short sample of the source: Sample2.mkv.
(using FFMS2 doesn't help, using the HDR to SDR script from https://forum.doom9.org/showthread.php?p=1800675 doesn't produce these artifacts, but since tonemap is quite a bit faster I would prefer using tonemap)

-> Is this a bug in ToneMap or is there something wrong with the source?
Problem also seems to only occur when using 'Hable', 'Mobius' and 'Reinhard' don't seem to have the problem.

Using tonemap from ffmpeg directly without Vapoursynth doesn't cause the problem.
Code:
ffmpeg -y -loglevel fatal -threads 8 -i "C:\Users\Selur\Desktop\Sample2.mkv" -map 0:0 -an -sn  -vf zscale=tin=smpte2084:min=bt2020nc:pin=bt2020:rin=limited:t=smpte2084:m=bt2020nc:p=bt2020:r=tv,zscale=t=linear:npl=100,format=gbrpf32le,zscale=p=bt709,tonemap=tonemap=clip:desat=2.000:peak=0.000,zscale=t=bt709:m=bt709:r=tv,scale=1920:1080 -vsync 0 -pix_fmt yuv420p  -sws_flags spline -f rawvideo -
so this might be a but in the toneMap Vapoursynth port.
-> added an issue to the bug tracker (https://github.com/ifb/vapoursynth-tonemap/issues/3)
Didn't notice that I didn't use hable with ffmpeg -> using hable as method with ffmpeg the problem doesn't appear.

Cu Selur
__________________
Hybrid here in the forum, homepage

Last edited by Selur; 14th March 2018 at 10:03. Reason: added 'ffmpeg direct' results + problem only with Hable
Selur is offline   Reply With Quote
Old 16th March 2018, 15:20   #2  |  Link
videoh
Useful n00b
 
Join Date: Jul 2014
Posts: 1,667
Another issue: The Reinhard filter provides a parameter "exposure" but the algorithm does not use it!

Maybe your issue isn't Hable. I don't see any artifacts with this:

Code:
import vapoursynth as vs
core = vs.get_core()

core.std.LoadPlugin(path='D:/Don/Programming/C++/Vapoursynth filters/Tonemap/x64/Release/tonemap.dll')
core.avs.LoadPlugin(path="D:/Don/Programming/C++/DGDecNV/DGDecodeNV/x64/Release/DGDecodeNV.dll")
video = core.avs.DGSource('D:\Don\Programming\C++\Vapoursynth filters\Tonemap\Test\Sample2.dgi',fulldepth=True)

video=core.resize.Bicubic(clip=video, format=vs.RGBS, range_in_s="limited", matrix_in_s="2020ncl",\
primaries_in_s="2020", primaries_s="2020", transfer_in_s="st2084", transfer_s="linear",dither_type="none", nominal_luminance=1000)

video=core.tonemap.Hable(video)

video=core.resize.Bicubic(clip=video, format=vs.YUV420P8,matrix_s="709", primaries_in_s="2020",\
primaries_s="709", transfer_in_s="linear", transfer_s="709",dither_type="ordered")

video.set_output()
I like Reinhard better anyway.

Last edited by videoh; 16th March 2018 at 20:17.
videoh is offline   Reply With Quote
Old 16th March 2018, 15:35   #3  |  Link
Selur
Registered User
 
Selur's Avatar
 
Join Date: Oct 2001
Location: Germany
Posts: 7,259
@videoh: I'll try whether converting to RGBS beforehand helps.
__________________
Hybrid here in the forum, homepage
Selur is offline   Reply With Quote
Old 16th March 2018, 15:49   #4  |  Link
Selur
Registered User
 
Selur's Avatar
 
Join Date: Oct 2001
Location: Germany
Posts: 7,259
You are right converting to RGBS beforehand does seem to fix the issue.
__________________
Hybrid here in the forum, homepage
Selur is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 23:47.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.