View Full Version : Overlay / Layer questions
tacman1123
24th June 2008, 16:44
I'm trying to layer a few photos together, and can't figure out Layer and/or Overlay. What I want to do is have a blank screen, after 10 frames dissolve one photo in, then another, then another, then start dissolving the first one out, etc.
In it's basic form, I thought Overlay would work:
Global W = 720
Global H = 480
Global F = Framerate(AssumeFPS(BlankClip(),"ntsc_video"))
Global R = 48000
f = BlankClip(1, W, H, "RGB32", F, stereo=false).KillAudio().Subtitle("Photos").Loop(300)
a = ImageSource("c:\avi\daver\pics\IMG_2777.JPG").BilinearResize(W / 2, H / 2).ConvertToRGB32().Trim(0, 40)
Overlay(f, a, x=10, y=30, mode="blend")
What I'm expecting is that the photo will show for 40 frames then go away, but it doesn't, it says visible for the whole 300 frames.
What am I doing wrong? Is Layer() the proper command for this?
Thanks -- I've read and re-read the documentation, and still don't quite get it.
Tac
Gavino
24th June 2008, 17:20
Overlay (or Layer) will do the basic layering for you, but they won't do fading in or out on their own.
Also, if the clip you're overlaying is shorter than the base clip, it effectively gets extended to the longer length, hence your 300 frames.
You need to trim/splice together the different parts of your montage.
tacman1123
24th June 2008, 18:02
Thanks, I'm getting closer, but still have a logic problem. Here's the code:
Global W = 720
Global H = 480
Global F = Framerate(AssumeFPS(BlankClip(),"ntsc_video"))
Global R = 48000
f = BlankClip(1, W, H, "RGB32", F, stereo=false).KillAudio().Subtitle("KBE").Loop(300)
a = ImageSource("c:\avi\daver\pics\IMG_2777.JPG").BilinearResize(W / 2, H / 2).ConvertToRGB32().Trim(0, 40).FadeIO(10)
f=Replace(f, Overlay(f, a, x=10, y=30, mode="blend"), 10, 40)
b = ImageSource("c:\avi\daver\pics\IMG_2777.JPG").BilinearResize(W / 3, H / 3).ConvertToRGB32().Trim(0, 40).FadeIO(10)
f=Replace(f, Overlay(f, b, x=240, y=190, mode="blend"), 30, 40)
f
function Replace (clip old, clip inclip, int frame, int numframes)
{
numframes = ((numframes == 0) || (numframes > inclip.framecount)) ? inclip.framecount : numframes
return old.Trim(0, frame - 1) + inclip.Trim(0, numframes) + old.Trim(frame + numframes, 0)
}
At frame 30, I expect to see "a" at full strength, with "b" just starting to fade in. Instead, "a" disappears, and "b" starts fading in.
What I THINK I'm doing is storing the "a" image in f, then overlaying the "b" image from frames 30 to 70 on top of that. But somewhere I'm not storing something right. I'm guessing it's in the replace, that I'm splicing in "b" rather than overlaying it, but I'm not sure what I'm doing wrong.
Thanks!
Tac
Gavino
24th June 2008, 19:28
The semantics of your Replace function do not match the way you use it here. Replace the last line with
return old.Trim(0, frame - 1) + inclip.Trim(frame, frame+numframes-1) + old.Trim(frame + numframes, 0)
ie you want to replace the specified part of the old clip with the same frame-range of the inclip, not start from frame 0 of inclip. Your frame 30 was showing frame 0 of the first overlay, in which 'a' doesn't start to appear till frame 10.
BTW As I mentioned in another post, you should be careful not to use your function to replace the first or last frame of a clip (or else make it handle these cases).
sidewinder711
24th June 2008, 22:17
I created (with some forum help from here) a few weeks ago a script for myself to view my camera pictures via picture show. It fades in, dissolves from one picture to the next and fades out (incl. audio). Adjust the paths, width, hight, loop length, fadeout length to your needs . For me it works perfectly.:)
#############################
### ###
### PICTURE SHOW ###
### ###
#############################
#---------------------------
Global F = Framerate(AssumeFPS(BlankClip(),"ntsc_video"))
Global W = 640
Global H = 500
Global L = 100
#---------------------------
pic= ImageReader("e:\....jpg",0,0).AssumeFPS(F).Lanczos4Resize(W,H).Loop(150)
pic1= ImageReader("e:\...jpg",0,0).AssumeFPS(F).Lanczos4Resize(W,H).Loop(L)
pic2= ImageReader("e:\...jpg",0,0).AssumeFPS(F).Lanczos4Resize(W,H).Loop(L)
pic3= ImageReader("e:\...jpg",0,0).AssumeFPS(F).Lanczos4Resize(W,H).Loop(L)
pic4= ImageReader("e:\...jpg",0,0).AssumeFPS(F).Lanczos4Resize(W,H).Loop(L)
#---------------------------
audio= NicMPG123Source("e:\....mp3")
#---------------------------
a=FadeIn(pic,100)
b=DissolveAGG(pic, pic1,TFrames=50, Mode="LeftToRight")
c=DissolveAGG(pic1,pic2,TFrames=50, Mode="TopToBottom")
d=DissolveAGG(pic2,pic3,TFrames=50, Mode="RightToLeft")
e=DissolveAGG(pic3,pic4,TFrames=50, Mode="BottomToTop")
#f= #here:further pic
#g=
#---------------------------
ff=b+c
gg=d+e
#hh=f+g #here:further pics
#-----------------------------
video= a+ff++gg #++hh #here:further pics
nr_frames = int(video.FrameRate() * 5)
c = AudioDub(video, audio)
AudioDub(c, c.FadeOut(nr_frames))
Dissolve(last, blackness(last, 48), 8)
# DissolveAGG(clip A, clip B, Int "TFrames", String "Mode")
# Tframes define the number of overlapped frames
# Four modes are possible: LeftToRight, RightToLeft, TopToBotoom and
# BottomToTop depending where the overlapping stars and ends.
function DissolveAGG(clip A, clip B, Int "TFrames", String "Mode") {
Global Hi = Height(A)
Global Wi = Width(A)
Global FS = Framerate(A)
Global Fa=FrameCount(A)
Global Fb=FrameCount(B)
Global TFrames = Default(TFrames, 25)
Mode = Default(Mode, "LeftToRight")
(Mode=="LeftToRight") ? LToR(A, B) :\
(Mode=="RightToLeft") ? RToL(A, B) :\
(Mode=="TopToBottom") ? TToB(A, B) :\
(Mode=="BottomToTop") ? BtoT(A, B) :\
LToR(A, B)
Function H(clip C, Float X) {
K = C.GaussResize(Wi, Hi, X, 0, 2.0, 0, P=50)
Return K
}
Function V(clip C, Float X) {
K = C.GaussResize(Wi, Hi, 0, X, 0, 2.0, P=40)
Return K
}
Function LToR(clip A, clip B) {
AA=BlankClip(TFrames+1, 4, Hi, pixel_type="RGB32", fps=FS, color=$000000)
BB=BlankClip(TFrames+1, 4, Hi, pixel_type="RGB32", fps=FS, color=$ffffff)
D=StackHorizontal(AA, BB)
Xi=4.5
Xf=1.5
E=D.Animate(0, TFrames, "H", Xi, Xf)
Return Trim(A, 0, Fa-TFrames-2) + Overlay( Trim(B, 0, TFrames), Trim(A, Fa-TFrames-1, \
0),mask=E, pc_range=True) + Trim(B, TFrames+1, 0)
}
Function RToL(clip A, clip B) {
AA=BlankClip(TFrames+1, 4, Hi, pixel_type="RGB32", fps=FS, color=$000000)
BB=BlankClip(TFrames+1, 4, Hi, pixel_type="RGB32", fps=FS, color=$ffffff)
D=StackHorizontal(AA, BB)
Xi=1.5
Xf=4.5
E=D.Animate(0, TFrames, "H", Xi, Xf)
Return Trim(A, 0, Fa-TFrames-2) + Overlay(Trim(A, Fa-TFrames-1, 0), Trim(B, 0, TFrames), \
mask=E, pc_range=True) + Trim(B, TFrames+1, 0)
}
Function TToB(clip A, clip B) {
AA=BlankClip(TFrames+1, Wi, 6, pixel_type="RGB32", fps=FS, color=$000000)
BB=BlankClip(TFrames+1, Wi, 6, pixel_type="RGB32", fps=FS, color=$ffffff)
D=StackVertical(AA, BB)
Xi=6.5
Xf=3.5
E=D.Animate(0, TFrames, "V", Xi, Xf)
Return Trim(A, 0, Fa-TFrames-2) + Overlay( Trim(B, 0, TFrames), Trim(A, Fa-TFrames-1, \
0),mask=E, pc_range=True) + Trim(B, TFrames+1, 0)
}
Function BToT(clip A, clip B) {
AA=BlankClip(TFrames+1, Wi, 6, pixel_type="RGB32", fps=FS, color=$000000)
BB=BlankClip(TFrames+1, Wi, 6, pixel_type="RGB32", fps=FS, color=$ffffff)
D=StackVertical(AA, BB)
Xi=3.5
Xf=6.5
E=D.Animate(0, TFrames, "V", Xi, Xf)
Return Trim(A, 0, Fa-TFrames-2) + Overlay(Trim(A, Fa-TFrames-1, 0), Trim(B, 0, TFrames), \
mask=E, pc_range=True) + Trim(B, TFrames+1, 0)
}
}
mikeytown2
25th June 2008, 05:04
@sidewinder711
Those transitions look very nice! I was going to suggest that you use TransWipe (http://avisynth.org/vcmohan/TransAll/docs/TransWipe.html), but the DissolveAGG (http://forum.doom9.org/showthread.php?p=900678#post900678) function is visually very appealing. I'm gonna look into that function more... Also check out ImageSequence (http://forum.doom9.org/showthread.php?t=109997)'s wild card (*) support for loading images. It might help in terms of organization, but it will require a more complex script, since you have to extract the pictures out of the clip; also the pics would have to be the same size.
sidewinder711
25th June 2008, 11:13
@mickeytown
The transition set "TransAll" (http://avisynth.org/vcmohan/TransAll/docs/index.html) created by vcmohan (including TransWipe) is a great tool set and works very smoothly, too.
If you are loading several images with a *wildcard through ImageSequence, what variables are you using to achieve different kind of transitions between the images (with other words: aren't you "stuck" to only one transition type for all transitions) ?
mikeytown2
25th June 2008, 22:20
I kept on trying to use AvsLib to create an array element for every frame, but i gave up. The problem with the script below is every pic is 100 frames long, and it's not easy to change. This will do 8 pics.
CoronaSequence("DSCN*.JPG")
#100 frames long
BlankClip(last,100) + SelectEvery(1, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0).AssumeFPS(25)
CutFrames(900,899,20)
CutFrames(800,799,20)
CutFrames(700,699,20)
CutFrames(600,599,20)
CutFrames(500,499,20, transition="DissolveAGG", opt1=""" "TopToBottom" """)
CutFrames(400,399,20, transition="DissolveAGG", opt1=""" "BottomToTop" """)
CutFrames(300,299,20, transition="DissolveAGG", opt1=""" "RightToLeft" """)
CutFrames(200,199,20, transition="DissolveAGG", opt1=""" "LeftToRight" """)
CutFrames(100,99,20)
CutFrames (http://forum.doom9.org/showthread.php?t=135423) can use any transition.
Using this DissolveAGG (http://forum.doom9.org/showthread.php?p=1152440#post1152440)
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.