Log in

View Full Version : How to put an image on top of a video WITH framerange? (solved)


Reino
23rd August 2008, 15:41
Hello,

Let me illustrate the situation:
http://www.degeelebosch.nl/reino/intro_problem.png
I have a lot of small VOB-files that I want to glue all together (with transitions). On top of that, I'd like to add a masked image for ± 8seconds. But not from the beginning, but rather after 1 or 2 seconds. Or in other words; I'd like to apply a specific framerange on this image.

Let me first show the avisynth-script I'm using (not the entire video yet, just some video clips for testing):
a1=MPEG2Source("C:\myvideo\shot1.d2v").Bob().SelectEven()
a2=NicAC3Source("C:\myvideo\shot1.ac3")
a=AudioDub(a1,a2).FadeIn(75)

b1=MPEG2Source("C:\myvideo\shot2.d2v").Bob().SelectEven()
b2=NicAC3Source("C:\myvideo\shot2.ac3")
b=AudioDub(b1,b2)

c1=MPEG2Source("C:\myvideo\shot3.d2v").Bob().SelectEven()
c2=NicAC3Source("C:\myvideo\shot3.ac3")
c=AudioDub(c1,c2).Trim(0, 198)

d1=MPEG2Source("C:\myvideo\shot4.d2v").Bob().SelectEven()
d2=NicAC3Source("C:\myvideo\shot4.ac3")
d=AudioDub(d1,d2).FadeOut(75)

vid=a.Dissolve(b.Dissolve(c.Dissolve(d,10),10),10)
vid=vid.Lanczos4Resize(720,400).LimitedSharpenFaster()

title = ImageReader("C:\myvideo\image.png", 0, 0, 1, true)
titleMask = ImageReader("C:\myvideo\image2.png", 0, 0, 1, true).Loop(200).FadeIO(75)

JDL_ApplyRange(75,275, "Overlay(vid, title, mode="multiply", mask=titleMask)")So in short: video and sound from every shot is synchronized by AudioDub. Then all shots are combined (with transitions) after which the video will be resized and sharpened. After that I'm trying to put a masked image (also with transitions) on top of the video from frame 75 to 275, but here's where it goes wrong!

When I'm using: JDL_ApplyRange(75,275, "Overlay(vid, title, mode="multiply", mask=titleMask)"), the error message I get is expected a , or ), so I remove mode="multiply" as I'm certain that's what's causing the error message, but then I get the following error message: Invalid arguments to function "JDL_ApplyRange".
Can anyone help me out here?

Sagekilla
23rd August 2008, 15:47
You have to use triple quotes I believe, like this: JDL_ApplyRange(75,275,"""Overlay(vid,title,mode="multiply",mask=titleMask)""") because you're using quotes within quotes.

Reino
23rd August 2008, 16:06
No sorry, Invalid arguments to function "JDL_ApplyRange" again :(

Gavino
23rd August 2008, 16:09
You also need to provide a clip to JDL_ApplyRange (note that 'last' has not been set). Try:JDL_ApplyRange(vid,75,275,"""Overlay(title,mode="multiply",mask=titleMask)""")

Note: "Invalid arguments to function xxx" means there is a mismatch in the type or number of arguments passed. More often than not, it is because it is expecting a clip as its first argument, you have not supplied one, and there is no 'last' to fall back on.

Reino
23rd August 2008, 16:47
...
vid=a.Dissolve(b.Dissolve(c.Dissolve(d,10),10),10)
vid=vid.Lanczos4Resize(720,400)

global title = ImageReader("C:\myvideo\image.png", 0, 0, 1, true)
global titleMask = ImageReader("C:\myvideo\image2.png", 0, 0, 1, true).Loop(200).FadeIO(75)

JDL_ApplyRange(vid,75,275, """Overlay(title, mode="multiply", mask=titleMask)""")Thanks! Now (after I made "title" and "titleMask" global variables) I finally didn't receive errors anymore. And Sagekilla, you were right afterall about the triple quotes.

Now the image does appear at frame 75, BUT... the FadeIn has already occurred. At frame 200 the image has faded out completely, so the image still starts at the beginning! :confused:
Is JDL_ApplyRange the right filter to use?

Gavino
23rd August 2008, 17:12
Now the image does appear at frame 75, BUT... the FadeIn has already occurred. At frame 200 the image has faded out completely, so the image still starts at the beginning! :confused:
Is JDL_ApplyRange the right filter to use?
Thinking about it, JDL_ReplaceRange is more apropriate here.
JDL_ReplaceRange(vid,Overlay(vid.Trim(75,0),title,mode="multiply",mask=titleMask),75,275)

Now you can get rid of both the global variables and the triple quotes.

Reino
23rd August 2008, 18:29
Yes, finally! This is exactly what I was looking for.

JDL_ApplyRange: # Applies a filter to the specified range of frames in a clip.
JDL_ReplaceRange: # Replaces a range of frames from a clip with another clip.

Still a little bit confusing...I thought I needed "JDL_ApplyRange" to apply the filter "Overlay" to a specific framerange.
...Well anyway, it works like a charm now.
Thank you very much, Gavino! :goodpost:

For those interested, my avs-script at the moment:
a1=MPEG2Source("C:\myvideo\shot1.d2v").Bob().SelectEven()
a2=NicAC3Source("C:\myvideo\shot1.ac3")
a=AudioDub(a1,a2).FadeIn(75)

b1=MPEG2Source("C:\myvideo\shot2.d2v").Bob().SelectEven()
b2=NicAC3Source("C:\myvideo\shot2.ac3")
b=AudioDub(b1,b2)

c1=MPEG2Source("C:\myvideo\shot3.d2v").Bob().SelectEven()
c2=NicAC3Source("C:\myvideo\shot3.ac3")
c=AudioDub(c1,c2).Trim(0, 198)

d1=MPEG2Source("C:\myvideo\shot4.d2v").Bob().SelectEven()
d2=NicAC3Source("C:\myvideo\shot4.ac3")
d=AudioDub(d1,d2).FadeOut(75)

a.Dissolve(b.Dissolve(c.Dissolve(d,10),10),10)
Lanczos4Resize(720,400).LimitedSharpenFaster()

title = ImageReader("C:\myvideo\image.png", 0, 0, 1, true)
titleMask = ImageReader("C:\myvideo\image2.png", 0, 0, 1, true).Loop(200).FadeIO(75)
JDL_ReplaceRange(Overlay(Trim(75,0),title,mode="multiply",mask=titleMask),75,275)

Gavino
23rd August 2008, 20:27
Still a little bit confusing...I thought I needed "JDL_ApplyRange" to apply the filter "Overlay" to a specific framerange.
Yes, that's what I started out thinking. The problem is that JDL_ApplyRange produces the clip to be spliced in by applying the filter to the whole clip, then selecting the requested range from that. Usually that's what you want, but in the case of Overlay the start points don't line up as desired.

Interestingly, there is a JDL_ApplyRangeOld which would have done what you wanted as it works the other way round (splicing before filtering).

BTW Dissolve takes multiple clips at a time, so if you want the same overlap for each transition you can simply say
Dissolve(a, b, c, d, 10)

Reino
24th August 2008, 00:26
BTW Dissolve takes multiple clips at a time, so if you want the same overlap for each transition you can simply say
Dissolve(a, b, c, d, 10)Oh yes of course. Good call! Thanks again.