Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion. Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules. Domains: forum.doom9.org / forum.doom9.net / forum.doom9.se |
|
|
#1 | Link |
|
Registered User
Join Date: Jul 2003
Posts: 52
|
Static mask - how ?
I've read all things about masks in masktools and avisynth doc, and I think (maybe I'm wrong here) that only moving masks are supported. But I need a static mask.
What's the difference ? In moving mask you have an overlay clip that contains some areas that should be removed. This is done with a mask. What is masked, is not visible. The mask is "tied" to an overlay clip. In static mask you have a base clip and want to replace some areas of it with an overlay clip. In this case the mask is "tied" to the base clip. An example is usually seen in 50-s films : when the car is moving, the view from the window changes, but it is visible that it is another movie overlayed on first one. Technically I have a clip and want to replace some areas of it, calculated using the clip colors, with contents of another clip which has different size and typically will move around. How can I do it ? Should I write another plugin ? |
|
|
|
|
|
#2 | Link |
|
Angel of Night
![]() Join Date: Nov 2004
Location: Tangled in the silks
Posts: 9,569
|
A truly static mask can be inserted with imagesource("").converttoyv12(matrix="pc.601"), if you have it in a png or whatever. If you're bluescreening, ColorKeyMask might be what you need. If you have more complex needs, you might need a lut or even a custom plugin.
|
|
|
|
|
|
#3 | Link |
|
Avisynth Developer
Join Date: Jan 2003
Location: Melbourne, Australia
Posts: 3,167
|
A static mask is fixed for all frames in the clip, typically you provide it in a single image file (.bmp, .png, etc).
A moving mask has a unique mask for each frame in the clip, it will be a separate clip in it's own right. The degenerate case is that all the frames are the same, i.e. it reverts to being a static mask. These should not be confused with a motion mask which is used to select areas in a frame that are different from related areas in adjacent frames. To turn a single frame clip into many frames use "Loop(n)". To freeze 1 frame in a clip to many frames use "FreezeFrame(n, start, end)" To build a mask clip to track an area of a particular colour use "ColorKeyMask". MaskTools has many other features to manipulate masks and images in advance of the limited tools native to avisynth. |
|
|
|
|
|
#4 | Link |
|
Registered User
Join Date: Jul 2003
Posts: 52
|
Yes, I understand this. I've made a static mask from the png picture and Loop() already. But the problem remains. Using Overlay function I can apply mask to the OVERLAY clip, but I need to apply it to the BASE clip. I cannot simply exchange clips, because the ovrlay clip should move relative to base clip and the mask.
What I need is to "cut a window" in a base clip and see moving overlay clip through it. |
|
|
|
|
|
#5 | Link |
|
Angel of Night
![]() Join Date: Nov 2004
Location: Tangled in the silks
Posts: 9,569
|
overlay(base,new,mask) doesn't work? The behavior your describe is exactly what you should be getting, if the mask is working. You can also use mt_merge, which is strictly weighting based on the mask, no fancy blending modes.
As a test, output the mask to be sure that it's actually showing up the way you want it to. |
|
|
|
|
|
#11 | Link |
|
Angel of Night
![]() Join Date: Nov 2004
Location: Tangled in the silks
Posts: 9,569
|
Well, I really don't think the error can get much more explicit. Crop your mask down, inside or outside avisynth, to match the overlay instead of the base clip. And if the overlay isn't supposed to start at 0,0 (upper left corner) make sure you use x and y. Alternately, pad/crop/resize your overlay clip to match the base.
|
|
|
|
|
|
#12 | Link |
|
AviSynth plugger
Join Date: Nov 2003
Location: Russia
Posts: 2,182
|
may be you need not in static but in sliding (tracking feature) mask for base clip?
__________________
My Avisynth plugins are now at http://avisynth.org.ru and mirror at http://avisynth.nl/users/fizick I usually do not provide a technical support in private messages. |
|
|
|
|
|
#13 | Link |
|
Avisynth Developer
Join Date: Jan 2003
Location: Melbourne, Australia
Posts: 3,167
|
and a matching copy of a good example frame from each of the base, overlay and mask. Plus a quick hand painted version of what you expect the output to look like (just use paint?? to paste approximate parts of the overlay onto the base) (highly compressed jpeg will be okay)
|
|
|
|
|
|
#14 | Link |
|
Registered User
Join Date: Jul 2003
Posts: 52
|
Here I tried to draw what I want to do. The upper picture shows what I already know how to make - the mask has the same size as an overlay clip, and when the overlay clip moves (using Animate) the mask moves with it.
The lower picture shows what I need. The mask has the same size as the base clip, and always stays at the same place. |
|
|
|
|
|
#15 | Link | |
|
Avisynth Developer
Join Date: Jan 2003
Location: Melbourne, Australia
Posts: 3,167
|
As I said previously you will need to abuse this relation
Quote:
Code:
... InvOlay=Base H=Base.Height() W=base.Width() InvMask=Mask.Invert() # Make middle blob transparent InvBase=Olay.AddBorders(100,100,100,100) # extra room Overlay(InvBase, InvOlay, 100-X, 100-Y, InvMask) PointResize(W, H, 100-X, 100-Y, W, H) # Restore base |
|
|
|
|
![]() |
|
|