View Full Version : Help Translating AVISynth to Vapoursynth
SaurusX
8th September 2022, 12:26
This is probably a no-brainer, but how do I directly translate this AVS script fragment to VS syntax?
aWarpSharp2(thresh=128, blur=2, type=0, depth=8, chroma=6)
Xaa(mode="dr NNedi3",ss=1,mthr=35,mask=1,mtype="TEMmod",nns=2)
dehalo_alpha(ry=1.75,rx=1.75,darkstr=0,brightstr=.8,ss=2,cs=false)
Selur
8th September 2022, 18:06
Since I got a few minutes:
aWarpSharp2 -> https://github.com/dubhater/vapoursynth-awarpsharp2:
Avisynth:
clip = clip.aWarpSharp2(thresh=128, blur=2, type=0, depth=8, chroma=6)
chroma=6 isn't available in Vapoursynth, there chroma:
chroma
Controls the chroma handling method. 0 will use the edge mask from the luma to warp the chroma. 1 will create an edge mask from each chroma channel and use those to warp each chroma channel individually.
Default: 0.
can only be 0 or 1.
Vapoursynth:
clip = clip .warp.AWarpSharp2(thresh=128, blur=2, type=0)
Xaa -> https://github.com/dubhater/vapoursynth-xaa
Avisynht:
clip = clip.Xaa(mode="dr NNedi3",ss=1,mthr=35,mask=1,mtype="TEMmod",nns=2)
Vapoursynth:
clip = xaa.xaa(clip = clip, mode="dr znedi3", ss=1, mthr=35, mask=1, mtype="TEdgeMask", nns=2)
DeHalo_Alpha -> https://github.com/HomeOfVapourSynthEvolution/havsfunc/blob/master/havsfunc.py
Avisynth:
clip = clip.dehalo_alpha(ry=1.75,rx=1.75,darkstr=0,brightstr=.8,ss=2,cs=false)
No clue about cs=false, as normal DeHalo_alpha from http://avisynth.nl/index.php/DeHalo_alpha doesn't have that and neither has havsfunc.DeHalo_alpha
Vapoursynth:
clip = havsfunc.DeHalo_alpha(clp=clip,rx=1.75, ry=1.75, darkstr=0, brightstr=0.8, ss=2)
Since your Avisynth script didn't include any loadplugin&co I assume you will manage to get all the dependencies also in Vapoursynth.
Cu Selur
SaurusX
9th September 2022, 17:45
Much thanks. I'm still working on figuring out all these little differences.
gugglu
29th September 2022, 21:41
Hi Selur I was about to create a thread about the similar topic>can you please help me translating this avisynth code into vapoursynth.
src = 'video.m2ts'
emask = last.tcanny(sigma=2.00, mode=1, plane=7)
ymask = emask.ConvertToY8
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)
mask = ymask.mt_logic(uvmask, "max", Y=3, U=1, V=1).ConvertToYV12
#i was trying it with a logic funtion from vshelpers but its giving me an error 'Expr: More expressions given than there are planes'
#here is what i was doing can you please help me how can i do this.
src = 'video.m2ts'
emask = core.tcanny.TCanny(src,sigma=2.00,mode=1,planes=[0])
ymask = emask.std.ShufflePlanes(planes=0, colorfamily=vs.GRAY)
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=[])
Selur
30th September 2022, 06:39
First thing I would usually do is convert the Avisynth script in a more readable form (hopefully I didn't make a mistake there)
src = 'video.m2ts'
# HERE A LINE using a source filter is missing !!
emask = last.tcanny(sigma=2.00, mode=1, plane=7)
vmask = emask.VtoY
vmask = vmask.ConvertToY8
uvmask = emask.UtoY
uvmask = uvmask.ConvertToY8
uvmask = uvmask.mt_logic(vmask, "max", Y=3, U=1, V=1)
uvmask = uvmask.Spline36Resize(emask.width, emask.height, 0.25)
uvmask = uvmask.mt_expand(U=1, V=1)
ymask = emask.ConvertToY8
mask = ymask.mt_logic(uvmask, "max", Y=3, U=1, V=1)
mask = mask.ConvertToYV12
I won't try to convert this as parts seem to be missing.
But looking at what you did:
Your emask = core.tcanny.TCanny(src,sigma=2.00,mode=1,planes=[0]) translation is wrong.
It should be emask = core.tcanny.TCanny(src,sigma=2.00,mode=1,planes=[0,1,2]) or simpler
emask = core.tcanny.TCanny(src,sigma=2.00,mode=1)
Since the Avisynth call uses plane=7 and the bit mask (binary representation) for 7 is 111, so all planes get processes not just the Y plane.
The error you get ('Expr: More expressions given than there are planes') and at the line:
uvmask = vshelpers.logic(umask, vmask, mode='max', planes=[])
Your problem seems to be that you used an empty planes array. Just removing the 'planes=[]' or using 'planes=[0]' might do what you want.
Cu Selur
Ps.: no clue why you quoted my previous post in total, if you post is not referring to it at all.
gugglu
30th September 2022, 21:05
First thing I would usually do is convert the Avisynth script in a more readable form (hopefully I didn't make a mistake there)
I won't try to convert this as parts seem to be missing.
But looking at what you did:
Your emask = core.tcanny.TCanny(src,sigma=2.00,mode=1,planes=[0]) translation is wrong.
It should be emask = core.tcanny.TCanny(src,sigma=2.00,mode=1,planes=[0,1,2]) or simpler
emask = core.tcanny.TCanny(src,sigma=2.00,mode=1)
Since the Avisynth call uses plane=7 and the bit mask (binary representation) for 7 is 111, so all planes get processes not just the Y plane.
The error you get ('Expr: More expressions given than there are planes') and at the line:
uvmask = vshelpers.logic(umask, vmask, mode='max', planes=[])
Your problem seems to be that you used an empty planes array. Just removing the 'planes=[]' or using 'planes=[0]' might do what you want.
Cu Selur
Ps.: no clue why you quoted my previous post in total, if you post is not referring to it at all.
thank you for your reply and correcting Tcanny Translate, i am using SMDegrain and Gradfun3 before creating this mask in Vapoursynth. But i can't translate my avisynth script code into vapoursynth srcipt code.
The error you get ('Expr: More expressions given than there are planes') and at the line:
uvmask = vshelpers.logic(umask, vmask, mode='max', planes=[])
sorry about the confusing but
uvmask = vshelpers.logic(umask, vmask, mode='max', planes=[])# it is not accepting any planes [1] or [2] or [3]
as umask is plane=1
and
vmask is plane=2
i was trying this
uvmask = vshelpers.logic(umask, vmask, mode='max', planes=[1,2])
and ending up with a error 'Expr: More expressions given than there are planes' still no luck to make it work
Please could you help me correcting this code if you want i can drop my script but there is nothing special in it
Selur
1st October 2022, 07:46
vmask = emask.VtoY # data is in planes[0]
...
uvmask = emask.UtoY # data is in planes[0]
...
which is why I suggested
using 'planes=[0]' might do what you want
it is not accepting any planes [1] or [2] or [3]
Naturally, since:
planes[3] doesn't exist
planes[1] and planes[2] also isn't set in umask and vmaks
-> try planes[0]
vBulletin® v3.8.11, Copyright ©2000-2025, vBulletin Solutions Inc.