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 8th September 2022, 12:26   #1  |  Link
SaurusX
Registered User
 
Join Date: Feb 2017
Posts: 134
Help Translating AVISynth to Vapoursynth

This is probably a no-brainer, but how do I directly translate this AVS script fragment to VS syntax?

Code:
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)
SaurusX is offline   Reply With Quote
Old 8th September 2022, 18:06   #2  |  Link
Selur
Registered User
 
Selur's Avatar
 
Join Date: Oct 2001
Location: Germany
Posts: 7,259
Since I got a few minutes:

aWarpSharp2 -> https://github.com/dubhater/vapoursynth-awarpsharp2:
Avisynth:
Code:
clip = clip.aWarpSharp2(thresh=128, blur=2, type=0, depth=8, chroma=6)
chroma=6 isn't available in Vapoursynth, there chroma:
Quote:
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:
Code:
clip = clip .warp.AWarpSharp2(thresh=128, blur=2, type=0)

Xaa -> https://github.com/dubhater/vapoursynth-xaa
Avisynht:
Code:
clip = clip.Xaa(mode="dr NNedi3",ss=1,mthr=35,mask=1,mtype="TEMmod",nns=2)
Vapoursynth:
Code:
clip = xaa.xaa(clip = clip, mode="dr znedi3", ss=1, mthr=35, mask=1, mtype="TEdgeMask", nns=2)
DeHalo_Alpha -> https://github.com/HomeOfVapourSynth...er/havsfunc.py
Avisynth:
Code:
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:
Code:
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
__________________
Hybrid here in the forum, homepage
Selur is offline   Reply With Quote
Old 9th September 2022, 17:45   #3  |  Link
SaurusX
Registered User
 
Join Date: Feb 2017
Posts: 134
Much thanks. I'm still working on figuring out all these little differences.
SaurusX is offline   Reply With Quote
Old 29th September 2022, 21:41   #4  |  Link
gugglu
Registered User
 
Join Date: Jul 2012
Location: Nottingham
Posts: 44
Hi Selur I was about to create a thread about the similar topic>can you please help me translating this avisynth code into vapoursynth.


Code:
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.
Code:
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=[])

Last edited by gugglu; 30th September 2022 at 08:49. Reason: Quote removed
gugglu is offline   Reply With Quote
Old 30th September 2022, 06:39   #5  |  Link
Selur
Registered User
 
Selur's Avatar
 
Join Date: Oct 2001
Location: Germany
Posts: 7,259
First thing I would usually do is convert the Avisynth script in a more readable form (hopefully I didn't make a mistake there)
Code:
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
    Code:
    emask = core.tcanny.TCanny(src,sigma=2.00,mode=1,planes=[0])
    translation is wrong.
    It should be
    Code:
    emask = core.tcanny.TCanny(src,sigma=2.00,mode=1,planes=[0,1,2])
    or simpler
    Code:
    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:
    Code:
    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.
__________________
Hybrid here in the forum, homepage
Selur is offline   Reply With Quote
Old 30th September 2022, 21:05   #6  |  Link
gugglu
Registered User
 
Join Date: Jul 2012
Location: Nottingham
Posts: 44
Quote:
Originally Posted by Selur View Post
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
    Code:
    emask = core.tcanny.TCanny(src,sigma=2.00,mode=1,planes=[0])
    translation is wrong.
    It should be
    Code:
    emask = core.tcanny.TCanny(src,sigma=2.00,mode=1,planes=[0,1,2])
    or simpler
    Code:
    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:
    Code:
    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:
Code:
uvmask = vshelpers.logic(umask, vmask, mode='max', planes=[])
sorry about the confusing but
Code:
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
gugglu is offline   Reply With Quote
Old 1st October 2022, 07:46   #7  |  Link
Selur
Registered User
 
Selur's Avatar
 
Join Date: Oct 2001
Location: Germany
Posts: 7,259
Code:
vmask = emask.VtoY # data is in planes[0]
...
uvmask = emask.UtoY # data is in planes[0]
...
which is why I suggested
Quote:
using 'planes=[0]' might do what you want
Quote:
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]
__________________
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 08:19.


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