View Single Post
Old 4th December 2018, 02:12   #6  |  Link
FranceBB
Broadcast Encoder
 
FranceBB's Avatar
 
Join Date: Nov 2013
Location: Royal Borough of Kensington & Chelsea, UK
Posts: 2,883
Quote:
Originally Posted by zorr View Post
So you have an example video of what your conversion should look like? Sounds like you could use AvisynthOptimizer to find the optimal parameters for the HDRTools script.
I took a look at Avisynth Optimizer, but I can't manage to get it working.
I made the following script:

Code:
FFVideoSource("Official_SDR.mxf")

ConverttoYUY2()

tdeint(mode=2, order=-1, field=-1, mthreshL=6, mthreshC=6, map=0, type=2, debug=false, mtnmode=1, sharp=true, cthresh=6, blockx=16, blocky=16, chroma=true, MI=64, tryWeave=true, link=1, denoise=true, slow=2, opt=4)

Converttoyv16()

source=trim(0, 4958)

FFVideoSource("Official_HDR_PQ.mxf")

ConvertBits(16)

Spline64ResizeMT(1920, 1080)

ConvertYUVtoXYZ(Color=0, OutputMode=1, HDRMode=0, fullrange=false)

ConvertXYZ_Scale_HDRtoSDR(Coeff_X=33.3, Coeff_Y=34.2, Coeff_Z=33.3)

ConvertXYZtoYUV(pColor=0)

Converttoyuv422()

ConvertBits(bits=8, dither=1)

tonemapped=trim(0, 4958)


global total = 0.0
global ssim_total = 0.0
FrameEvaluate(last, """
	global ssim = SSIM_FRAME(source, tonemapped)
	global ssim = (ssim == 1.0 ? 0.0 : ssim)
	global ssim_total = ssim_total + ssim	
""")	

# measure runtime, plugin writes the value to global avstimer variable
global avstimer = 0.0
AvsTimer(frames=1, type=0, total=false, name="Optimizer")

# per frame logging (ssim, time)
delimiter = "; "
resultFile = "perFrameResults.txt"	# output out1="ssim: MAX(float)" out2="time: MIN(time) ms" file="perFrameResults.txt"
WriteFile(resultFile, "current_frame", "delimiter", "ssim", "delimiter", "avstimer")

# write "stop" at the last frame to tell the optimizer that the script has finished
frame_count = FrameCount()
WriteFileIf(resultFile, "current_frame == frame_count-1", """ "stop " """, "ssim_total", append=true)

return last
I successfully got the following logs for the first 4958 frames: https://pastebin.com/wELMQiTY

Then I tried to set a very large range of values to let the optimiser work:

Code:
FFVideoSource("Official_SDR.mxf")

ConverttoYUY2()

tdeint(mode=2, order=-1, field=-1, mthreshL=6, mthreshC=6, map=0, type=2, debug=false, mtnmode=1, sharp=true, cthresh=6, blockx=16, blocky=16, chroma=true, MI=64, tryWeave=true, link=1, denoise=true, slow=2, opt=4)

Converttoyv16()

source=trim(0, 4958)

FFVideoSource("Official_HDR_PQ.mxf")

ConvertBits(16)

Spline64ResizeMT(1920, 1080)

ConvertYUVtoXYZ(Color=0, OutputMode=1, HDRMode=0, fullrange=false)

Coeff_X = 33.3 # optimize Coeff_X = _n_ | 0.1..1000.1 | Coeff_X
Coeff_Y = 34.2 # optimize Coeff_Y = _n_ | 0.1..1000.1 | Coeff_Y
Coeff_Z = 33.3 # optimize Coeff_Z = _n_ | 0.1..1000.1 | Coeff_Z

ConvertXYZ_Scale_HDRtoSDR(Coeff_X=Coeff_X, Coeff_Y=Coeff_Y, Coeff_Z=Coeff_Z)

ConvertXYZtoYUV(pColor=0)

Converttoyuv422()

ConvertBits(bits=8, dither=1)

tonemapped=trim(0, 4958)


global total = 0.0
global ssim_total = 0.0
FrameEvaluate(last, """
	global ssim = SSIM_FRAME(source, tonemapped)
	global ssim = (ssim == 1.0 ? 0.0 : ssim)
	global ssim_total = ssim_total + ssim	
""")	

