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. |
|
|
Thread Tools | Search this Thread | Display Modes |
1st October 2022, 21:25 | #1 | Link |
Registered User
Join Date: Jul 2012
Location: Nottingham
Posts: 44
|
Need help to translate Avisynth script into Vapoursynth.
Hello folks
I want to translate my avisynth script code into Vapoursynth script code,but i don't know Vapoursynth that much and having problem to convert some part of the script i have been trying from last few days but still not able to complete the script. i will be greatly thankful him if anyone could help. Here is my Avisynth script Code:
LoadPlugin("C:\Users\Binny\Desktop\MeGUI-2913-32\tools\lsmash\LSMASHSource.dll") LSMASHVideoSource("C:\Users\Binny\Videos\Jungle.mp4") crop(0, 140, 0, -140) Spline36Resize(1920,800) src = last src16 = Dither_convert_8_to_16(src) emask = src.tcanny(sigma=2.00, mode=1, plane=7) denoise = SMDegrain(src,lsb=true,lsb_out=true) deband = GradFun3(denoise, Smode=2, radius=14, ampn=0, thr=0.25, mask=0, lsb_in=true, lsb=true) s16 = deband s8 = deband.ditherpost(mode=-1) blur = s8.minblur(1) sharp = s8.mt_adddiff(mt_makediff(blur,blur.removegrain(4))) sharp16 = Dither_convert_8_to_16 (sharp) dlm16 = Dither_limit_dif16 (s16, sharp16, thr=1.0, elast=2.0) #i did translate the script upto here i will leave a translated code below hopefully its correct if you guys found anything wrong please correct me.tia # This Avisynth block of mask i am not able to translate into Vapoursynth script code ymask = emask.ConvertToY8.mt_lut("x 3 <= 0 x 3 - 7 << ?", U=1, V=1) uvmask = emask.UtoY.ConvertToY8.mt_logic(emask.VtoY.ConvertToY8, "max", Y=3, U=1, V=1) \ .Spline36Resize(emask.width, emask.height, 0.25) \ .mt_expand(U=1, V=1).mt_lut("x 4 <= 0 255 ?", U=1, V=1) mask = ymask.mt_logic(uvmask, "max", Y=3, U=1, V=1) \ .ConvertToYV12() #stuck here from almost a week dm16_8 = Dither_merge16_8(dlm16, src16, mask, luma=true, Y=3, U=3, V=3) #Dither_quantize (dm16_8,bitdepth=10,reducerange=true,mode=0).Dither_out()#Reduce to 10bit Interleave output to x264 DitherPost(dm16_8,mode=0) #Reduce to 8bit output Code:
import vapoursynth as vs import havsfunc import muvsfunc import Dither import vshelpers core = vs.core src = core.lsmas.LWLibavSource(r'C:\Users\Binny\Videos\Jungle.mp4') src = core.std.Crop(src,0,0,140,140) src = core.resize.Spline36(src, width=1920, height=800) emask = core.tcanny.TCanny(src,sigma=2.00,mode=1,planes=[0,1,2]) src16 = core.fmtc.bitdepth(src, bits=16) denoise = havsfunc.SMDegrain(src16) deband = muvsfunc.GradFun3(denoise, smode=2, radius=14, ampn=0, thr=0.25, mask=0, lsb=True) s16 = deband s8 = deband.fmtc.bitdepth(bits=8,dmode=1) blur = havsfunc.MinBlur(s8,r=1) sharp = s8.std.MergeDiff(core.std.MakeDiff(blur,blur.rgvs.RemoveGrain(4))) sharp16 = core.fmtc.resample(sharp) dlm16 = Dither.limit_dif16(s16, sharp16, thr=1.0, elast=2.0) dlm16.set_output() #only upto here i could translate ,guys i really need help to complete the below part correctly. Code:
#my attempt to translate the below avisynth code and ended up with this [vapoursynth.Error: Expr: More expressions given than there are planes] error in vshelpers logic function #ymask = emask.std.ShufflePlanes(planes=0, colorfamily=vs.GRAY).std.Expr(expr=["x 3 <= 0 x 3 - 128 * ?", ""]) #umask = emask.std.ShufflePlanes(planes=1, colorfamily=vs.GRAY) #vmask = emask.std.ShufflePlanes(planes=2, colorfamily=vs.GRAY) #uvmask = vshelpers.logic(umask, vmask, mode='max', planes=[0]) # This Avisynth block of mask i am struggling to translate into Vapoursynth avobe #ymask = emask.ConvertToY8.mt_lut("x 3 <= 0 x 3 - 7 << ?", U=1, V=1) #uvmask = emask.UtoY.ConvertToY8.mt_logic(emask.VtoY.ConvertToY8, "max", Y=3, U=1, V=1) #\ .Spline36Resize(emask.width, emask.height, 0.25) #\ .mt_expand(U=1, V=1).mt_lut("x 4 <= 0 255 ?", U=1, V=1) #mask = ymask.mt_logic(uvmask, "max", Y=3, U=1, V=1) #\ .ConvertToYV12() #stuck here from almost a week Thank you for having a look. |
2nd October 2022, 08:39 | #2 | Link |
͡҉҉ ̵̡̢̛̗̘̙̜̝̞̟̠͇̊̋̌̍̎̏̿̿
Join Date: Feb 2009
Location: No support in PM
Posts: 712
|
The part between s16 and dlm16 is a pattern for mixing 8-bit and stack16 processing in the times when Avisynth couldn’t use native 16 bit data. You most likely don’t need this suboptimal hack with VS. You could replace it with something like:
Code:
blur = havsfunc.MinBlur(deband,r=1) dlm16 = deband.std.MergeDiff(core.std.MakeDiff(blur,blur.rgvs.RemoveGrain(4)))
__________________
dither 1.28.1 for AviSynth | avstp 1.0.4 for AviSynth development | fmtconv r30 for Vapoursynth & Avs+ | trimx264opt segmented encoding |
2nd October 2022, 10:51 | #3 | Link | |
Registered User
Join Date: Jul 2012
Location: Nottingham
Posts: 44
|
Quote:
|
|
16th October 2022, 17:16 | #4 | Link |
Registered User
Join Date: Jul 2012
Location: Nottingham
Posts: 44
|
Code:
# This Avisynth block of mask i am struggling to translate into Vapoursynth avobe #ymask = emask.ConvertToY8.mt_lut("x 3 <= 0 x 3 - 7 << ?", U=1, V=1) #uvmask = emask.UtoY.ConvertToY8.mt_logic(emask.VtoY.ConvertToY8, "max", Y=3, U=1, V=1) #\ .Spline36Resize(emask.width, emask.height, 0.25) #\ .mt_expand(U=1, V=1).mt_lut("x 4 <= 0 255 ?", U=1, V=1) #mask = ymask.mt_logic(uvmask, "max", Y=3, U=1, V=1) #\ .ConvertToYV12() #stuck here from almost a week thanks cretindesalpes. |
18th October 2022, 03:35 | #5 | Link |
Registered User
Join Date: Oct 2001
Location: Germany
Posts: 7,259
|
@gugglu: might be a good idea to also post a complete finished translation in 'translate Avisynth script into Vapoursynth' scripts to help potential other users.
As a bonus, explaining what the script is intended to do also might help other users. |
Thread Tools | Search this Thread |
Display Modes | |
|
|