Log in

View Full Version : want to modify,(create?) function...


matrix
22nd September 2002, 21:36
Ever since I saw this script:
clip1=AVISource("C:\Movie\menu.avi").converttorgb32
clip2=AVISource("C:\Movie\sDisk2\t7.avi").BilinearResize(160,160).converttorgb32
clip2=clip2.Mask(clip2.BlankClip(color=$FFFFFF))
function CIRCLE(clip clip, clip "LClip", float "angle") {
return clip.Layer(LClip, "Add",500 , round((clip.width-LClip.width)/2 + cos(angle)*100),
\ round((clip.height-LClip.height)/2 + sin(angle)*100) )
}
Animate(0, 840, "CIRCLE", clip1, clip2, 0, clip1, clip2,Pi*8 )

at avisynth.org, and before that somewhere in this forum, I wanted to do something similar, but having the thumbnail clip going from right to left or the other way, straight in line on top of the screen. Actually I want to have more of them, (3 or 4)going one after the other from outside the edge, and dissapearing beyond the other edge. And to repeat the cycle for as long as the main clip lasts.
First of all, I have no clue about many of the functions and arguments in the above script, but I was messing around with some of them, and I got to this:
clip1=AVISource("C:\Movie\menu.avi").converttorgb32
clip2=AVISource("C:\Movie\sDisk2\t1.avi").BilinearResize(160,160).converttorgb32
clip2=clip2.Mask(clip2.BlankClip(color=$FFFFFF))
function LINE(clip clip, clip "LClip", float "line") {
return clip.Layer(LClip, "Add", 500, round((clip.width-LClip.width)/-1+ exp(line)*100),
\ round((clip.height-LClip.height)/100 + exp(line)*2) )
}
Animate(0, 840, "LINE", clip1, clip2, 0, clip1, clip2, Pi*4)

You can laugh if you want, as I said, no clue what it all means, exept I noticed changing the value in red, makes it less transparent, and the one in green, slows it down. Some other values I changed, make it go somewhat in line, but not straight. It starts on top, and as it passes across the screen, goes down a little.
Can't seem to be able to go any further than this.
Now I know this is the place to ask, because here is where all the experts are.
So if anybody have some time to spare on this, please give me a hand.
I appreciate any help.
Thank you.

Wilbert
23rd September 2002, 09:53
Have a look at this thread screensavers (http://forum.doom9.org/showthread.php?s=&threadid=32884). The functions translation and trans_acc translates in a straight line:

# translation: translates LClip along a straight line on a black background. (centerX,centerY)
# is the center of the first frame of the translation and (center2X,center2Y) is the center
# of the last frame of the translation. LClip starts playing at start_frame (with
# start_frame >= 0 and end_frame >= LClip.framecount).

function translation(clip clip, clip LClip, int start_frame, int centerX, int centerY, int end_frame,
\ int center2X, int center2Y) {
return Animate(start_frame, end_frame, "layer", clip, LClip, "Add", 255, centerX, centerY,
\ clip, LClip, "Add", 255, center2X, center2Y)
}

where clip is your videoclip and LClip the menu. As for what it means: "layer" is applied the animations with starting center-point (centerX,centerY) and ending center-point (center2X,center2Y) where it is interpolated between resulting in a straight line.

=====
Try something like this:

# creates a mask of it since we want to use C2 as a background for clip1 which will be playing and moving:

clip=clip2.Mask(clip2.Greyscale.Levels(0, 1, 1, 0, 255))

clip.translation(clip1, 0, 360, 288, clip1.framecount-1, 0, 288)

matrix
24th September 2002, 00:48
And when you think I went through that thread. Seems I didn't read everything.

I tried and indeed, it is what I wanted.

Now on the same background and at the same time, can I have more than one clip playng?
Can I use the same function (translation) and just use different clips, and change the coordinates?

I will try different variations. But just last time, with the other script, I tried, but it allways palyed only the last clip.
But don't worry. As I said, I will try different things. What's most important, I got. Thanks to you.

Thanks for the help.
I appreciate you taking the time to shed some light on this.

Wilbert
24th September 2002, 14:31
Now on the same background and at the same time, can I have more than one clip playing? Can I use the same function (translation) and just use different clips, and change the coordinates?

Sure. clip1, clip3 are moving and clip2 is background.

Recall:

clip=clip2.Mask(clip2.Greyscale.Levels(0, 1, 1, 0, 255))
clip4=clip.translation(clip1, 0, 360, 288, clip1.framecount-1, 0, 288)

Just do it a second time. Thus overlay the second moving clip "clip3" over the clip "clip4" and apply a translation.

clip=clip4.Mask(clip4.Greyscale.Levels(0, 1, 1, 0, 255))
clip=clip.translation(clip3, 0, 360, 144, clip1.framecount-1, 0, 144)

or in a different direction (say diagonal):

clip=clip4.Mask(clip4.Greyscale.Levels(0, 1, 1, 0, 255))
clip=clip.translation(clip3, 0, 0, 0, clip1.framecount-1, 720, 576)

You have to cut it into pieces if you want the three clips not playing (or translating) from the same moment. Suppose you want that clip3 starts playing after clip1 is finished playing:

first piece:

clip=clip2.Mask(clip2.Greyscale.Levels(0, 1, 1, 0, 255))
clip4=clip.translation(clip1, 0, 360, 288, clip1.framecount-1, 0, 288)

second piece:

clip5=clip4.Trim(clip4.framecount-1,-1).Loop(clip3.framecount)
#this freezes the last frame of clip1 during the length of clip3

clip=clip5.Mask(clip5.Greyscale.Levels(0, 1, 1, 0, 255))
clip6=clip.translation(clip3, 0, 360, 144, clip3.framecount-1, 0, 144)

return clip4+clip6

#Haven't tried this, so maybe it is not correct. But I hope you get the idea.

matrix
25th September 2002, 01:16
Well, I have to say this... This is weird. I mean this program. It works beautiful.
Makes you wonder,. Is there a limit.

I just want to know if I understand this correct now.
Mask(clip.Greyscale.Levels(0, 1, 1, 0, 255)), applyes a transparent layer over the entire screen area?
At first I thought it applyes the layer over a certain area. But that can't be right? Because if it did, you wouldn't have to apply the Mask to the previous clip, in order to have another one playing at the same time. Is it right?

Anyway, I got it working now.
Thanks again for your help and your patience. Really appreciate it.

Wilbert
26th September 2002, 09:25
I'm sorry, told you nonsense. You don't need to apply any masks at all. I just copied it from the other thread where I also didn't need that. Just remove the lines with mask ...

Mask(clip.Greyscale.Levels(0, 1, 1, 0, 255)), applyes a transparent layer over the entire screen area?
It makes a mask over the part of the clip which is not pure black.