erazortt / DoViBaker

Bake the DoVi into your clip
GNU General Public License v3.0
41 stars 7 forks source link

No output from dovibaker? #26

Closed Mahaaveer closed 6 months ago

Mahaaveer commented 7 months ago

Trying to move to avisynth for the dovibaker.

I extracted BL and EL using dovi_tool. BL is 3840 X 2160 and EL is 1920 X 1080 When i try encoding using following script:

LoadPlugin("C:\encoding\MeGUI-2944-64\tools\lsmash\LSMASHSource.dll")
LoadPlugin("C:\encoding\DoViBaker_v0.2.0\DoViBaker_x64.dll")

bl = LWLibavVideoSource("BL.hevc", format="YUV420P10", repeat=true)
el = LWLibavVideoSource("EL.hevc", format="YUV420P10", repeat=true)

resized = Spline36Resize(bl,1920,1080)

baked = DoViBaker(resized,el)
ConvertToYUV420(baked,matrix="Rec2020")
ConvertBits(10)
AssumeFPS(24000,1001)
PreFetch(4)

I get "Could not read avs frame" in MeGUI and when i start the encode, x265 encoder crashed. Same thing happened in terminal when i used the avs script directly without MeGUI. If i comment out the dovibaker line, encoding works fine with spline36 resize.

Help appreciated in getting me started with dovibaker.

erazortt commented 7 months ago

Your exact code works for me. A couple of comments though:

So your script should look somthing like that:

SetFilterMTMode("DEFAULT_MT_MODE", MT_MULTI_INSTANCE)
LoadPlugin("...\LSMASHSource.dll")
LoadPlugin("...\DoViBaker_x64.dll")

bl=LWLibavVideoSource("bl.ts", format="YUV420P10", repeat=true)
el=LWLibavVideoSource("el.ts", format="YUV420P10", repeat=true)

resized=bl.z_ConvertFormat(chromaloc_op="top_left=>top_left",width=bl.Width()/2,height=bl.Height()/2,resample_filter="spline36",resample_filter_uv="spline36",dither_type="none")

baked = DoViBaker(resized,el)

baked.z_ConvertFormat(chromaloc_op="center=>top_left",pixel_type="YUV420P16",colorspace_op="rgb:st2084:2020:full=>2020ncl:st2084:2020:limited",dither_type="none",resample_filter="spline36",resample_filter_uv="spline36")
PreFetch(4)
Mahaaveer commented 7 months ago

Thanks for the quick reply. The encoding works with the above script. However, the video freezes for around 40 seconds before playing smoothly. It is basically a few static frames for 40 seconds. encoding bitrate was too low initially , which confirms static frames. before transitioning from static frame to normal frames, i noticed a glitch frame with weird colors (dovi like green and pink). Is it because of BL and EL frame misalignment ? Both has equal number of frames as i checked with ffprobe.

UPDATE : Got it working. Must be a faulty extraction.

Mahaaveer commented 7 months ago

Dealing with some odd crop values on EL like 139 so that final output be 1920 X 802. so far i came up with a script to crop odd numbers in RGB24 space but don't know how to convert it back to YUVP10 which dovibaker accepts. Also worried that YUV <-> RGB conversions will result in loss of quality. is this a prudent thing to do ?

SetFilterMTMode("DEFAULT_MT_MODE", MT_MULTI_INSTANCE)

LoadPlugin("C:\encoding\MeGUI-2944-64\tools\lsmash\LSMASHSource.dll")
LoadPlugin("C:\encoding\Avisynth\DoViBaker_v0.2.0\DoViBaker_x64.dll")
LoadPlugin("C:\encoding\Avisynth\DPID-1.1.0\x64\Release\DPID.dll")
LoadPlugin("C:\encoding\Avisynth\avsresize.dll")

bl = LWLibavVideoSource("BL.hevc", format="YUV420P10", repeat=true)
el = LWLibavVideoSource("EL.hevc", format="RGB24", repeat=true)

# BL Crop & Resize

blcrop = Crop(bl,0,278,0,-278)
resizedbl = DPID(blcrop, 1920, 802, 1.2)

# EL Crop

elcrop = Crop(el,0,139,0,-139)
elinput = ConvertToYUV420(elcrop,matrix="Rec2020")

baked = DoViBaker(resizedbl,elinput)
ConvertToYUV420(baked,matrix="Rec2020")
ConvertBits(10)
PreFetch(4)

ConvertToYUV420 is 8 bit i guess so dovibaker will need higher bit depth

erazortt commented 7 months ago

I would just overcrop to 140. No harm in there, nobody cares for that on pixel missing. Under no circumstances would I do color conversions just for that one pixel. RGB<->YUV is not lossless! You should only do this if its a technical must.

Mahaaveer commented 7 months ago

Thanks for the wisdom. Keeping it simple always helps !

erazortt commented 7 months ago

To put things into perspective. In the old days of divx people where using mod16 crops on 480p sources. Now we are blessed with mod2 on 1080p sources.

Mahaaveer commented 6 months ago

baked.z_ConvertFormat(chromaloc_op="center=>top_left",pixel_type="YUV420P16",colorspace_op="rgb:st2084:2020:full=>2020ncl:st2084:2020:limited",dither_type="none",resample_filter="spline36",resample_filter_uv="spline36")

Just trying to understand what is happening here. I get the color space conversion but resampling with spline after resizing, 10 bit to 16 bit conversion before encoding, and chromalac operation confuses me the most. I find DPID to be sharper than spline but always leaves me with box like deblocking artifacts .. even with crf in the range of 13-16 ... wish spline retained the source's sharpness

erazortt commented 6 months ago
Mahaaveer commented 6 months ago

Thanks for taking the time for detailed explanation. Now i understand it better.