Log in

View Full Version : Custom functions, applying per frames


DarkT
1st February 2007, 00:09
Hi, I am wondering if I am doing this correctly - my gut, and the schrieking noises my hdd makes are telling me I am going wrong somewhere...

Here's how I use it(after help from a certain somebody from DarkHold):

function FunctionTcombUni(clip a, int start, int end)
{return (a.trim(0,start)+a.trim(start+1,end).Tcomb(mode=2,fthreshl=12, othreshl=19)+a.trim(end+1,0))}

And then in the script itself:

FunctionTcombUni(106,218)
FunctionTcombUni(491,540)
FunctionTcombUni(563,755)
FunctionTcombUni(1023,1095)
FunctionTcombUni(1212,1253)
FunctionTcombUni(1346,1504)
FunctionTcombUni(1761,1771)
FunctionTcombUni(2093,2115)
FunctionTcombUni(2544,2593)
FunctionTcombUni(2939,3030)
FunctionTcombUni(3138,3317)
FunctionTcombUni(3417,3505)
FunctionTcombUni(3635,3756)
FunctionTcombUni(3814,3853)
FunctionTcombUni(3976,4088)
FunctionTcombUni(4187,4288)
FunctionTcombUni(4347,4812)
FunctionTcombUni(4920,5086)
FunctionTcombL(5269,5403)
...

There are ~105 lines of it... Also I need to derainbow the bad parts and MFToon some 90%, which will add another 30 lines similiar to those, is it the way it's supposed to be?

IanB
1st February 2007, 09:29
Well thats one way to bash the inards out of avisynth.

Generally start with 2 full clips, 1 original, 1 filtered.
Trim the appropriate segments from each clip, then splice them all together.

FrameEvaluate/ConditionalReader also make a good pair for doing this, particularly if you have a data file describing the segements. The installed Docs have an example almost exactly like this.

StickBoy also has some inovative pluggins to help with this sort of thing.

DarkT
1st February 2007, 19:04
I haven't even checked it yet, as I just came from work... God, users will end up in the weirdest situations by two clicks or less - you didn't even suspect such options exist untill you need to solve it...

*sigh*

ANYWAY, thanks - I am certain it'll be better and more correct then what I do - since before leaving to work I tried to make virtual dub eat it - and, ummm, it didn't want to - gave me some error and stuff :) - funny...

Anyway, thanks ;).

stickboy
1st February 2007, 20:26
Use my ReplaceFramesSimple plug-in (http://forum.doom9.org/showthread.php?p=585002#post585002).

DarkT
1st February 2007, 20:37
I'm an utter noob to this, so I don't quite understand how I'd use it and what it'd do for me - if you could explain it a bit more, I'd really appritiate it...

In the meanwhile, I've found that Vdub likes it when instead of the script I put in my first post, I do it like this:

trim(0,106)+trim(107,218).Tcomb(mode=2,fthreshl=12, othreshl=19)+trim(219,491)+trim(492,540).Tcomb(mode=2,fthreshl=12, othreshl=19)+trim(541,563)+trim(564,755).Tcomb(mode=2,fthreshl=12, othreshl=19)...

All in one, big and happy line... Kekekekekeke ;).

stickboy
1st February 2007, 21:26
With ReplaceFramesSimple, you'd do:
ReplaceFramesSimple(Tcomb(mode=2,fthreshl=12, othreshl=19),
\ mappings="[106 218]
[491 540]
[563 755]
[1023 1095]
[1212 1253]
[1346 1504]
[1761 1771]
[2093 2115]
[2544 2593]
[2939 3030]
[3138 3317]
[3417 3505]
[3635 3756]
[3814 3853]
[3976 4088]
[4187 4288]
[4347 4812]
[4920 5086]
[5269 5403]")
You might have to adjust the numbers a bit. Your original FunctionTCombUni function uses really bizarre semantics since it filters on the interval (start, end] instead of [start, end) or even [start, end].

DarkT
1st February 2007, 21:41
Yeah, like, if I see in the video that I want frames 45 to 50 be fltered, I actually enter 44 to 50 :), hahha, it's funny :).

It's proly so that if your first value is 1/0 it won't mess it all up :).

Coincidentally I've read your rant on trim, rememebr? ;) - wasn't it something similiar to those exceptions? Meow :).

stickboy
1st February 2007, 23:09
Coincidentally I've read your rant on trim, rememebr? ;) - wasn't it something similiar to those exceptions? Meow :).Yeah, but the point of my rant was to use my Trim2 function, not to write functions that use Trim and have weird semantics.

DarkT
1st February 2007, 23:42
Hahahahaha, *I* didn't write it :), if I'd be writing it I'd merely make a comment "Don't apply to frames 0/1/2" (2 because we want to be on the safe side) :).

Anyway - thanks for the help man, your script helped me a lot ;), all is well now... And I can keep kickin' ;). Well, atleast untill the next major issue comes ;) - then I'll be running back like a little girl who lost her mommy :).

IanB
3rd February 2007, 01:04
trim(0,106)+trim(107,218).Tcomb(mode=2,fthreshl=12, othreshl=19)+
trim(219,491)+trim(492,540).Tcomb(mode=2,fthreshl=12, othreshl=19)+
trim(541,563)+trim(564,755).Tcomb(mode=2,fthreshl=12, othreshl=19)...Okay, that is part of the way to collapsing your issue. But as I said "Generally start with 2 full clips, 1 original, 1 filtered.". Stickboys ReplaceFramesSimple plug-in obeys this concept and is probably the most straight forward expression of the idea.

The important issue is to avoid creating many separate instances of what is effectively the same filter. There are 2 issues with not doing this.

1. Edge condition with temporal filters. If you Trim(100, 110) the result is an 11 frame clip. If you then apply a temporal filter that wants to do it's magic with the prior, current and next frame, then when processing frame 100 there is no longer a prior frame and likewise for frame 110 there is no longer a next frame. The temporal filter will implement some boundary rules unique to that filter and you will get inconsistant processing at the edges of your trims.

2. Memory wastage from duplicate objects. Some filters like Overlay allocate a set of private buffers. This can represent a large amount of untracked memory if you write your script to mention a large number of these filters.

So your intermediate script would best be served like this :-Clip2=Tcomb(mode=2,fthreshl=12, othreshl=19)
trim(0,106)+Clip2.trim(107,218)+\
trim(219,491)+Clip2.trim(492,540)+\
trim(541,563)+Clip2.trim(564,755)+\
...And this is how Stickboys filter is implemented

DarkT
3rd February 2007, 02:10
It's cool guys ;) - thanks for all of your help, I implemented stickyboy's solution, everything works, I am currently processing the 2nd pass (I chose lagyrinth over huffyuv because huffyuv don' support no yv12 and hence SOME quality loss will occur - or atleast that's what I understood from all of the wiki reading I did...).

It's all really awesome :) - god I love this... Apply this here, that there, use this method to do this...

Even found a way to make the encoding go faster - SAFE MODE! kekekeke, works like a charm :).

Thank you all for the advice, because of people like you I am growing with knowledge by the day.