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. |
25th December 2004, 22:21 | #1 | Link |
Registered User
Join Date: Oct 2003
Location: Porto Alegre, Brazil
Posts: 13
|
Applyrange calling function with global
My intention is to get rid of flashes in a show ("David Gilmour in concert"). After some experiments that didn't satisfy me, I'm trying Depan to fix the affected fields before deinterlacing with Alignfields. This show has a lot of flashes that I noted down, and will be fixed by calling a function. Usually 3 fields are affected.
Code:
function flash (clip f, int "first", int "qty") { global first = first # first affected field of the range global qty = qty # number of affected fields to fix # It copies the last and next good fields to the previous and # current ones so that Depan can do its job. scriptclip(f,""" x= freezeframe(current_frame -1,current_frame -1,first -1) y= x.freezeframe(current_frame,current_frame,first + qty) d= y.DePanEstimate(improve=true,zoommax=1.4) offs= 1. / ( qty + 1.) * (current_frame - first + 1.) DePan(x, data=d, offset=offs,info=true) subtitle (" current_frame="+string(current_frame)+ \ " first="+string(first)+ \ " offset="+string(offs), \ " qty="+string(qty),y=200) """) } avisource("f:\david gilmour\show.avi",audio=false) assumetff() ###alignfields(fps2=true,mode=0) ibob() showframenumber(scroll=true) applyrange (157177,157179,"flash",157177,3) applyrange (37115,37117,"flash",37115,3) applyrange (6713,6715,"flash",6713,4) the variables first and qty keep the value from the last "applyrange" of the script! For instance, in the sequence above the value for "first" will be 6713 for all instances of applyrange. The only way I know for passing the parameters to the scriptclip is this one. I appreciate if someone could think of a workaround. There are about 100 flashes to clean. PS: I suggest comment Depan in order to run this script, because the value for "offset" will be absurd (30093 for the range 157177).
__________________
Athlon XP2400;a7v333;768mb PC2100;Seagate 80Gb;AIW8500;DVD musica do mundo - my favourite radio program, check it! |
25th December 2004, 23:34 | #2 | Link |
AviSynth Enthusiast
Join Date: Jul 2002
Location: California, U.S.
Posts: 1,267
|
Re: Applyrange calling function with global
Yeah, that's pretty much what you can expect when you can expect when using global variables. It's not a problem with ApplyRange.
You can think of script evaluation as being in two stages: 1. Script load. 2. Exuection/frame requests. When the script is loaded, AviSynth parses the script, evaluates expressions, and creates the filter chains. This means that it calls the "flash" function three times when the script is loaded, before it ever requests a frame. By the time you request frames, your global variables have been set to their final values already. (I really do not like this global variable business with ScriptClip/FrameEvalute/et al., but oh well.) And none of that really helps you. Heh. I suppose a possible workaround to try: Code:
function flash(clip f, int "first", int "qty") { return ScriptClip(f, "first = " + String(first) \ + "qty = " + String(qty) \ + """x = FreezeFrame(...) y = x.FreezeFrame(...) ...""") } |
26th December 2004, 00:47 | #3 | Link |
Registered User
Join Date: Aug 2004
Location: Denmark
Posts: 807
|
you could try this scriptclip instead:
Code:
scriptclip(f,""" x= freezeframe(current_frame -1,current_frame -1,first -1) y= x.freezeframe(current_frame,current_frame,first + qty) d= y.DePanEstimate(improve=true,zoommax=1.4) offs= 1. / ( qty + 1.) * (current_frame - first + 1.) DePan(x, data=d, offset=offs,info=true) subtitle (" current_frame="+string(current_frame)+ \ " first="+string(first)+ \ " offset="+string(offs), \ " qty="+string(qty),y=200) """,after_frame=true) |
19th January 2005, 00:10 | #4 | Link |
Registered User
Join Date: Oct 2003
Location: Porto Alegre, Brazil
Posts: 13
|
I hope it's never too late to thank
The script that worked is this. I made an AVSI and put it in the plugin directory: Code:
function applyflash(clip a, int fn, int qt) {a eval ("""applyrange (fn,fn+qt-1,"flash",fn,qt)""")} function flash (clip f, int "first", int "qty") { scriptclip(f,"first = "+string(first) +chr(13)+ \ "qty = " +string(qty) +chr(13)+ \ """x= freezeframe(current_frame -1,current_frame -1,first -1) Y= x.freezeframe(current_frame,current_frame,first + qty) d= y.DePanEstimate(improve=true,zoommax=1.4) offs= 1. / ( qty + 1.) * (current_frame - first + 1.) DePan(y, data=d, offset=offs,info=false) #subtitle (string(offs)+" "+string(first)+" "+string(qty),y=200) #stackhorizontal(x.trim(current_frame - 1,-1).crop(0,0,360,0),y.crop(360,0,0,0)) """)} Code:
avisource("f:\xxx.avi",audio=false) assumetff() alignfields(fps2=true,mode=0) #showframenumber(scroll=true) applyflash(271,3) applyflash(288,2) applyflash(703,2) ... AssumeTFF().SeparateFields().SelectEvery(4,0,3).Weave() alignfields(mode=3,scene=3) Your help was unvaluable. Thank you guys! Cecilia
__________________
Athlon XP2400;a7v333;768mb PC2100;Seagate 80Gb;AIW8500;DVD musica do mundo - my favourite radio program, check it! |
Thread Tools | Search this Thread |
Display Modes | |
|
|