PDA

View Full Version : Applying filters to broken ranges


AlanHK
11th May 2008, 18:41
I use a logo filter on TV rips, but as the logo fades in and out several times, I divide it into several sections, and apply the filter to alternate ones.

It works, but is not elegant. In particular, I'd like to be able to just specify the filter parameters once (since usually they are the same throughout all the logo sections).

So currently I do something like this:

AVISource("209.avi")

t0 =972
t1 =3412
t2 =6707
t3 =19745
t4 =20491

Trim(0 ,t0) ++\
Trim(t0 +1,t1).xlogo("logo209_x_40_y_282_2.bmp", X=40, Y=282, alpha=0) ++\
Trim(t1 +1,t2) ++\
Trim(t2 +1,t3).xlogo("logo209_x_40_y_282_2.bmp", X=40, Y=282, alpha=0) ++\
Trim(t3 +1,t4) ++\
Trim(t4 +1,0).xlogo("logo209_x_40_y_282_2.bmp", X=40, Y=282, alpha=0)

The "t" parameters let me change the ranges fairly easily.

I looked at Stickboy's functions, but they either apply to sequences of on/off of constant length, or continuous ranges.

Or failing that, I tried to write a function so the parameters of the logo did not have to be repeated. But this DID NOT work:
(It fails with "incorrect parameters to xlogo".)
AVISource("209.avi")
function xl()
{
return xlogo("logo209_x_40_y_282_2.bmp", X=40, Y=282, alpha=0)
}

t0 =972
t1 =3412
t2 =6707
t3 =19745
t4 =20491

Trim(0 ,t0) ++\
Trim(t0 +1,t1).xl() ++\
Trim(t1 +1,t2) ++\
Trim(t2 +1,t3).xl() ++\
Trim(t3 +1,t4) ++\
Trim(t4 +1,0).xl()

I hope the intent is clear, so what have I done wrong?

LaTo
11th May 2008, 19:35
function xl()
{
return xlogo("logo209_x_40_y_282_2.bmp", X=40, Y=282, alpha=0)
}

Use this:

function xl(clip clp)
{
return clp.xlogo("logo209_x_40_y_282_2.bmp", X=40, Y=282, alpha=0)
}

stickboy
12th May 2008, 06:43
I looked at Stickboy's functions, but they either apply to sequences of on/off of constant length, or continuous ranges.Try the ReplaceFramesSimple function from my RemapFrames plug-in (http://www.avisynth.org/stickboy/).
Or failing that, I tried to write a function so the parameters of the logo did not have to be repeated. But this DID NOT work:
(It fails with "incorrect parameters to xlogo".)
AVISource("209.avi")
function xl()
{
return xlogo("logo209_x_40_y_282_2.bmp", X=40, Y=282, alpha=0)
}

t0 =972
t1 =3412
t2 =6707
t3 =19745
t4 =20491

Trim(0 ,t0) ++\
Trim(t0 +1,t1).xl() ++\
Trim(t1 +1,t2) ++\
Trim(t2 +1,t3).xl() ++\
Trim(t3 +1,t4) ++\
Trim(t4 +1,0).xl()

I hope the intent is clear, so what have I done wrong?If you want to go that route, you'll have to do what LaTo said. (Once your xl() function is fixed, you also might as well use it with ApplyRange too.)

AlanHK
12th May 2008, 08:18
Try the ReplaceFramesSimple function from my RemapFrames plug-in (http://www.avisynth.org/stickboy/).

Thanks. I hadn't looked at that one, it looks like it will do what I need.

AlanHK
13th May 2008, 13:29
So this is the ReplaceFramesSimple version:
AVISource("30r-209.avi")
src = last
xlogo("logo209_x_40_y_282_2.bmp", X=40, Y=282, alpha=0)
filtered = last
ReplaceFramesSimple(src, filtered, mappings= \
"[973 3412]
[6708 19745]
[20492 30711]")
Which is rather tidier.

I had been looking at the "Apply..." series of functions, rather than "Replace..." so it didn't click that these could do the job.

The only problem I had was that ReplaceFrames does not accept the convention of 0 at the end of a range for the last frame of the clip. I suppose this is because mappings can run backwards and and so it becomes ambiguous whether it means the beginning or the end.

MADAJ
14th June 2008, 02:47
loadplugin("E:\dgmpgdec150rc5\DGDecode.dll")
import("C:\Program Files\AviSynth 2.5\plugins\AnimeIVTC.avsi")
mpeg2source("E:\1.d2v")+mpeg2source("E:\2.d2v")
Crop(4,4,-4,0)
tfm.tdecimate.vinverse
ReplaceFramesSimple(AnimeIVTC(mode=2, aa=3),
\ mappings= "[30865 32223]")
LanczosResize(720,480)

http://img515.imageshack.us/img515/8886/asua6.png

I tried to set mappings value to [3 100] and it works, but I don't know why it doesn't work with frames like [30865 32223]

stickboy
14th June 2008, 11:45
And how long is the clip returned by AnimeIVTC()?

How can I reproduce the problem (preferably with a BlankClip as the source)?

MADAJ
14th June 2008, 22:47
And how long is the clip returned by AnimeIVTC()?

How can I reproduce the problem (preferably with a BlankClip as the source)?

woah!!:eek:

sorry, I didn't notice that AnimeIVTC() changes the duration.

thetoof
15th June 2008, 19:32
It doesn't change the duration, but it does change the amount of frames (obviously... it's ivtc), so if you took you frame numbers before ivtc, they are wrong and if they are near the end of the clip, out of bounds.
Also, you seem to be using animeivtc by selecting manually the double hard telecined section... but mode=2 and 4 (for dht) also does ivtc on regular hard telecined.
So, instead of all that, you can simply call animeivtc(mode=2,aa=3) # and maybe killcomb=1 or 2 to remove combing + have a speed boost (dunno why, when it's disabled it slows things down... I'm looking into it right now) and it'll do the job... because with this you ivtc properly all the dht sections, which is much more accurate than spotting them manually (you could miss some).

Mystery Keeper
16th June 2008, 16:39
http://forum.doom9.org/showthread.php?t=136415