Log in

View Full Version : Problem trying to put a videoclip on top of another with Overlay()


Reino
10th May 2009, 22:11
Hello,

The situation:
I'd like to put a small videoclip on top of the original with fade-in-effects at a specific framerange.
This is my script so far:
a = AVISource("D:\video\video_1.avi").Lanczos4Resize(448,336).Trim(0,1926).ConvertToYV12()
b = AVISource("D:\video\video_2.avi").Lanczos4Resize(192,144).Trim(113,1744).Crop(1,1,-1,-1).AddBorders(1,1,1,1)
c = AVISource("D:\video_2.avi").Lanczos4Resize(192,144).Trim(113,1744).Crop(1,1,-1,-1).AddBorders(1,1,1,1).invert().FadeIO(50)

JDL_ReplaceRange(a,Overlay(a.Trim(111,0),b,x=250,y=6,mask=c),111,1744)
Because of Invert() and FadeIO(50) the small videoclip now emerges on top just as I intended, BUT after the fade-in, the small videoclip seems to be semi-transparant, which is NOT my intention.
I don't use Avisynth that much, but I have a hunch it has something to do with mask. What am I doing wrong?

Gavino
10th May 2009, 22:50
The mask controls the opacity, with black=transparent and white=opaque, so you want the mask to be basically white apart from the fade in and out.

I think you need to replace the definition of the mask c as follows:
c = BlankClip(b).Invert().FadeIO(50).ColorYUV(levels="tv->pc")

The levels="tv->pc" ensures the mask is in the full range 0-255.

Reino
10th May 2009, 23:25
Thanks a lot Gavino! That did the trick, but I don't quite understand why you added ColorYUV, because the end result in my clip is all YV12. Without ColorYUV everything looks great imo.

Gavino
11th May 2009, 00:12
I don't quite understand why you added ColorYUV, because the end result in my clip is all YV12. Without ColorYUV everything looks great imo.
The mask needs to be fully white (Y=255) in the middle part, and not limited to Y=235 as is usually the case for YV12 clips. If you look closely you will see that the overlaid clip is still very slightly transparent (about 8%) when you leave out the ColorYUV.

Reino
11th May 2009, 19:29
Nope, both clips are RGB32 originally, so I believe in my case I can leave out ColorYUV. I don't seem to notice any difference. But thanks anyway.

Gavino
11th May 2009, 19:42
OK, that's fine - I thought your clips were YV12.
If the mask (which here is based on clip b) is RGB, then there is no problem.