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 > Avisynth Usage

Reply
 
Thread Tools Search this Thread Display Modes
Old 13th February 2009, 06:53   #41  |  Link
Mug Funky
interlace this!
 
Mug Funky's Avatar
 
Join Date: Jun 2003
Location: i'm in ur transfers, addin noise
Posts: 4,555
oooh, that means something is failing for 1 of the detected types of frames (by default "film" or "other").

try "show=true" and tell me what colour the top-left corner is. from the look of things it may be buggering up on one of the plugins it uses (maybe mvtools, as i haven't updated this for mvtools2 with superclips and all that).

glad to hear it's coming in useful, somewhat. i haven't maintained this script since i moved jobs from being the fixer of problems to the cause of them
__________________
sucking the life out of your videos since 2004
Mug Funky is offline   Reply With Quote
Old 13th February 2009, 10:53   #42  |  Link
McCauley
Registered User
 
Join Date: Nov 2006
Posts: 83
Added to wiki.

Regards
McCauley
McCauley is offline   Reply With Quote
Old 13th February 2009, 13:26   #43  |  Link
Floatingshed
Registered User
 
Join Date: Nov 2008
Posts: 324
Thanks for the fast response. The colour in the top left is red. The error message is intermittent. I had it on frames 57 and 60 of a clip but when I re-loaded it was fine. Another clip had it on frames 0 and 5 but again it is difficult to recreate. There is no crash or problem loading into VDub, just an error message on the outputted video and it seems only to occur in the first few seconds of a clip.

Apart from this tiny problem this is an absolutely superb piece of work, I've never seen better NTSC-PAL conversion.

I do have a clip it doesn't like though! But that's another story and another post in the near future.

Thanks.
Floatingshed is offline   Reply With Quote
Old 13th February 2009, 22:41   #44  |  Link
Floatingshed
Registered User
 
Join Date: Nov 2008
Posts: 324
Which version of MVTools was your function designed to work with? Maybe I could use that and see if the problem goes away?
Thanks.
Floatingshed is offline   Reply With Quote
Old 16th February 2009, 03:01   #45  |  Link
Mug Funky
interlace this!
 
Mug Funky's Avatar
 
Join Date: Jun 2003
Location: i'm in ur transfers, addin noise
Posts: 4,555
aaah, stupid me forgot that i used clouded's "motion" plugin to do the motion-compensated frame rate conversion (and i think i also used the "blendfps" component for the dumb-blend default mode). unfortunately this plugin is not maintained (hope clouded's alright, but he dropped off the forum years ago).

you can find the 12/12/05 version on warpenterprises' plugin page here:

http://avisynth.org/warpenterprises/

or download the plugin directly here:

http://avisynth.org/warpenterprises/...l_20051212.zip

hopefully that should make it all work. i just quickly tested it on some awful NTSC VHS i got from a friend and it appears to be working (though it likes cleaner video and was falsely matching the analog black as film... ah well), though i seem to be using a newer version of the script. that doesn't necessarily mean it's better mind you...
__________________
sucking the life out of your videos since 2004
Mug Funky is offline   Reply With Quote
Old 18th February 2009, 20:00   #46  |  Link
Floatingshed
Registered User
 
Join Date: Nov 2008
Posts: 324
Downloaded it only to find that its the same version I have!
Still got the problem regardless of input clip. Loads fine, works beautifully but still outputs the error message on one or two frames.
Is it possible to switch off the subtitle-style error reporting in avisynth?
Thanks again.
Floatingshed is offline   Reply With Quote
Old 18th February 2009, 20:56   #47  |  Link
Gavino
Avisynth language lover
 
Join Date: Dec 2007
Location: Spain
Posts: 3,431
Quote:
Originally Posted by Floatingshed View Post
Is it possible to switch off the subtitle-style error reporting in avisynth?
No - and you shouldn't want to. You get errors reported this way when a run-time script (such as within ScriptClip) produces an error.

Since a run-time script can do different things on different frames, sometimes you only get the error on certain frames. But it still indicates a problem in the script that needs to be fixed.
Gavino is offline   Reply With Quote
Old 18th February 2009, 21:14   #48  |  Link
IanB
Avisynth Developer
 
Join Date: Jan 2003
Location: Melbourne, Australia
Posts: 3,167
@Floatingshed,

Actually, sort of yes. As Gavino points out "you shouldn't want to". The error "Evaluate: System exception - Access violation" is very serious. It means some code tried to access part of the address space that was not declared. If the rouge access is random that same code accessing any part of the address space that is declared will not trigger an error, it will silently just mess things up. So you really should find and replace the errant plugin.

To suppress the default error handling behaviour you can wrap the offending statement with a try/catch and script to deal with (or ignore) the problem.
Code:
try {
    statement # goes boom!
}
catch(err_msg) {
    statements
    ...
}
IanB is offline   Reply With Quote
Old 18th February 2009, 21:36   #49  |  Link
Gavino
Avisynth language lover
 
