Log in

View Full Version : Copying an area from one frame to another


AsTimeGoesBy
11th February 2005, 12:19
Maybe there is such a filter but i'm not able to find it...

I'm looking for a filter that works similar to freezeframe(), but that copies only a partial area from one frame to other frames, something like...

FreezeArea(clip, first-frame, last-frame, source-frame, x-pos, y-pos, x-width, y-width)

...or any filter and syntax doing the same. :)

stickboy
11th February 2005, 13:18
Try my JDL_FreezeRegion function (http://www.avisynth.org/stickboy/) (part of jdl-range.avsi).

AsTimeGoesBy
16th March 2005, 21:38
Hey thanks! I will try it at the weekend when i'm back home again.

BTW, is it also possible to use loops or so in the avs file like:
for {i=0;i<16;i++) { ... }
I remember that such a syntax must be wrong, at least virtualdub did not accept it the last time...

vcmohan
17th March 2005, 03:55
You can also try Hollywoodsq plugin of mine available at www.avisynth.org/warpenterprises
It provides freeze or motion part frame over another clip

stickboy
17th March 2005, 06:13
Originally posted by AsTimeGoesBy
BTW, is it also possible to use loops or so in the avs file like:
for {i=0;i<16;i++) { ... }No. You can write recursive functions, however.

Exactly what do you want to do?

AsTimeGoesBy
17th March 2005, 16:11
Well, i just have played a bit with overlay() due to its possibility to copy and place clips respectively areas - although it's quite unhandy compared to the 'FreezeArea' idea above...

However i found it very interesting meanwhile to make once a picture-in-picure video with blended borders around the inserted clip/picture.
I did this with 50 overlays with continuiously increased opacity value and permantly cropped framesize - a lot of script code while a loop only would need some rows.
Of course there is maybe another much easier (and faster ;)) way to do the same!?

stickboy
17th March 2005, 18:24
Originally posted by AsTimeGoesBy
I did this with 50 overlays with continuiously increased opacity value and permantly cropped framesize - a lot of script code while a loop only would need some rows.If all you want to do is adjust the opacity of an overlay, there are many things you can do.

A. Use a mask that fades in and out. I have an example (http://www.avisynth.org/stickboy/etc/logo-example.zip) available.

B. Use Animate.

C. Use Overlay's conditional variables. See the Overlay documentation for details.

AsTimeGoesBy
18th March 2005, 13:33
Thanks for the example! - I never have used (or seen) a mask before.
This make me believe i also could realize that picture-in-picture (PiP) effect with different masks maybe.
I'm not sure if animate() would help because on all frames happens the same.
Also i can't find a better overlay mode - but i must make once some test sample to see if the modes really work as i think now.


Please let me generally clear something i haven't expressed very well in the previous post:
This PiP effect i'm thinking on isn't indeed 'picture in a picture', it's rather 'video in video' - but sometimes on TV devices it's simply called picture-in-picture.

I have made a screen-shot with a short avi to download (1.5mb) because there is also no temporally alternated fading/blending:

http://homepage.hispeed.ch/audio/temp/viv-test2.jpg (http://homepage.hispeed.ch/audio/temp/viv-test2.avi)

Of course a temporarly in-/out-faded video-in-video (let me call it 'viv' form now) would look very nice but the existing code for the viv example above is critical in many ways already now i think:

# base, background:
base = AviSource("g:\Notorious.avi") # 560x320
base = killAudio(base)
base = trim(base,55135,55644)

# video-in-video:
viv = AviSource("g:\20thFox.avi") # 560x400
viv = killAudio(viv)
viv = trim(viv,51,559)
viv = crop(viv,0,32,560,320)

# Dimension & final position of viv:
vivWid = 192
vivHei = 128
vivPosX = 364
vivPosY = 188

# Resizing viv to smaller final size (by meaning, but not needed, see later why)
# viv = bicubicresize(viv,vivWid,vivHei,0.1,0.5)

# This would be a border-unblended overlay:
# overlay(base,viv,vivPosX,vivPosY,opacity=1)


# Temporary 'carrier' clip for viv (same dimension, final location,
# not really needed but easier to change resulting position of viv):
vivTemp = crop(base,vivPosX,vivPosY,vivWid,vivHei)

# double size due to crop() restriction (width has to be multiple of 4):
viv = bicubicresize(viv,(vivWid*2),(vivHei*2),0.1,0.5)
vivTemp = bicubicresize(vivTemp,(vivWid*2),(vivHei*2),0.1,0.5)


# --- 'loop code' go! ---
vivTemp = overlay(vivTemp,viv,0,0,opacity=0.0075)
viv = crop(viv,2,2,380,252)
vivTemp = overlay(vivTemp,viv,2,2,opacity=0.015)
viv = crop(viv,2,2,376,248)
# ...
# --- 'loop code' is going on, please see full code length (http://homepage.hispeed.ch/audio/temp/viv-test2.html) ---
# ...
vivTemp = overlay(vivTemp,viv,76,76,opacity=0.2925)
viv = crop(viv,2,2,228,100)
vivTemp = overlay(vivTemp,viv,78,78,opacity=0.3)
viv = crop(viv,2,2,224,96)
# --- 'loop code' end ---


# now the full/plain viv (although cropped) is placed in the center
# of the carrier vivTemp clip (checked with: viv = greyscale(viv)):
vivTemp = overlay(vivTemp,viv,80,80,opacity=1)

# down-sizing back again by 2
vivTemp = bicubicresize(vivTemp,vivWid,vivHei,0,0.6)

# Finally the border-blended viv finds its destimony
overlay(base,vivTemp,vivPosX,vivPosY,opacity=1)



I have made another code (http://homepage.hispeed.ch/audio/temp/viv-test3.avs) for avisynth intended to produce better corners and to be more efficient due to generally less redundant pixels to overlay - but anyhow that script blasts the memory of my actual PC, i hope it will work at my PC at home...

matrix
21st March 2005, 01:54
However i found it very interesting meanwhile to make once a picture-in-picure video with blended borders around the inserted clip/picture
For something like that why don't you use a mask?
You can make one in photoshop. White in the middle and gradient black towards the edges, and use overlay.
mask=imagereader("").bicubicresize(220,180)
clip=avisource("")
pip=clip.trim(). bicubicresize(220,180) # or another clip
overlay(clip,pip,mask=mask,x=200,y=100)
And your picture in picture(pip) clip will show with the edges nicely dissolved in the main clip.

The mask can look like this: I hope I can post the pic.

Wilbert
21st March 2005, 10:35
The mask can look like this: I hope I can post the pic.
I converted it to jpeg and reattached it for you.

Btw, E-male made a plugin for creating such masks. I forgot the name of the plugin though, but I will look it up ...

AsTimeGoesBy
21st March 2005, 13:50
Great, so many hints!

The plugin mentioned seems to be called 'MaskMaker'. I wasn't able to find a binary to dowanload but a good starting point for further investigations would be this developper thread. (http://forum.doom9.org/showthread.php?threadid=88710&highlight=mask+AND+plug%2A)

So i was lucky to be able to use the mask attached :) - and now i begin to understand!
I guess i didn't pay enough attention to this luma remark in the Overlay() description, and indicating the mask file directly in the command never had worked too...

But now:
http://homepage.hispeed.ch/audio/temp/viv-test4.jpg
It could be so easy (and fast!)... :)

Thanks for all that help!