PDA

View Full Version : Avisynth Logo Filter


NoX1911
13th November 2003, 04:11
Hi,
im trying to create a script that watermarks a video (FadeIn,Stay,FadeOut) by .bmp or video with alpha channel. I didnt find a solution in the forum so maybe you can help me with it...

-------
FadeStart=50
FadeInLength=50
FadeRest=50
FadeOutLength=50

clip=AviSource("video.avi").ConvertToYuY2
pic=ImageReader("overlay.bmp").ConvertToYuY2

animate(FadeStart,FadeStart+FadeInLength-1,"Layer",clip,pic,"add",0, clip,pic,"add",255)
#animate(FadeStart+FadeInLength+FadeRest,FadeStart+FadeInLength+FadeRest+FadeOutLength,"Layer",clip,pic,"add",255, clip,pic,"add",0)

-------


The Problem is that 'animate' effects all frames and renders all other 'animate' lines useless so you can only use it once... I also tried 'trim' with no luck (same problem).
Any suggestions or alternatives?

mf
13th November 2003, 10:48
Originally posted by HeldImZelt
The Problem is that 'animate' effects all frames and renders all other 'animate' lines useless so you can only use it once... I also tried 'trim' with no luck (same problem).
Any suggestions or alternatives?
ApplyRange(Animate)

tempetai
13th November 2003, 10:55
Look at below script, maybe you can get some idea out of it.

function AddSmallClip(clip a, clip b,
\ int frm1, int frm2, int frm3, int frm4,
\ int x1, int y1,
\ int x2, int y2,
\ int x3, int y3,
\ int x4, int y4,
\ int "widthb1", int "heightb1",
\ int "widthb2", int "heightb2",
\ int "olystart", int "olyend")
{
a = IsRGB32(a)? a : ConvertToRGB32(a)
b = IsRGB32(b)? b : ConvertToRGB32(b)

x1 = default(x1,0)
x2 = default(x2,0)
x3 = default(x3,0)
x4 = default(x4,0)
y1 = default(y1,0)
y2 = default(y2,0)
y3 = default(y3,0)
y4 = default(y4,0)

widthb1 = default(widthb1,Width(b))
heightb1 = default(heightb1,Height(b))
widthb2 = default(widthb2,Width(b))
heightb2 = default(heightb2,Height(b))
olystart = default(olystart,0)
olyend = default(olyend,0)

a1 = Trim(a,0,frm1-1)
a2 = Trim(a,frm1,frm2-1)
a3 = Trim(a,frm2,frm3)
a4 = Trim(a,frm3+1,frm4)
a5 = Trim(a,frm4+1,0)

b = FrameCount(b) > frm4 - frm1? Trim(b,0,frm4-frm1) : b
b = FrameCount(b) > FrameCount(a)? Trim(b,0,FrameCount(a)-1) : b
b = FrameCount(b) <= frm4 - frm1? AddFrame(b,frm4-frm1) : b

b1 = Trim(b,0,frm2-1-frm1)
b2 = Trim(b,frm2-frm1,frm3-frm1)
b3 = Trim(b,frm3+1,0)

a2 = animate(0,framecount(a2)-1,"anme",a2,b1,olystart,x1,y1,widthb1,heightb1,a2,b1,255,x2,y2,widthb1,heightb1)
a3 = animate(0,framecount(a3)-1,"anme",a3,b2,255,x2,y2,widthb1,heightb1,a3,b2,255,x3,y3,widthb2,heightb2)
a4 = animate(0,framecount(a4)-1,"anme",a4,b3,255,x3,y3,widthb2,heightb2,a4,b3,olyend,x4,y4,widthb2,heightb2)

c = frm1 > 0? a1+a2 : a2
c = c + a3 + a4
c = (frm4 > 0) && (FrameCount(a) > frm4-frm1+1) && (FrameCount(a) != frm4+1)? c+a5 : c

return c
}

function anme(clip a,clip b,int "oly",int "x",int "y",int "widthb",int "heightb")
{
widthb=default(widthb,Width(b))
heightb=default(heightb,Height(b))
x=default(x,0)
y=default(y,0)
oly=default(oly,255)
b = (Width(b)!=widthb) && (Height(b)!=heightb)? BicubicResize(b,widthb,heightb):b
c=layer(a,b,"add",oly,x,y,0,true)
return c
}

function AddFrame(clip a,n_frm)
{
a = a + a
a = FrameCount(a) < n_frm? AddFrame(a,n_frm) : a
a = Trim(a,0,n_frm)
return a
}

function ChgBckGnd(clip a, clip "b", int "sfrm", int "efrm", int "icol", int "tol")
{
sfrm = default(sfrm,0)
efrm = default(efrm,0)
icol = default(icol,0)
tol = default(tol,0)

a = IsRGB32(a)? a : ConvertToRGB32(a)
b = IsRGB32(b)? b : ConvertToRGB32(b)

a1 = Trim(a,0,sfrm-1)
a2 = Trim(a,sfrm,efrm)
a3 = Trim(a,efrm+1,0)

b = FrameCount(b) > efrm - sfrm? Trim(b,0,efrm-sfrm) : b
b = FrameCount(b) > FrameCount(a)? Trim(b,0,FrameCount(a)-1) : b
b = FrameCount(b) <= efrm - sfrm? AddFrame(b,efrm-sfrm) : b
b = audiodub(b,getChannel(a2,1,2))

a2 = colorkeymask(a2,icol,tol)
a2 = layer(b,a2,"add",255,0,0,0,true)

c = sfrm > 0? a1+a2 : a2
c = (efrm > 0) && (FrameCount(a) > efrm-sfrm+1) && (FrameCount(a) != efrm+1)? c+a3 : c

return c
}

tempetai
13th November 2003, 10:57
Below is the sample on how to call the share function above:


Import("multiclip.avs")

mainclip=AVISource("clip25a.avi")+AVISource("clip25b.avi")+AVISource("clip25c.avi")

s1 = AVISource("clip25b.avi")
mainclip=ChgBckGnd(mainclip,s1,179,205,$D3E0F0,40)

s2=imagereader("c:\temp\vtour\000000.png",0,235-206,25,false)
mainclip=ChgBckGnd(mainclip,s2,206,235,$D3E0F0,40)

s3=imagereader("c:\temp\fpgladden.jpg",0,25,25,false)

mainclip=AddSmallClip(mainclip,s1,0,25,50,150,0,0,0,0,220,170,220,170,width(mainclip),height(mainclip),width(mainclip)/3,height(mainclip)/3,255,255)
mainclip=AddSmallClip(mainclip,s1,146,148,150,175,220,170,220,170,220,170,220,170,width(mainclip)/3,height(mainclip)/3,width(mainclip)/3,height(mainclip)/3,255,0)
mainclip=AddSmallClip(mainclip,s3,25,50,150,175,20,300,20,20,20,20,300,20,width(mainclip)/3,height(mainclip)/3,width(mainclip)/3,height(mainclip)/3,0,0)

return mainclip