Join Date: Dec 2007
Location: Spain
Posts: 3,431
Quote:
Originally Posted by IanB View Post
To suppress the default error handling behaviour you can wrap the offending statement with a try/catch and script to deal with (or ignore) the problem.
Yes, but note you would need to put the try/catch inside the failing run-time script, ie at the appropriate place inside NTSCTools. Putting it in the user-level script will not help.
Gavino is offline   Reply With Quote
Old 18th February 2009, 22:38   #50  |  Link
Floatingshed
Registered User
 
Join Date: Nov 2008
Posts: 324
Thanks for your replies. However I understand very little of it. I can write simple scripts for my own use but something as complex as this is way beyond me. Mug Funky's script produces superb results apart from this small problem. The error never seems to occur on the same frame twice. This is really frustrating as I have a lot of material to process. Any more ideas very welcome. Thanks.
Floatingshed is offline   Reply With Quote
Old 18th February 2009, 22:41   #51  |  Link
Floatingshed
Registered User
 
Join Date: Nov 2008
Posts: 324
Quote:
Originally Posted by Mug Funky View Post
though i seem to be using a newer version of the script. that doesn't necessarily mean it's better mind you...
Could I possibly try the newer version please?
Floatingshed is offline   Reply With Quote
Old 19th February 2009, 06:19   #52  |  Link
Mug Funky
interlace this!
 
Mug Funky's Avatar
 
Join Date: Jun 2003
Location: i'm in ur transfers, addin noise
Posts: 4,555
here's 0.96. i think the defaults have been tweaked slightly.

note that you have a choice of IVTC methods for "film" flagged frames. it's possible that's where the errors were popping up before, so if this new script doesn't help you could change "IVTCtype" to some other number (it says inside the script what each one does).

also, AFAIK this script is a bit slower but _should_ be better quality. bear in mind any tweaks i've made since i left madman have been sample-specific, and haven't been "general" solutions (at madman i was putting through ~60 DVDs a month, mostly on this script. where i am now i'm not even encoding, but colour grading, so i don't see much NTSC, and almost never need to convert it).

keep the old script on hand somewhere - rename it and turn the "avsi" into "avs" so it doesn't get autoloaded.

good luck

Code:
####
##
## NTSC tools 0.96, by Sal, aka Mug
##
## takes an NTSC clip, finds Film, 30p and 60i parts and gives them special treatment
## use it to convert to PAL with 4% speed-up (ie 23.976 to 25 fps)
##
####

function AutoPAL (clip c, clip "ext_match", bool "speedup", float "th_film", int "th_film2", int "th_prog", float "th_noise", int "th_noise2", int "th_bob", bool "show", int "mode", string "filter", bool "blend", int "deblocker", int "IVTCtype", int "precision", bool "find30p", int "reset", int "denoise",int "threads")
{
speedup=default(speedup,false)
ext_match=default(ext_match,c)
blend=default(blend,true)
th_film=default(th_film,.4)#.15)
th_film2=default(th_film2,5)
th_prog=default(th_prog,18) # 16 seems good

th_noise=default(th_noise,.5)
th_noise2=default(th_noise2,40)

th_bob=default(th_bob,8)
show=default(show,false)
mode=default(mode,1)
filter=default(filter,"last")
deblocker=default(deblocker,0)
IVTCtype = default(IVTCtype,3)	# 1 = telecide, 2 = tfm, 3 = tfm(pp=0), 4 = tdeint(mode=2), 5 = smartdecimate  ...formerly 2
precision = default(precision,1)
reset = default(reset,50)
denoise = default(denoise,0)

threads=default(threads,1)

find30p = default(find30p,false)

data= NTSCanalyse(ext_match,th_film=th_film,th_prog=th_prog, th_noise=th_noise,th_film2=th_film2,precision=precision,find30p=find30p,denoise=denoise)


threads<=1? NTSCconvert(c,data,th_bob=th_bob,speedup=speedup,show=show,mode=mode,filter=filter,blend=blend,deblocker=deblocker, IVTCtype=IVTCtype, reset=reset) :
\ mt(blackpal(c.changefps(25).framecount()),"""NTSCconvert(c,data,th_bob=th_bob,speedup=speedup,show=show,mode=mode,filter=filter,blend=blend,deblocker=deblocker, IVTCtype=IVTCtype, reset=reset)""",threads,8,true)



c.height==576? deblocker==0? c : c.converttoyv12(interlaced=true).deblocker(quant=deblocker,ipp=true) : last
}

