Log in

View Full Version : Using Layer, Mask


Zarxrax
13th November 2002, 23:44
I've read the documentation, and experimented for about an hour, but I couldn't get anything working. I am making a video clip in Adobe Premiere that I want to overlay on top of a video in avisynth. However I can't figure out exactly what I need to do with avisynth. The overlay clip will just be some text, and I can make any color background behind it that it needs. Im simply wanting to overlay this text on top of my video. Can anyone help me out?

Asmodian
14th November 2002, 01:47
I have no idea about Premiere but I believe you could get something working with vobsub and making your own sub station alpha (ssa) files to display the text. (unless you want to do something very exotic with the text, sub station alpha can do most things like font and color).

Could you save the video from avisynth with virtual dub and then merge it in Premiere? (can Premiere do that?)

wotef
14th November 2002, 01:50
clip1=avisource("baseclip.avi")
clip2=avisource("text.avi")
clip3=layer(clip1,clip2,"add",128,use_chroma=true)
return clip3

what's the problem?

Zarxrax
14th November 2002, 04:21
@wote: I'm trying it exactly like what you wrote there, but nothing is happening!

Here is my script i'm using:

LoadPlugin("decomb.dll")
clip1=AVISource("C:\file1.avi").convertToRGB32()
clip2=AVISource("c:\file2.avi").decimate()
clip3=layer(clip1,clip2,"add",128,use_chroma=true)
return clip3

wotef
14th November 2002, 06:35
two possible points of weirdness - take them away and see what happens

why are you using decimate without a prior telecide?
why are you converting one clip to rgb32?

Zarxrax
14th November 2002, 07:33
The video is 23.976fps, and is not in rgb32 format (which I believe it has to be in for layer to work, doesnt it?)
The overlay clip is 29.97fps progressive, and is in rgb32 format already.

Richard Berg
14th November 2002, 08:25
Layer works in both YUY2 and RGB, but the clips have to be in the same format. Let me know if the filter isn't flagging this condition correctly and I'll fix it.

wotef
14th November 2002, 10:19
colourspace format assertions are definitely working in 2.06

zarxax, it's not clear what is meant by "nothing is happening" - i take it you're not getting an error message AND that you are using 2.06?

otherwise try this:

LoadPlugin("decomb.dll")
clip1=AVISource("yuy.avi").convertToRGB32()
clip2=AVISource("rgb.avi").decimate().converttorgb32()
clip3=layer(clip1,clip2,"add",128,use_chroma=true)
return clip3

Wilbert
14th November 2002, 10:49
It can be that the background avi is already in rgb32. So nothing happings when using ConvertToRGB32 (meaning that no mask is created). Try the following:

LoadPlugin("decomb.dll")
clip1 = AVISource("yuy.avi").ConvertToRGB32
clip2 = AVISource("rgb.avi").Decimate.ConvertToYUY2.ConvertToRGB32
Layer(clip1, clip2, "add", 128, use_chroma=true)

or use a mask:

LoadPlugin("decomb.dll")
clip1 = AVISource("yuy.avi").ConvertToRGB32
clip2 = AVISource("rgb.avi").Decimate
clip3 = Mask(clip2, BlankClip(clip2, color=$FFFFFF))
Layer(clip1, clip3, "add", 128, use_chroma=true)

Zarxrax
14th November 2002, 20:57
Alright, it works now with the script
LoadPlugin("decomb.dll")
clip1 = AVISource("yuy.avi").ConvertToRGB32
clip2 = AVISource("rgb.avi").Decimate.ConvertToYUY2.ConvertToRGB32
Layer(clip1, clip2, "add", 128, use_chroma=true)

It also works if i use convertToYUY2 instead of rgb32.

However I still can't quite get the effect I'm wanting. In my overlay clip, I want to completely have the background removed, so that only the text in the clip is overlayed onto the video, and I want the text to be fully opaque. How could I go about doing this? The background on my overlay clip is currently an AlphaChannel (transparent). I was messing around with ColorKeyMask just now, converting to making the background of the clip black and then keying it out, but this makes the edges blocky. I was hoping theres a way to just preserve the alpha channel and simply overlay this ontop of the video.

Richard Berg
14th November 2002, 22:34
You lost me. Which clip has the text? Which has the background? Which has the alpha channel? Which did you mess with ColorKeyMask?

Not sure why you're converting to YUY2 & back again, but note that doing so will erase your alpha channel.

Zarxrax
14th November 2002, 22:54
Clip1 is the video source that I want on the bottom.
Clip2 is the overlay clip. It is text against a transparent background.
If I try convert Clip 1 to rgb32 and try to layer clip 2 on it, it does not work. If I convert clip 2 so that it no longer has an alpha channel, then it works. I am trying to get it to work while preserving the alpha channel. By it doesnt work, I mean it just outputs clip one, there is nothing overlayed on it.

ErMaC
15th November 2002, 00:38
I'm also experimenting with Layer but for a different reason.

