Log in

View Full Version : Moving Picture in picture


MrTVideo
10th March 2004, 06:10
Hi.All. this is my first post.
I use Pinnacle Studio 8 plus a DC10 card but as the program is a single timeline editor I have discovered AVIsynth and am amazed by its apparent capability. I wish to be able to give my avi's extra special effects. The simple ones Reverse, flip, and mirror I am ok with. I am trying to work out how to program a splice or other function to perform a moving picture in picture effect and am coming to grips with the syntax of manipulating one clip on top of another frame by frame.
I am brushing up on my knowledge of C which I was reasonably competant 20 years ago (I am over 60)

What I am asking for is:
1. Do you think it possible
2. Functions that might do the task
3. Discusions on the programing syntax using AVIsynth

If I come up with anything usefull I will post my efforts
Anyway cheers for now
Terry

MrTVideo
10th March 2004, 06:24
Ok! just had a look at the AVIsynth Manual it looks as if there is a way I might have been a bit premature. I will post if I come a cropper. In the mean time any surgestions would be greatfully accepted.
Have a good day all
Terry

Mug Funky
10th March 2004, 08:06
hey yo.

avisynth can do all those effects... the only one's i've not managed to do are the really cheezy ones (page curl, lens flare, etc.).

"imagereader" and "overlay" are commands to look into in this regard.

the avisynth manual is actually really useful for figuring out what things you can do by combining functions and making your own. you can even do chroma-keying (quite a lot better than premiere as well) with the appropriate script.

WarpEnterprises
10th March 2004, 16:46
some hints (only available with the latest AViSynth versions):

- Overlay and its "conditional variables":

- ConditionalReader

- Zoom plugin

It can all be done by using the "conditional" or better called "runtime" functionality, which evaluates part of the script for each frame.

Be careful, AviSynth does not FULLY support this because the variables used exist only "once" for the whole script.

MrTVideo
11th March 2004, 01:21
Am I impressed, not only on your knowledge but the speed of your response. I am using a GUI which I am adding to. As I have received a lot of help from those on the Studio forum I am offering it to them plus upgrades as I make it more sophisticated. If any are interested my logo is MRT on the Pinnacle Studio 8 forum. The download site is in my signature.
Anyway thanks again, I look forward in airing my knowledge as I aquire it with you experts out there. I will keep a record of the surgestions for addition to my GUI's help file.

Avisynth and virtualdubmod rocks. "Wonder if I can get them to whistle Dixi". Pommy computer geek joke.

matrix
11th March 2004, 02:37
I used to do that moving pip a lot.
There's a function that wilbert wrote to do that.

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

And use it like this:

clip1=avisource(your clip)
clip2=avisource(your PIP clip)

clip=clip1.Mask(clip1.Greyscale.Levels(0, 1, 1, 0, 255))
clip=clip.translation(clip2, 0, 1440, 30, clip2.framecount-1, 0, 30)
clip

The only drawback is mask only works in rgb32. so you have to do some color conversion.

MrTVideo
11th March 2004, 09:14
Im Back.
Thanks to you all. got it working pic in pic + moving pic in pic. To you Matrix I will try your script looks interesting.
to you both Mug Funky (Fellow Aussie)and WarpEnterprises what can I say - Thanks. I will code up a script writer add it to the GUI and make it available. There a lot of home video editers out there like me who cannot afford one of the more upmarket products like Premiere so this is for them. Maybe later when I get it to whistle Dixi I will turn it into shareware.
Just for interest I am using Mediator for the frontend (I am lazy) and C as the file and string concatenation. Mediator swallows the C executables. downside is Mediator has a fair bit of o'head about 2meg.
I would code the lot in C for a Shareware version that requires using Windows API.
As a thought the convolution function might do page turns - look into it

PraetorianPrefect
1st August 2007, 16:01
Using the script Matrix provided, i wanted to add and move another PiP. I tried this:

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

#And use it like this:

clip1=imagesource("Image.bmp").ConvertToRGB32()
clip2=imagesource("Image.bmp").ConvertToRGB32().BicubicResize(120,160)

clip=clip1.Mask(clip1.Greyscale.Levels(0, 1, 1, 0, 255))
clipa=clip.translation(clip2, 0, 800, 500, clip2.framecount-1, 10, 10)

clip=clip1.Mask(clip1.Greyscale.Levels(0, 1, 1, 0, 255))
clipb=clip.translation(clip2, 0, 250, 500, clip2.framecount-1, 10, 50)

clipa+clipb

--------------------

it ended up removing the first PiP and replacing it with the second PiP.

matrix
2nd August 2007, 00:57
That's a very old scipt. You can simplify it a little.
Use this function
Function move(clip clip, clip LClip, int start_frame,
\ int end_frame,
\ int centerX,
\ int centerY,
\ int center2X,
\ int center2Y,
\ string "mode",
\ int "strength")

{
return Animate(start_frame , end_frame, "layer", clip, LClip, mode, strength, centerX, centerY,
\ clip, LClip, mode, strength, center2X, center2Y)
}

and use it like this example.

clip=avisource("")
a=clip.trim(25000, 25500).bicubicresize(200, 160)
b=clip.trim(50000, 50500).bicubicresize(200, 160)
move(clip, a, 0, 160, 40, 40, 240, 40, "add", 255)
move(b, 40, 140, 40, 220, 240, 220, "add", 255)

so for "a": it starts at frame 0, and ends at 160. At frame 0 it's going to be at 40 horizontal and 40 vertical. then at frame 160, it will be at 240 horiz and 40 vertical.

PraetorianPrefect
2nd August 2007, 02:26
Thank you. If I try having one clip move from the bottom right and stop at the top left of the screen and have another clip move from the bottom left and stop next to the first clip, the first clip disappears, leaving only the second clip.