function NTSCanalyse (clip c, float "th_film", int "th_film2", int "th_prog", int "precision", bool "show", bool "find30p", int "denoise", float "th_noise", int "th_noise2")
{
# output clip is teeny coloured clip in same space as input
# red   = FILM
# green = progressive
# blue  = interlaced

show=default(show,false)
order = c.getparity()==true? 1 : 0

global filmnum=-4
global ftype="60i"
global noise=1
global noise2=1

global th_film=default(th_film,.4)#.15)
global th_film2=default(th_film2,5)
global th_prog=default(th_prog,18) # 16 seems good

global th_noise=default(th_noise,.5)
global th_noise2=default(th_noise2,40)

precision=default(precision,1)
denoise = default(denoise,0)

find30p = default(find30p,false)

e = c.converttoyv12(interlaced=true)
d= denoise==0? 
\	c.bicubicresize(32*precision,c.height,1/3.,1/3.,16,0,c.width-32,c.height).separatefields().bicubicresize(32*precision,32*precision,1/3.,1/3.,0,8,32*precision,(c.height/2.)-16).converttoyv12()
\ :	c.bicubicresize(32*precision,c.height,1/3.,1/3.,16,0,c.width-32,c.height).separatefields().bicubicresize(32*precision,32*precision,1/3.,1/3.,0,8,32*precision,(c.height/2.)-16).converttoyv12().weave().temporalsoften(5,denoise,0).separatefields()

global film_c = d
global film_d = d.selectevery(2,0)

weavemask=e.mt_edge("0 -1 0 0 2 0 0 -1 -0 2",0,255,y=3,u=3,v=3)
separatemask=e.separatefields().mt_edge("0 -1 0 0 2 0 0 -1 -0 2",0,255,y=3,u=3,v=3).weave()

global f01	= mt_lutxy(weavemask,separatemask,expr="x y -").mt_inpand(mode=mt_rectangle(0,2))

global f02	= mt_lutxy(film_c.selectevery(2,0),	film_c.selectevery(2,2),expr="x y - abs")
global f13	= mt_lutxy(film_c.selectevery(2,1),	film_c.selectevery(2,3),expr="x y - abs")
global b1f1	= mt_lutxy(film_c.selectevery(2,-1),	film_c.selectevery(2,1),expr="x y - abs")
global b02	= mt_lutxy(film_c.selectevery(2,0),	film_c.selectevery(2,-2),expr="x y - abs")
global f24	= mt_lutxy(film_c.selectevery(2,2),	film_c.selectevery(2,4),expr="x y - abs")
global b13	= mt_lutxy(film_c.selectevery(2,-1),	film_c.selectevery(2,-3),expr="x y - abs")
global b24	= mt_lutxy(film_c.selectevery(2,-2),	film_c.selectevery(2,-4),expr="x y - abs")
global f35	= mt_lutxy(film_c.selectevery(2,3),	film_c.selectevery(2,5),expr="x y - abs")
global b35	= mt_lutxy(film_c.selectevery(2,-3),	film_c.selectevery(2,-5),expr="x y - abs")

global NTSCanalyse_red   = blankclip(film_d,width=8,height=4,color=$ff0000)
global NTSCanalyse_green = blankclip(film_d,width=8,height=4,color=$00ff00)
global NTSCanalyse_blue  = blankclip(film_d,width=8,height=4,color=$0000ff)

film_d1 =    scriptclip(NTSCanalyse_blue,""" ftype=="24p" ? NTSCanalyse_red : ftype=="30p" ? NTSCanalyse_green : NTSCanalyse_blue """)

film_d2 = find30p==true? frameevaluate(film_d1,""" ftype = f01.yplanemax() <= th_prog ? "30p" : ftype """) : frameevaluate(film_d1,"NOP")
film_d3 = frameevaluate(film_d2,""" 
\	ftype = (noise2==1)? ftype : ftype != "24p"? "60i" : (b1f1.yplanemax() < th_film2) ? "24p" : 
\	max(f02.yplanemax(),b35.yplanemax()) < th_film2 ? "24p" : 
\	max(b02.yplanemax(),f35.yplanemax()) < th_film2 ? "24p" : 
\	max(b13.yplanemax(),f24.yplanemax()) < th_film2 ? "24p" : 
\	max(f13.yplanemax(),b24.yplanemax()) < th_film2 ? "24p" : 
\	max(f24.yplanemax(),b13.yplanemax()) < th_film2 ? "24p" : 
\	max(b24.yplanemax(),f13.yplanemax()) < th_film2 ? "24p" : "60i" """)

film_d4 = frameevaluate(film_d3,""" 
\	ftype = (noise==1)? ftype : (b1f1.averageluma() < th_film) ? "24p" : 
\	max(f02.averageluma(),b35.averageluma()) < th_film ? "24p" : 
\	max(b02.averageluma(),f35.averageluma()) < th_film ? "24p" : 
\	max(b13.averageluma(),f24.averageluma()) < th_film ? "24p" : 
\	max(f13.averageluma(),b24.averageluma()) < th_film ? "24p" : 
\	max(f24.averageluma(),b13.averageluma()) < th_film ? "24p" : 
\	max(b24.averageluma(),f13.averageluma()) < th_film ? "24p" : "60i" """)

film_d5 = frameevaluate(film_d4,""" 
\	noise= (b1f1.averageluma() > th_noise) ? 0 : 
\	max(f02.averageluma(),b35.averageluma()) > th_noise ? 0 : 
\	max(b02.averageluma(),f35.averageluma()) > th_noise ? 0 : 
\	max(b13.averageluma(),f24.averageluma()) > th_noise ? 0 : 
\	max(f13.averageluma(),b24.averageluma()) > th_noise ? 0 : 
\	max(f24.averageluma(),b13.averageluma()) > th_noise ? 0 : 
\	max(b24.averageluma(),f13.averageluma()) > th_noise ? 0 : 1 """)

film_d6 = frameevaluate(film_d5,""" 
\	noise2= (b1f1.yplanemax() > th_noise2) ? 0 : 
\	max(f02.yplanemax(),b35.yplanemax()) > th_noise2 ? 0 : 
\	max(b02.yplanemax(),f35.yplanemax()) > th_noise2 ? 0 : 
\	max(b13.yplanemax(),f24.yplanemax()) > th_noise2 ? 0 : 
\	max(f13.yplanemax(),b24.yplanemax()) > th_noise2 ? 0 : 
\	max(f24.yplanemax(),b13.yplanemax()) > th_noise2 ? 0 : 
\	max(b24.yplanemax(),f13.yplanemax()) > th_noise2 ? 0 : 1 """)



show==true? overlay(c,film_d6) : film_d6

show==true? scriptclip(""" subtitle("max pixel difference = "+
\	string(max(b1f1.yplanemax(),
\	f02.yplanemax(),b35.yplanemax(),
\	b02.yplanemax(),f35.yplanemax(),
\	b13.yplanemax(),f24.yplanemax(),
\	f13.yplanemax(),b24.yplanemax(),
\	f24.yplanemax(),b13.yplanemax(),
\	b24.yplanemax(),f13.yplanemax()))+", max avg luma diff = "+
\	string(max(b1f1.averageluma(),
\	f02.averageluma(),b35.averageluma(),
\	b02.averageluma(),f35.averageluma(),
\	b13.averageluma(),f24.averageluma(),
\	f13.averageluma(),b24.averageluma(),
\	f24.averageluma(),b13.averageluma(),
\	b24.averageluma(),f13.averageluma()))
\	+", noise1 = "+string(noise)+", noise2 = "+string(noise2)) """) : last

}