I want to be able to overlay an SSA script onto a video stream without changing it's colorspace. This is difficult, since the SSA plugin is a VirtualDub plugin and thus only runs in RGB space.

My original idea was to create a blankclip() in rgb32, put the subtitles on top of it with the SSA filter, convert the clip to YUY2, then use Layer() to combine it with the original video, thus preserving it's colorspace (or rather, keeping it in YUV since it'll still be converted from YV12 to YUY2 since Layer doesn't yet work with YV12 in the 2.5 alphas).

Does anyone have any idea how to do this? I thought about using a blue clip and colormasking.. but colormasking only works in RGB32 and once I convert to YUY2 the alpha channel is lost! What can I do, or is this idea just not feasable and I'm going to be stuck converting the video stream to RGB for adding the subtitles?

Belgabor
15th November 2002, 00:49
@ErMaC: Why don't you use TextSub from the VobSub package as subtitle filter? This is native AviSynth&YUY2.

Cheers
Belgabor

ErMaC
15th November 2002, 00:54
But will it do all the SSA functions like the VDub filter? Can it do proper antialiasing, changing colors, screen positioning, etc, like the vdub filter does?
The digisubbing group I'll be working with will be using the Vdub plugin for their styling/positioning reference. If TextSub can duplicate the SSA filter exactly, then I'll use it. But if it's different I'd rather try the layer method, if it's possible...
Is it possible?

Zarxrax
15th November 2002, 01:11
Ermac, textsub will make it look nearly exactly like the ssa plugin. Some line breaks might be a little different but as far as looks go its exactly the same. I'd recommend you use textsub anyways in order to use ASS format scripts, as they are much easier to work with.

You must have been out of fansubbing for a while now from the sounds of things ^^; Come talk to me on Efnet or ETG (nick Zarxrax) and I can help catch you up to speed on current fansubbing techniques.

wotef
15th November 2002, 04:01
dunno, maybe poptones would be able to explain what's going on...otherwise perhaps you should make some source available...or else it sounds like you'd be better off with your subtitle tools...

slk001
15th November 2002, 19:59
If you want to overlay your text onto the video, I believe that you have to use a MASK, because the program doesn't know where text or background starts and ends. To create a MASK, take your TEXT STREAM (I'm assuming that it is a video stream), and change the TEXT ONLY to BLACK, with everything else being white. As long as the TEXT STREAM and the MASK STREAM are the same length, there shouldn't be any sync issues. Here is a script that I use for menu creation:

LoadPlugin("e:\program files\mpeg2dec\mpeg2dec.dll")

mpeg2source("H:\MENUS\SINGA.D2V")

LEN=1250

vid1=trim(0,42)
vid2=trim(43,90)
vid3=trim(91,314)
vid4=trim(315,394)
vid5=trim(395,554)
vid6=trim(555,602)
vid7=trim(603,826)
vid8=trim(827,954)
vid9=trim(955,1018)
vid10=trim(1019,1104)
vid11=trim(1105,0)

v1_out=Bilinearresize(vid1,720,480,20,20,740,500)
v2_out=Bilinearresize(vid2,720,480,-40,-40,760,520)
v3_out=bilinearresize(vid3,720,480,20,10,740,490)
v4_out=bilinearresize(vid4,720,480,0,-20,720,460)
v5_out=bilinearresize(vid5,720,480,70,0,790,480)
v6_out=bilinearresize(vid6,720,480,-20,0,700,480)
v7_out=bilinearresize(vid7,720,480,-10,15,710,495)
v8_out=bilinearresize(vid8,720,480,-20,-25,700,455)
v9_out=bilinearresize(vid9,720,480,-60,0,660,480)
v10_out=bilinearresize(vid10,720,480,50,0,770,480)
v11_out=bilinearresize(vid11,720,480,-80,15,640,495)

vid=v1_out+v2_out+v3_out+v4_out+v5_out+v6_out+v7_out+v8_out+v9_out+v10_out+v11_out

OT=vid #bilinearresize(vid,720,480,-28,-20,892,540)

TOP=converttoRGB32(OT)

BASE=converttoRGB32(IMAGESEQUENCE("H:\MENUS\RED_V5_BG.BMP",1,1,24).loop(LEN))

MASK_CLIP=converttoRGB32(IMAGESEQUENCE("H:\MENUS\MENU_MASK_BG.BMP",1,1,24).loop(LEN))

overlay_clip=MASK(top,mask_clip)

out=layer(base,overlay_clip,"add",255,0,0,0)

converttoyuy2(out)

out2=fadeout2(out,42)

out3=reverse(fadeout2(reverse(out2),48))



Here is a sample of the TOP VIDEO:

slk001
15th November 2002, 20:01
Here is a sample of the BASE BITMAP (it is static):

slk001
15th November 2002, 20:02
Here's a sample of the MAIN_MASK:

slk001
15th November 2002, 20:03
And here's the final product. You have a video playing in the center surrounded by everything else static:

Zarxrax
15th November 2002, 21:14
Great! Thats just what im looking to do!