# measure runtime, plugin writes the value to global avstimer variable
global avstimer = 0.0
AvsTimer(frames=1, type=0, total=false, name="Optimizer")

# per frame logging (ssim, time)
delimiter = "; "
resultFile = "perFrameResults.txt"	# output out1="ssim: MAX(float)" out2="time: MIN(time) ms" file="perFrameResults.txt"
WriteFile(resultFile, "current_frame", "delimiter", "ssim", "delimiter", "avstimer")

# write "stop" at the last frame to tell the optimizer that the script has finished
frame_count = FrameCount()
WriteFileIf(resultFile, "current_frame == frame_count-1", """ "stop " """, "ssim_total", append=true)

return last
After that, I tried to make the optimiser start by creating a .bat with the following command line:

Code:
optimizer "I:\LUT\test.avs"

pause
However, it starts and crashes soon after.
It also ignores the "pause" command, so I can't see what error it gives.
Last but not least, the work directory is created, but it's empty.
(For the records, I do have Java 6, 7 and 8 installed).

This is what I get before it crashes:



These are the Java redistributables I have installed:



Out of records, I just opened the latest version of JDownloader2 on this machine and it works fine, so it's not Java.

EDIT: Oh, sorry, I got it, it wants integers, my bad, now it works:

Code:
FFVideoSource("Official_SDR.mxf")

ConverttoYUY2()

tdeint(mode=2, order=-1, field=-1, mthreshL=6, mthreshC=6, map=0, type=2, debug=false, mtnmode=1, sharp=true, cthresh=6, blockx=16, blocky=16, chroma=true, MI=64, tryWeave=true, link=1, denoise=true, slow=2, opt=4)

Converttoyv16()

source=trim(0, 4958)

FFVideoSource("Official_HDR_PQ.mxf")

ConvertBits(16)

Spline64ResizeMT(1920, 1080)

ConvertYUVtoXYZ(Color=0, OutputMode=1, HDRMode=0, fullrange=false)

Coeff_X = 33.3 # optimize Coeff_X = _n_ | 1..1000 | Coeff_X
Coeff_Y = 34.2 # optimize Coeff_Y = _n_ | 1..1000 | Coeff_Y
Coeff_Z = 33.3 # optimize Coeff_Z = _n_ | 1..1000 | Coeff_Z

ConvertXYZ_Scale_HDRtoSDR(Coeff_X=Coeff_X, Coeff_Y=Coeff_Y, Coeff_Z=Coeff_Z)

ConvertXYZtoYUV(pColor=0)

Converttoyuv422()

ConvertBits(bits=8, dither=1)

tonemapped=trim(0, 4958)


global total = 0.0
global ssim_total = 0.0
FrameEvaluate(last, """
	global ssim = SSIM_FRAME(source, tonemapped)
	global ssim = (ssim == 1.0 ? 0.0 : ssim)
	global ssim_total = ssim_total + ssim	
""")	

# measure runtime, plugin writes the value to global avstimer variable
global avstimer = 0.0
AvsTimer(frames=1, type=0, total=false, name="Optimizer")

# per frame logging (ssim, time)
delimiter = "; "
resultFile = "perFrameResults.txt"	# output out1="ssim: MAX(float)" out2="time: MIN(time) ms" file="perFrameResults.txt"
WriteFile(resultFile, "current_frame", "delimiter", "ssim", "delimiter", "avstimer")

# write "stop" at the last frame to tell the optimizer that the script has finished
frame_count = FrameCount()
WriteFileIf(resultFile, "current_frame == frame_count-1", """ "stop " """, "ssim_total", append=true)

return last


Quote:
Have you tried also DGHDRtoSDR ?
You can get it here. Don't forget to read the manual...
The author worked a lot on it, and it produces very good results, and from what i've understood, he's done more than simple tonemap algorithm in his filter (mines are simple tonemap).
I'm letting Avisynth Optimizer run with "Scale" as a basic option.
I'm gonna make it run with Reinhard from HDRTools after the first test and then I'll make it run with DGHDRtoSDR.
I downloaded it and I read the documentation; it seems something I can play a lot with. ^_^

Last edited by FranceBB; 4th December 2018 at 02:50.
FranceBB is offline   Reply With Quote