function NTSCconvert (clip c, clip data, bool "speedup", int "th_bob", int "mode", bool "show", string "filter", bool "blend", int "deblocker",int "IVTCtype", int "reset")
{
# mode 1 = blend non-film frames to 50i
# mode 2 = try to motion-compensate non-film frames to 25p or 50i

speedup=default(speedup,true)
th_bob=default(th_bob,2)
blend=default(blend,true)
mode=default(mode,1)
show=default(show,false)
filter = default(filter,"last")
deblocker = default(deblocker,0)
IVTCtype = default(IVTCtype,3)	# 1 = telecide, 2 = tfm(chroma=true), 3 = tfm(), 4 = tdeint(mode=2) 5 = smartdecimate
reset = default(reset,50)

outnum = speedup==true? 48000 : 50000
outden = speedup==true? 1001 : 1000

order = c.getparity()==true? 1 : 0

d = deblocker==0? c : c.converttoyv12(interlaced=true).deblocker(quant=deblocker,ipp=true)
d = mode==1? d : d.converttoyv12(interlaced=true)

global bobbed = d.tdeint(1,order,expand=4,mthreshl=th_bob)
sdbob = d.tdeint(1,order,expand=4,mi=24,cthresh=8,mthreshl=th_bob,tryweave=true)

NTSCconvert_60i = mode==1? bobbed.vinverse().blendfps(outnum/float(outden),1.25).changefps(outnum,outden).resizetopal(false,false) : bobbed.vinverse().converttoyv12(interlaced=false).salfps(outnum/float(outden),protection2=60,reset=reset).changefps(outnum,outden).resizetopal(false,false)
NTSCconvert_30p = d.converttoyv12().vinverse().salfps(outnum/float(2*outden),protection2=50,reset=reset).resizetopal(false,false).changefps(outnum/2,outden)

IVTCtype==1? d.telecide(order=order,guide=1).decimate() :\
IVTCtype==2? d.tfm(order=order,pp=0,chroma=true).decimate() :\
IVTCtype==3? d.tfm(order=order,pp=0,chroma=false).decimate() :\
IVTCtype==4? d.tdeint(2,-1,expand=4,tryweave=true,cthresh=3,mi=24,mthreshl=8,chroma=true).decimate() :\
d.smartdecimate(24,60,bob=sdbob,tel=1.)

vinverse()
resizetopal(false,false)

eval(filter)
NTSCconvert_24pfilter = last

global NTSCconvert_24p = speedup==true?
\ NTSCconvert_24pfilter.changefps(outnum/2,outden) : 
\ (blend==true)? NTSCconvert_24pfilter.blendfps(50,1.25).changefps(outnum,outden).interlace(order=1):
\ NTSCconvert_24pfilter.changefps(outnum,outden).interlace(order=1)

NTSCconvert_60i
eval(filter)

interlace(order=1)
global NTSCconvert_60i = last

NTSCconvert_30p
eval(filter)
#mode==1? last : last.interlace(order=1)
global NTSCconvert_30p = last


global NTSCconvert_data 		= data.assumetff().blendfps(outnum/float(outden*2),2.).changefps(outnum/2,outden)
#global NTSCconvert_data 		= data.changefps(outnum/2,outden)
#global NTSCconvert_data 		= data.assumetff().medianblurt(0,0,2).changefps(outnum/2,outden)

global NTSCconvert_red		= blankclip(NTSCconvert_data,color=$ff0000)
global NTSCconvert_green	= blankclip(NTSCconvert_data,color=$00ff00)
global NTSCconvert_blue		= blankclip(NTSCconvert_data,color=$0000ff)

global NTSCconvert_isred	= mt_lutxy(NTSCconvert_red,NTSCconvert_data,yexpr="x y - abs",y=3,u=1,v=1)
global NTSCconvert_isgreen	= mt_lutxy(NTSCconvert_green,NTSCconvert_data,yexpr="x y - abs",y=3,u=1,v=1)

mode==1? scriptclip(NTSCconvert_24p,"yplanemax(NTSCconvert_isred)==0 ? NTSCconvert_24p : NTSCconvert_60i") : scriptclip(NTSCconvert_24p,"yplanemax(NTSCconvert_isred)==0 ? NTSCconvert_24p : yplanemax(NTSCconvert_isgreen)==0 ? NTSCconvert_30p : NTSCconvert_60i")
speedup==true? last.assumefps(25,true).SSRC(48000) : last

show==true? overlay(last,data.changefps(outnum/2,outden)) : last
assumetff()

c.height==576? c : last
trim(0,c.changefps(outnum/2,outden).framecount())
}
__________________
sucking the life out of your videos since 2004
Mug Funky is offline   Reply With Quote
Old 19th February 2009, 06:19   #53  |  Link
Mug Funky
interlace this!
 
