View Full Version : A dummy needs some help porting an AviSynth script.
brucethemoose
22nd September 2016, 00:13
I'm trying to run this wonderful little IVTC script in VapourSynth:
edeintted = SeparateFields().SelectEven().EEDI2(field=-1)
tdeintted = TDeint(edeint=edeintted)
tfm(order=-1,clip2=tdeintted).tdecimate(mode=1,hybrid=1)
But I get an "unable to import" error when trying to import TVITC, EEDI2, or TDeint with avs.loadplugin(). (If anyone knows why, that would certainly help).
So, I tried copying it to VapourSynth. This is what I got:
f = 1 #top field first
edeintted = core.eedi2.EEDI2(core.std.SelectEvery(core.std.SeparateFields(clip), 2, 0), field = f)
tdeintted = core.tdm.TDeintMod(edeintted, order = f)
clip = core.vivtc.VFM(edeintted, order=f,clip2=tdeintted)
clip = core.vivtc.VDecimate(clip)
Unfortunately, the output looks pretty bad. Something is very wrong, and just mucking about with the syntax I can't seem to fix it :(.
I know VDecimate is missing some of the options TDecimate has, and VS doesnt have the internal field flag that AS has.
The 2 plugins are attached. And please, forgive me, for I know not what I do :D
EDIT: Oh, and here's a sample:
Interlaced: https://drive.google.com/open?id=0B5x9fhXF1aIwMGthUDlRQk5mNlE
Desired final output: https://drive.google.com/open?id=0B5x9fhXF1aIwaWdZVGNVQUFtNEE
Are_
22nd September 2016, 00:21
clip = core.vivtc.VFM(edeintted, order=f,clip2=tdeintted)
should translate to
clip = core.vivtc.VFM(clip, order=f,clip2=tdeintted)
or am I missing something?
Anyway, I don't know if that's gonna fix anything.
brucethemoose
22nd September 2016, 00:45
clip = core.vivtc.VFM(edeintted, order=f,clip2=tdeintted)
should translate to
clip = core.vivtc.VFM(clip, order=f,clip2=tdeintted)
or am I missing something?
Anyway, I don't know if that's gonna fix anything.
I get a ton of interlaced frames with that.
You got the right idea though, I think I followed the variables around wrong and misplaced one of the videos.
TheFluff
22nd September 2016, 04:19
The clip2 parameter doesn't do what you think it does. In TFM it's used for postprocessing frames that are detected as interlaced after field matching, but VFM doesn't have any postprocessing functionality (instead it sets the _Combed frame property and lets you sort that stuff out yourself). Instead, clip2 is used if you want to use VFM on something that isn't 8-bit YV12, in which case matching decisions are made based on clip while output is created from clip2.
I would suggest consulting the documentation for VFM; it's not an exact copy of TFM.
brucethemoose
22nd September 2016, 04:32
The clip2 parameter doesn't do what you think it does. In TFM it's used for postprocessing frames that are detected as interlaced after field matching, but VFM doesn't have any postprocessing functionality (instead it sets the _Combed frame property and lets you sort that stuff out yourself). Instead, clip2 is used if you want to use VFM on something that isn't 8-bit YV12, in which case matching decisions are made based on clip while output is created from clip2.
I would suggest consulting the documentation for VFM; it's not an exact copy of TFM.
I was afraid of that. According to the documentation, there's not really an direct equivalent to those parameters from TFM or TDecimate.
EDIT: Oh, but I did just see the _Combed property, I guess I can work with that, thanks.
I do wish VS wouldn't crash when trying to import the script with Avisource though :(
brucethemoose
22nd September 2016, 06:33
What's the syntax for getting _Combed?
I'm brand new to python and pretty new to coding, and after digging though github and the forums I can't find a single simple example of anyone simply grabbing a property from the current frame.
I've seen the documentation here:
http://www.vapoursynth.com/doc/pythonreference.html
But it doesn't tell me the syntax for accessing that property.
brucethemoose
22nd September 2016, 07:45
Alright, I seem to have figured it out. I didn't realize we needed a whole function for conditional statements, but it kinda makes sense.
If anyone in the future is looking for an Vapoursynth IVTC post-processor (something to get rid of the combed frames IVTC misses), this is what I got, basically copied from the TDeint example:
f = 1 #field
clip = core.vivtc.VFM(clip, mode = 0, order=f, mi = 74, cthresh = 8) #IVTC
def conditionalDeint(n, f, orig, deint):
if f.props._Combed:
return deint
else:
return orig
deint = core.tdm.TDeintMod(clip, order=1, edeint=core.nnedi3.nnedi3(clip, field=1)) #Deinterlacer goes here!
#deint = havsfunc.QTGMC(clip, TFF=True, Preset="Medium", InputType=2 ) #Slower alternative, untested
combProps = clip #Get _Combed flag from VFM
#combProps = core.tdm.IsCombed(clip) #Get _Combed flag from IsCombed.
clip = core.std.FrameEval(clip, functools.partial(conditionalDeint, orig=clip, deint=deint), clip)
clip = core.vivtc.VDecimate(clip)
TheFluff
22nd September 2016, 18:34
clip = core.vivtc.VFM(clip, mode = 0, order=1, mi = 74, cthresh = 8)
deint = core.tdm.TDeintMod(clip, order=1, edeint=core.nnedi3.nnedi3(clip, field=1))
clip = core.std.FrameEval(clip, lambda n, f: return deint if f.props._Combed else clip, clip)
not tested, but I really think this is a case where you don't need to muck around with partial functions, just define an anonymous function right there
you can write unreadable oneliners in any language, even python
brucethemoose
22nd September 2016, 21:11
clip = core.vivtc.VFM(clip, mode = 0, order=1, mi = 74, cthresh = 8)
deint = core.tdm.TDeintMod(clip, order=1, edeint=core.nnedi3.nnedi3(clip, field=1))
clip = core.std.FrameEval(clip, lambda n, f: return deint if f.props._Combed else clip, clip)
not tested, but I really think this is a case where you don't need to muck around with partial functions, just define an anonymous function right there
you can write unreadable oneliners in any language, even python
Last line gives me a syntax error.
But I'm fine the sloppy def :P
TheFluff
22nd September 2016, 22:40
forgot you don't actually use return statements in lambda functions so last line should be
clip = core.std.FrameEval(clip, lambda n, f: deint if f.props._Combed else clip, clip)
vBulletin® v3.8.11, Copyright ©2000-2025, vBulletin Solutions Inc.