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 22nd September 2016, 00:13   #1  |  Link
brucethemoose
Registered User
 
Join Date: Sep 2016
Posts: 62
A dummy needs some help porting an AviSynth script.

I'm trying to run this wonderful little IVTC script in VapourSynth:

Code:
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:
Code:
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


EDIT: Oh, and here's a sample:

Interlaced: https://drive.google.com/open?id=0B5...GthUDlRQk5mNlE

Desired final output: https://drive.google.com/open?id=0B5...WdZVGNVQUFtNEE
Attached Files
File Type: zip plugins64.zip (195.2 KB, 19 views)

Last edited by brucethemoose; 22nd September 2016 at 00:51.
brucethemoose is offline   Reply With Quote
Old 22nd September 2016, 00:21   #2  |  Link
Are_
Registered User
 
Join Date: Jun 2012
Location: Ibiza, Spain
Posts: 293
Code:
clip = core.vivtc.VFM(edeintted, order=f,clip2=tdeintted)
should translate to
Code:
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.
Are_ is offline   Reply With Quote
Old 22nd September 2016, 00:45   #3  |  Link
brucethemoose
Registered User
 
Join Date: Sep 2016
Posts: 62
Quote:
Originally Posted by Are_ View Post
Code:
clip = core.vivtc.VFM(edeintted, order=f,clip2=tdeintted)
should translate to
Code:
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.
brucethemoose is offline   Reply With Quote
Old 22nd September 2016, 04:19   #4  |  Link
TheFluff
Excessively jovial fellow
 
Join Date: Jun 2004
Location: rude
Posts: 1,094
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.
TheFluff is offline   Reply With Quote
Old 22nd September 2016, 04:32   #5  |  Link
brucethemoose
Registered User
 
Join Date: Sep 2016
Posts: 62
Quote:
Originally Posted by TheFluff View Post
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

Last edited by brucethemoose; 22nd September 2016 at 04:35.
brucethemoose is offline   Reply With Quote
Old 22nd September 2016, 06:33   #6  |  Link
brucethemoose
Registered User
 
Join Date: Sep 2016
Posts: 62
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.

Last edited by brucethemoose; 22nd September 2016 at 06:39.
brucethemoose is offline   Reply With Quote
Old 22nd September 2016, 07:45   #7  |  Link
brucethemoose
Registered User
 
Join Date: Sep 2016
Posts: 62
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:

Code:
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)

Last edited by brucethemoose; 22nd September 2016 at 17:15.
brucethemoose is offline   Reply With Quote
Old 22nd September 2016, 18:34   #8  |  Link
TheFluff
Excessively jovial fellow
 
Join Date: Jun 2004
Location: rude
Posts: 1,094
Code:
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 edited by TheFluff; 22nd September 2016 at 18:40.
TheFluff is offline   Reply With Quote
Old 22nd September 2016, 21:11   #9  |  Link
brucethemoose
Registered User
 
Join Date: Sep 2016
Posts: 62
Quote:
Originally Posted by TheFluff View Post
Code:
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
brucethemoose is offline   Reply With Quote
Old 22nd September 2016, 22:40   #10  |  Link
TheFluff
Excessively jovial fellow
 
Join Date: Jun 2004
Location: rude
Posts: 1,094
forgot you don't actually use return statements in lambda functions so last line should be
Code:
clip = core.std.FrameEval(clip, lambda n, f: deint if f.props._Combed else clip, clip)
TheFluff 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 10:47.


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