Mug Funky's Avatar
 
Join Date: Jun 2003
Location: i'm in ur transfers, addin noise
Posts: 4,555
...and the support functions (please append this to the last lot in a .avsi file)
Code:

function NTSCfilter (clip c, clip data, string filter, bool "show")
{

show=default(show,false)
order = c.getparity()==true? 1 : 0
bobbed = c.assumeframebased().leakkernelbob(order=order,threshold=2)

bobbed.selecteven()
eval(filter)
evn=last
bobbed.selectodd()
eval(filter)
odd=last
interleave(evn,odd)
interlace(order=order)
global NTSCfilter_60i = last

c
eval(filter)
global NTSCfilter_30p = last

c.tdeint(2,1,tryweave=true,cthresh=2,mi=24,mtnmode=1,mthreshl=2).decimate()
eval(filter)
changefps(c.framerate*2).interlace(order=order)
global NTSCfilter_24p = last

global NTSCfilter_data  = data

global NTSCfilter_red   = blankclip(NTSCfilter_data,color=$ff0000)
global NTSCfilter_green = blankclip(NTSCfilter_data,color=$00ff00)

global NTSCfilter_isred   = mt_lutxy(NTSCfilter_red,NTSCfilter_data,yexpr="x y - abs",y=3,u=1,v=1)
global NTSCfilter_isgreen = mt_lutxy(NTSCfilter_green,NTSCfilter_data,yexpr="x y - abs",y=3,u=1,v=1)

scriptclip(NTSCfilter_30p,"yplanemax(NTSCfilter_isred)==0 ? NTSCfilter_24p : yplanemax(NTSCfilter_isgreen)==0 ? NTSCfilter_30p : NTSCfilter_60i")

show==true? overlay(last,NTSCfilter_data) : last
}


function NTSC120 (clip c, clip data, bool "show")
{

show=default(show,false)
order = c.getparity()==true? 1 : 0
bobbed = c.tdeint(1,order,expand=4,mi=24,cthresh=8,mthreshl=8,tryweave=true).vinverse()#leakkernelbob(order=order,threshold=2)


global NTSCfilter_60i = bobbed.changefps(120000,1001)
global NTSCfilter_30p = c.changefps(120000,1001)
global NTSCfilter_24p = bobbed.decimate().changefps(120000,1001)

global NTSCfilter_data  = data.changefps(120000,1001)

global NTSCfilter_red   = blankclip(NTSCfilter_data,color=$ff0000)
global NTSCfilter_green = blankclip(NTSCfilter_data,color=$00ff00)

global NTSCfilter_isred   = mt_lutxy(NTSCfilter_red,NTSCfilter_data,yexpr="x y - abs",y=3,u=1,v=1)
global NTSCfilter_isgreen = mt_lutxy(NTSCfilter_green,NTSCfilter_data,yexpr="x y - abs",y=3,u=1,v=1)

scriptclip(NTSCfilter_30p,"yplanemax(NTSCfilter_isred)==0 ? NTSCfilter_24p : yplanemax(NTSCfilter_isgreen)==0 ? NTSCfilter_30p : NTSCfilter_60i")

show==true? overlay(last,NTSCfilter_data) : last
}


