Hi,
First, sorry for my bad english.
I'm trying to do an avisynth function and i have a crash when i use it (no error log).
Here is the code :
This function should make an overlay on a video with a transparent PNG file and make this overlay appears only after "start" and before "end" with fading in and out.Code:function Incruster(clip film, string "image", int "abs", int "ord", int "start", int "end", float "fade") { fps=film.FrameRate fade=Default(fade, 0) fade=Round(fps*fade) incrust=ImageSource(image, pixel_type="RGB32") film1=film.Trim(0, start-1) film2=film.Trim(start, end) film3=film.Trim(end+1, film.FrameCount-1) film2b=Overlay(film2,incrust,mask=incrust.ShowAlpha().Trim(start,end).FadeIO0(fade),x=abs,y=ord) v=film1++film2b++film3 return(v) }
And this is the script i use for avsproxy :
Can anyone tell me what's wrong ?Code:film=AVISource("C:\01.avi") film=film.Incruster(image="C:\01.png", abs=0, ord=0, start=1000, end=3000, fade=1.5)
+ Reply to Thread
Results 1 to 9 of 9
-
-
Does it work if you open it in a media player or VirtualDub?
Add "return(film)". Otherwise AviSynth will attempt to return last (the default video name).
film=AVISource("C:\01.avi")
film=film.Incruster(image="C:\01.png", abs=0, ord=0, start=1000, end=3000, fade=1.5)
return(film)Last edited by jagabo; 2nd Jun 2011 at 19:38.
-
Hum, now there is still one problem. Here it is :
I want to display an overlay from frame 1000 to frame 3000 so here is my AVS script :
Code:film=AVISource("C:\01.avi") film=film.Incruster(image="C:\01.png", abs=0, ord=0, start=1000, end=3000, fade=1.5, verbose=true) return(film)
Code:function Incruster(clip film, string "image", int "abs", int "ord", int "start", int "end", float "fade", bool "verbose") { fps=film.FrameRate fade=Default(fade, 0) fade=Round(fps*fade) incrust=ImageSource(image, pixel_type="RGB32") film1=film.Trim(0, start-1) film2=film.Trim(start, end) film3=film.Trim(end+1, film.FrameCount-1) film2b=Overlay(film2,incrust,mask=incrust.ShowAlpha().FadeIO0(fade),x=abs,y=ord) v=film1++film2b++film3 verbose = Default(verbose, false) v = verbose ? v.Show(start, end, abs, ord, fade) : v return(v) } function Show (clip v, int "start", int "end", int "abs", int "ord", int "fade") { i = 10 v= v.subtitle("Overlay from "+start.string +" to "+end.string, 10,i) i = i+20 v = v.subtitle("Display (x,y) = ("+abs.string +","+ord.string+")", 10,i) i = i+20 v = v.subtitle("Fading = "+fade.string+" frame(s)", 10,i) return(v) }
Overlay from 1000 to 3000
Display (x,y) = (0,0)
Fading = 36 frame(s)
Now, in fact, overlay really appears from frames 1000 to 2000 and i don't know why...Last edited by Khyinn; 3rd Jun 2011 at 03:30. Reason: remove useless code
-
That's because ImageSource by default gives you a clip of 1001 frames.
Change the definition of incrust to:
incrust=ImageSource(image, pixel_type="RGB32", start=start, end=end)
Incidentally, your function suffers from a common problem when using Trim with variable arguments - it will not work if called with start=1 (can you see why?).
Replace
film1=film.Trim(0, start-1)
by
film1=film.Trim(0, -start)
Actually, it won't work for start=0 either, or ending at the last frame.
If those cases may be required, you need to add extra logic to handle them.
The solution is correct, but the explanation is not.
It's a common myth that 'last' is returned by default. If the last statement is an assignment, a void value (equivalent to a defaulted parameter) is returned, even if 'last' was previously set. -
Thank you so much Gavino for all your explanations, now it works as intended.
Don't need to start at 0 or ending on the last frame but if you have time to modify this function for those who need this, please do it.
Here is my final function :
Code:function Incruster(clip film, string "image", int "abs", int "ord", int "start", int "end", float "fade", bool "verbose") { fps=film.FrameRate fade=Default(fade, 0) fade=Round(fps*fade) incrust=ImageSource(image, pixel_type="RGB32", start=start, end=end) film1=film.Trim(0, -start) film2=film.Trim(start, end) film3=film.Trim(end+1, 0) film2b=Overlay(film2,incrust,mask=incrust.ShowAlpha().FadeIO0(fade),x=abs,y=ord) v=film1++film2b++film3 verbose = Default(verbose, false) v = verbose ? v.Show(start, end, abs, ord, fade) : v return(v) } function Show (clip v, int "start", int "end", int "abs", int "ord", int "fade") { i = 10 v= v.subtitle("Overlay from "+start.string +" to "+end.string, 10,i) i = i+20 v = v.subtitle("Display (x,y) = ("+abs.string +","+ord.string+")", 10,i) i = i+20 v = v.subtitle("Fading = "+fade.string+" frame(s)", 10,i) return(v) }
-
-
Thanks, so the really really final function :
Code:function Incruster(clip film, string "image", int "abs", int "ord", int "start", int "end", float "fade", bool "verbose") { fps=film.FrameRate fade=Default(fade, 0) fade=Round(fps*fade) incrust=ImageSource(image, pixel_type="RGB32", start=start, end=end) film1=film.Trim(0, -start) film2=film.Trim(start, end) film3=film.Trim(end+1, 0) film2b=Overlay(film2,incrust,mask=incrust.ShowAlpha().FadeIO0(fade),x=abs,y=ord) v = start > 0 ? film1++film2b : film2b v = end+1 < film.Framecount ? v++film3 : v verbose = Default(verbose, false) v = verbose ? v.Show(start, end, abs, ord, fade) : v return(v) } function Show (clip v, int "start", int "end", int "abs", int "ord", int "fade") { i = 10 v = v.subtitle("Overlay from "+start.string +" to "+end.string, 10,i) i = i+20 v = v.subtitle("Display (x,y) = ("+abs.string +","+ord.string+")", 10,i) i = i+20 v = v.subtitle("Fading = "+fade.string+" frame(s)", 10,i) return(v) }
-
Similar Threads
-
AVISynth function to darken an area
By kinglerch in forum EditingReplies: 13Last Post: 9th Apr 2012, 17:26 -
Avidemux Scripting: some wanted information!
By klode in forum Video ConversionReplies: 0Last Post: 21st Aug 2011, 00:24 -
AviSynth: No function named LeakKernelDeint
By user2008 in forum Video ConversionReplies: 4Last Post: 23rd May 2010, 16:42 -
AVIsynth: is there such a function like repeat/until or for/next ?
By vhelp in forum EditingReplies: 4Last Post: 8th May 2010, 05:20 -
AviSynth function to add SUP subtitles?
By MilesAhead in forum SubtitleReplies: 11Last Post: 3rd Feb 2010, 13:16