View Full Version : ? bug in Layer with negative y offset
neily
29th September 2003, 15:08
Hi,
I don't know whether it is a bug or a feature of how Layer is implemented, but it seems that when using negative Y offsets, the amount of shift up is one less than might be expected.
Any confirmation / comments would be appreciated.
stickboy
30th September 2003, 05:37
Could you be a little more specific? Could you provide a sample script that demonstrates the problem?
It seems fine in this script:clip1 = ColorBars(640, 480)
clip2 = clip1.Levels(0, 1.0, 255, 255, 0) # invert
Layer(clip1, clip2.ResetMask(), "fast", x=0, y=-1)
neily
30th September 2003, 09:49
@Stickboy,
Yes I agree your example works just fine. I do have some wierdness going on though, which maybe has something to do with ApplyRange. I have some captures where a field is intermittently shifted down by a variable number of lines. I have an applet that can detect this and generate a script to move the affected fields up the requisite amount. A segment of an example script is:
AVISource("J:\Temp\LumA RGB Full.avi").ConvertToRGB32.SeparateFields()
even=SelectEven()
odd=SelectOdd()
even=ApplyRange(even,8,18,"Layer",even,"add",255,0,-2,0,true)
even=ApplyRange(even,123,125,"Layer",even,"add",255,0,-3,0,true)
#etc
Interleave(even,odd)
Weave()
The odd thing is that within each specified range, the first frame gets shifted up the requisite amount, but the subsequent frames only get shifted up by one less. Basing a further example on your example,
ColorBars(352,288)
vid00=last
vid01=Levels(0,1.0000,255,255,0)
ApplyRange(vid00,8,18,"Layer",vid01,"add",255,0,-2,0,true)
produces the same effect, but works OK for positive values of Y. BTW, this is using the avisynth_180903.exe release.
As an aside, I was trying to use a function to simplify the generated script.
function ShiftUp(clip v,int firstframe,int lastframe,int amount)
{
v = ApplyRange(v,firstframe,lastframe,"Layer",v,"add",255,0,-amount,0,true)
}
..
ShiftUp(even,8,18,2)
..
This doesn't work though, and I have to omit the 'v =' in the function, and do even=ShiftUp(even,8,18,2) instead.
neily
30th September 2003, 11:00
I apologise for repeat posting, but I tried playing around with ApplyRange with Subtitle, as it was the easiest one to work with that had a definable Y offset, and it is totally wierd.
My test script was:
ColorBars(352,288)
ApplyRange(5,9,"Subtitle", "Hello, World!", 0, 0, 0, 99999, "Arial",20,$ffff00,$000000,7)
ApplyRange(10,14,"Subtitle", "Hello, World!", 0, Y, 0, 99999, "Arial",20,$ffff00,$000000,7)
ApplyRange(15,19,"Subtitle", "Hello, World!", 0, 0, 0, 99999, "Arial",20,$ffff00,$000000,7)
The first and last ApplyRanges are just there to act as markers for where the baseline is.
With Y = -1, the subtitle in frame 10 is aligned with the centre of the frame, and in frames 11 to 14 the subtitle is not shifted at all.
With Y = -2, the subtitle in frame 10 is shifted up 2, and the subtitle in frames 11 to 14 are aligned with the centre of the frame.
With Y = -3, the subtitle in frame 10 is shifted up by 3, and the subtitle in frames 11 to 14 is shifted up by 2.
With Y = -4, the subtitle in frames 10 to 13 is shifted up by 4, and the subtitle in frame 14 is shifted up by 3.
With Y = -5, the subtitles in frames 10 to 14 are all shifted up by 4.
I stopped at -5 as it was doing my head in. Once again, this is with the most recent avisynth_180903.exe release.
WarpEnterprises
4th October 2003, 22:06
1)
and I have to omit the 'v =' in the function,
you must have a "return" in a function.
2) You can't use neg. values in Subtitle, only -1 centers on the axis as is (badly) in the docs.
3) There may well be an error in Layer, too, didn't check so far.
Could you try WITHOUT any ApplyRange to get the error?
neily
5th October 2003, 01:23
@WarpEnterprises,
No, without invoking ApplyRange, negative offsets in Layer work just fine. Using a simple example of layering a small coloured BlankClip onto another with ApplyRange and using negative x or y offsets for Layer parameters, the first frame of the range shifts the correct amount, and the subsequent frames shift one less (magnitude) i.e. with an x offset of '-d', the first frame layers with an offset to the left of 'd' and subsequent frames have the offset to the left of 'd-1'.
BTW, with reference to Subtitle, you are of course absolutely correct about the -1 special meaning (sorry I forgot about that), but other negative offset values do seem to work as expected, at least when not used in conjunction with ApplyRange.
Thanks for your interest.
WarpEnterprises
6th October 2003, 08:18
ApplyRange(v,firstframe,lastframe,"Layer",v,"add",255,0,-amount,0,true)
Can you try instead of
-amount
(-1)*amount
?
neily
6th October 2003, 09:16
Tried (-1)*amount, but it made no difference. The script I used was:
vid00=BlankClip(width=32,height=32,color=$0080FF)
vid01=BlankClip(width=16,height=16,color=$FFFF80).ResetMask()
ApplyRange(vid00,5,9,"Layer",vid01,"add",255,0,(-1)*2,0,true)
WarpEnterprises
6th October 2003, 17:04
Now I see:
There is indeed a problem when using
ApplyRange and a function with TWO CLIPS as input.
It seems ApplyRange (as Animate) cannot handle this.
(one more reason to make ApplyRange Trim()-based, I suppose)
Wilbert
6th October 2003, 21:05
Forgot to update www.avisynth.org (but it's corrected in sourceforge). The argument list (args) can't contain a clip, contrary to Animate.
neily
6th October 2003, 21:31
Thanks all for your input. I could rewrite things to use trims and splices, but ApplyRange seemed much more elegant.
Is it "can't" or "not recommended / unreliable", as it does seem to work fine with positive offsets. And I'm sure I've seen user functions before which use Animate and Layer to get moving picture in picture effects.
stickboy
6th October 2003, 21:46
Try using my ApplyRange alternative (JDL_ApplyRange) from http://www.avisynth.org/stickboy/.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.