function NTSCtoFPS (clip c, clip data, int "num", int "den", int "th_bob", bool "show", string "filter", int "deblocker",int "IVTCtype", int "reset")
{

num=default(num,24000)
den=default(den,1001)

th_bob=default(th_bob,2)
show=default(show,false)
filter = default(filter,"last")
deblocker = default(deblocker,0)
IVTCtype = default(IVTCtype,3)	# 1 = telecide, 2 = tfm(chroma=true), 3 = tfm(), 4 = tdeint(mode=2) 5 = smartdecimate
reset = default(reset,50)

order = c.getparity()==true? 1 : 0

d = deblocker==0? c : c.converttoyv12(interlaced=true).deblocker(quant=deblocker,ipp=true)
d = d.converttoyv12(interlaced=true)

global bobbed = d.tdeint(1,order,expand=4,mthreshl=th_bob)
sdbob = d.tdeint(1,order,expand=4,mi=24,cthresh=8,mthreshl=th_bob,tryweave=true)

NTSCtoFPS_60i = bobbed.vinverse().converttoyv12(interlaced=false).salfps(num/float(den),protection2=60,reset=reset).changefps(num,den)
NTSCtoFPS_30p = d.converttoyv12().vinverse().salfps(num/float(den),protection2=50,reset=reset).changefps(num,den)

IVTCtype==1? d.telecide(order=order,guide=1).decimate() :\
IVTCtype==2? d.tfm(order=order,pp=0,chroma=true).decimate() :\
IVTCtype==3? d.tfm(order=order,pp=0,chroma=false).decimate() :\
IVTCtype==4? d.tdeint(2,-1,expand=4,tryweave=true,cthresh=3,mi=24,mthreshl=8,chroma=true).decimate() :\
d.smartdecimate(24,60,bob=sdbob,tel=1.)

vinverse()

eval(filter)

salfps(num/float(den),protection2=50).changefps(num,den)

global NTSCtoFPS_24p = last


NTSCtoFPS_60i
eval(filter)

global NTSCtoFPS_60i = last

NTSCtoFPS_30p
eval(filter)

global NTSCtoFPS_30p = last


global NTSCtoFPS_data 		= data.assumetff().blendfps(num/float(den),2.).changefps(num,den)

global NTSCtoFPS_red		= blankclip(NTSCtoFPS_data,color=$ff0000)
global NTSCtoFPS_green	= blankclip(NTSCtoFPS_data,color=$00ff00)
global NTSCtoFPS_blue		= blankclip(NTSCtoFPS_data,color=$0000ff)

global NTSCtoFPS_isred	= mt_lutxy(NTSCtoFPS_red,NTSCtoFPS_data,yexpr="x y - abs",y=3,u=1,v=1)
global NTSCtoFPS_isgreen	= mt_lutxy(NTSCtoFPS_green,NTSCtoFPS_data,yexpr="x y - abs",y=3,u=1,v=1)

scriptclip(NTSCtoFPS_24p,"yplanemax(NTSCtoFPS_isred)==0 ? NTSCtoFPS_24p : yplanemax(NTSCtoFPS_isgreen)==0 ? NTSCtoFPS_30p : NTSCtoFPS_60i")

show==true? overlay(last,NTSCtoFPS_data) : last
assumetff()

c.height==576? c : last
}


function resizetopal (clip c, bool "soft", bool "speedup")
{
soft=default(soft,false)
speedup=default(speedup,true)

soft==false? c.addborders(0,2,0,2).lanczosresize(c.width,576,0,2+(c.height-483.84)/2,c.width,483.84) : c.addborders(0,2,0,2).bicubicresize(c.width,576,1,0,0,2+(c.height-483.84)/2,c.width,483.84)
speedup==true? last.assumefps(25,true).SSRC(48000) : last
c.height==576? c : last
}

function interlace (clip interlace_c, int "order")
{
order=default(order,1)
interlace_d= interlace_c.framecount()%2==0? interlace_c : interlace_c.assumefps(interlace_c.framerate)++interlace_c.selectevery(interlace_c.framecount,interlace_c.framecount-1).assumefps(interlace_c.framerate)
order==1? interlace_d.assumeframebased().assumetff().separatefields().selectevery(4,0,3).weave() :
\	interlace_d.assumeframebased().assumebff().separatefields().selectevery(4,0,3).weave()
}


function deblocker (clip c,int "quant",int "th",int "radius", bool "deblock",bool "depump",bool "conv",bool "ipp",int "modh", int "modv")
{

quant=default(quant,8)
th=default(th,3)
radius=default(radius,8)
deblock=default(deblock,true)
depump=default(depump,false)
conv=default(conv,false)
ipp=default(ipp,false)
modh=default(modh,20)
modv=default(modv,40)

c = (c.width*c.height%256==0)? c : mod16(c)#.limiter()

blurd = (conv==true)?c.wideblur(4,conv): (depump==true)? c.bilinearresize(4*(c.width/8),4*(c.height/8)) : c.bilinearresize(4*(c.width/8),4*(c.height/8)).bicubicresize(c.width,c.height,1,0)

highpass=(conv==true)?mt_makediff(blurd,c,y=3,u=3,v=3): (depump==true)? mt_makediff(blurd.bicubicresize(c.width,c.height,1,0),c,y=3,u=3,v=3) : mt_makediff(blurd,c,y=3,u=3,v=3)
deblocked=(deblock==true) ? highpass.blindpp(quant=quant,cpu=4,ipp=ipp,moderate_h=modh,moderate_v=modv) : highpass

nopump=mt_makediff(blurd,deblocked,y=3,u=3,v=3)

depumped=blurd.temporalsoften(2,th,th,32,2)#.removedirt()

pump=(conv==true)?mt_makediff(depumped,deblocked,y=3,u=3,v=3):mt_makediff(depumped.bicubicresize(c.width,c.height,1,0),deblocked,y=3,u=3,v=3)

(depump==true) ? pump : nopump

(c.width*c.height%256==0)? last : unmod16(last)
}

function combblur(clip c, int threshold)
{
mt_merge(c.mt_convolution("1","1 2 1",y=3,u=3,v=3).mt_convolution("1","-1 6 -1",y=3,u=3,v=3),c,c.combmask(threshold,threshold,y=3,u=3,v=3).mt_expand(mode=mt_rectangle(0,1),y=3,u=3,v=3).mt_inflate(y=3,u=3,v=3),y=3,u=3,v=3)
}


function salblendfps(clip c, float fps, float "aperture")
{
aperture = default(aperture,1.)

c.changefps(8*fps).temporalsoften(round(8*aperture),255,255,24).selectevery(8,0)
}
__________________
sucking the life out of your videos since 2004
Mug Funky is offline   Reply With Quote
Old 19th February 2009, 08:36   #54  |  Link
Floatingshed
Registered User
 
Join Date: Nov 2008
Posts: 324
Great, thanks. Can't wait to get home and have a play. On a twelve hour Tx shift so it'll be a while!
Floatingshed is offline   Reply With Quote
Old 19th February 2009, 23:20   #55  |  Link
Floatingshed
Registered User
 
Join Date: Nov 2008
Posts: 324
Oops, no joy at all:

Avisynth open failure
Evaluate: system exception - integer overflow
(C:\Program Files\AviSynth 2.5\plugins\vinverse.avsi, line 14)
(C:\Program Files\AviSynth 2.5\plugins\NTSC tools 0.96\ntsc096.avsi, line 189)
(C:\Program Files\AviSynth 2.5\plugins\NTSC tools 0.96\ntsc096.avsi, line 40)

Any thoughts?
Thanks.

edit... tried the dll of vinverse too, not sure which version is required. Same result.

Last edited by Floatingshed; 19th February 2009 at 23:35.
Floatingshed is offline   Reply With Quote
Old 19th February 2009, 23:48   #56  |  Link
Mug Funky
interlace this!
 
Mug Funky's Avatar
 
Join Date: Jun 2003
Location: i'm in ur transfers, addin noise
Posts: 4,555
argh. another one

hang on, i don't have any good NTSC stuff to check this out on at the moment (just a couple of VHS captures for a friend - too jittery for meaningful results i think). i'll just simulate some.

if you could run autopal with "show=true", and let me know what colour the little spot in the top left is just on the frames that are failing. that way i'll know which part of the script to look at (red is for "i think this is film" and blue is for "this doesn't look like film, i'll treat it as 60i").

i'm also thinking of some possible speed boosts when using motion compensation, but please bear in mind i'm quite short of NTSC samples at the moment, especially stuff with mixed timebases (working with film is great - no need to worry about mixing things up - it's all progressive 25fps off the telecine)

[edit]
btw, i don't recommend using "threads" at the moment - it's broken and just there for testing. i forgot it was still in there

[edit 2]

@ floatingshed: dll version is required. make sure you move the avsi version out of the way so avisynth doesn't try to load both. though they should both work, the dll is faster.

[edit 3]

poos. i can't replicate this bug. apologies. i'll go check the date-stamps on my plugins and we can compare, k?

[edit 4]

plugins: (dated yyyy-mm-dd)

decomb521.dll (dated 2004-5-18)
leakkerneldeint.dll (dated 2005-1-18)
tdeint.dll (dated 2007-01-22)
vinverse.dll (dated 2006-11-04)
Motion_12Dec05.dll (dated, obviously, 2005-12-12)
SmartDecimate.dll (dated 2006-10-25)

also, there's a couple of script functions used internally that weren't included in the package maybe. "blackpal" simply makes black pal video of the desired length. "salfps" is called when motion-compensated conversion is used (by default it's off).

here they are:

Code:
function salFPS(
 \ clip input, float FPS, 
 \ int "mode", int "protection", int "protection2",
 \ int "iterate", int "reset", int "initialise", bool "interlaced")
{
mode       = default(mode, warp)#warpfast)
protection = default(protection, 80)
protection2 = default(protection2, 32)
iterate    = default(iterate, 2)
reset      = default(reset, 50)
initialise = default(initialise, 6)
interlaced = default(interlaced,false)

originalFPS = input.framerate()
input

mp    = FindMotion(iterate = iterate, reset = reset,
 \       initialise = initialise)
p     = MotionFPS(FPS,mode,Motion = mp)
maskp = mp.SumStretchFPSMask(FPS, protection)

mn    = FindMotion(iterate = iterate, reset = reset,
 \       initialise = initialise, from = next)
n     = MotionFPS(FPS,mode,Motion = mn, source = next)
maskn = mn.SumStretchFPSMask(FPS, protection, source = next)

maskp
assumeFPS(originalFPS)

tehmask=last.CombineFPS(FPS, maskp, maskn)
last.CombineFPS(FPS, maskp, maskn.Invert())
bilinearresize(width*8, height*8)
crop(0, 0, input.width(), input.height())
fity2uv()
mpro=last

tehmask
mt_deflate()
mt_binarize(protection2,false)
temporalsoften(1,255,255,255)
mt_binarize(80,false)
mt_expand(mode=mt_circle(3))
mt_inflate()
bicubicresize(width*8, height*8,1,0)
crop(0, 0, input.width(), input.height())
fity2uv()
tehmask=last
mt_merge(p, n, mpro, u=3, v=3)

interlaced==false? mt_merge(last,input.blendfps(FPS,aperture=FPS/float(input.framerate())),tehmask, u=3,v=3) :
\	mt_merge(last.changefps(FPS,false).selectevery(1,0,0),input.blendfps(2*FPS,aperture=FPS/float(input.framerate())),tehmask, u=3,v=3).interlace()
#merge(last,tehmask.greyscale(),.5)
}


function blackPAL (int "length", int "colour")
{
length = default(length,250)
colour = default(colour,$000000)

blankclip(width=720,height=576,fps=25000,fps_denominator=1000,pixel_type="yv12",length=length,audio_rate=48000,stereo=true,color=colour)
}


best of luck!... my plugins folder is in a bit of a shambles, so i'll have to clean this all up and re-release at some point just to be fair to anybody actually trying to use it
__________________
sucking the life out of your videos since 2004

Last edited by Mug Funky; 20th February 2009 at 00:33.
Mug Funky is offline   Reply With Quote
Old 20th February 2009, 08:08   #57  |  Link
Floatingshed
Registered User
 
Join Date: Nov 2008
Posts: 324
Morning!
The colour in the corner of error frames is red using version 0.93.
I can't load version 0.96 into VDub without getting the failure error (above).
A couple of plugins needed different versions. Result: Same errors as before (minus the mention of vinverse):

Avisynth open failure
Evaluate: system exception - integer overflow
(, line 14)
(C:\Program Files\AviSynth 2.5\plugins\Autopal096.avsi, line 189)
(C:\Program Files\AviSynth 2.5\plugins\Autopal096.avsi, line 40)

Last edited by Floatingshed; 27th February 2009 at 18:20.
Floatingshed is offline   Reply With Quote
Old 27th February 2009, 18:21   #58  |  Link
Floatingshed
Registered User
 
Join Date: Nov 2008
Posts: 324
@: mugfunky

Any more thoughts? Thanks.
Floatingshed is offline   Reply With Quote
Old 2nd March 2009, 08:28   #59  |  Link
Mug Funky
interlace this!
 
Mug Funky's Avatar
 
Join Date: Jun 2003
Location: i'm in ur transfers, addin noise
Posts: 4,555
eeks. um... maybe post a sample? red spot means frames detected as film. so something's going wrong there. the only problem is it works at my end

sorry about the late reply. work is mad - sometimes i've got time to post, other times i'm here until the wee hours.
__________________
sucking the life out of your videos since 2004
Mug Funky is offline   Reply With Quote
Old 4th March 2009, 23:16   #60  |  Link
Floatingshed
Registered User
 
Join Date: Nov 2008
Posts: 324
I'm not sure that a sample would help as the problem is not dependent on the clip, it occurs with every piece of video that I load!

Great shame that it won't work for me it seems so promising.
Floatingshed 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 23:40.


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