Log in

View Full Version : AVS - SelectEvery() further explanation please?


vhelp
14th October 2003, 03:11
Hello AVS guru's..

Can someone please explain the proper usage of the following function:
* SelectEvery()

in a more simpler approach that even a child would understand (like me)
cause I'm still confused how to apply it to different scenarios.

I've ben to the FAQ and AVS forums and AVS help sites but all that I
have ben to have copied the same popular explanation of it.

Can someone give me some more examples please ??

Thank you,
-vhelp

Mug Funky
14th October 2003, 06:40
well... the popular explanation does explain the function of the filter, so i'm not sure what else i might add to it...

it's mainly useful when you've bobbed a video (ie. turned fields into their own frames) and want to put the original field order back.

selectevery will decimate the stream in whatever way you choose

the first parameter states the size of the frame group you're decimating, so if you wanted to only keep the first and last frames in every given group of 10, you'd go: selectevery(10,0,9).

any parameters following the first one specify which frame in that group you want to keep. this can be any number, in any order.

one thing to note is that selectevery is a little odd with frame 0's. i haven't quite worked it out myself, but a script like:

trim(0,10) # gives 11 frames
selectevery(10,1,2,3,4,5,6,7,8,9,10) # gives 10 frames
selectevery(10,0,1,2,3,4,5,6,7,8,9,10) # gives 12 frames??

it's a bit confusing, but usually one doesn't have to worry. i think in the latter selectevery, it should end with 9 instead of 10... the most common use of selectevery is to "un-bob" a stream, that is:

bob() # gives twice the framerate
separatefields() # splits the bobbed stream into another double, with alternating lines per frame
selectevery(4,0,3) # selects of the 4 frames per original 1 frame, the very first field and the last field, corresponding to "top" and "bottom" fields of a video frame
weave() - puts these fields back into frames. the output should be interlaced exactly the same way as the input.

the reason you'd do that would be for resizing interlaced video, or running flters that aren't sensitive to interlacing (like vaguedenoiser).

stickboy
14th October 2003, 06:41
Imagine that SelectEvery(n, ...) divides up a clip into groups, each containing n frames. These frames are then numbered 0, 1, ..., n - 1. The values you pass in the "..." specify which frames in each group to keep.

Here are some examples:

SelectEvery(10, 0) generates a clip containing frames 0, 10, 20, 30, .... All other frames are discarded.

SelectEvery(5, 0) selects frames 0, 5, 10, 15, ...
SelectEvery(10, 1) selects frames 1, 11, 21, 31, ...
SelectEvery(10, 2) selects frames 2, 12, 22, 32, ...
SelectEvery(10, 1, 2) selects frames 1, 2, 11, 12, 21, 22, 31, 32, ...

SelectEvery(10) is supposed to be the same as SelectEvery(10, 0), but there's a bug that disallows that usage.

stickboy
14th October 2003, 06:52
Originally posted by Mug Funky
so if you wanted to only keep the first and last frames in every given group of 10, you'd go: selectevery(10,1,10).This is not correct. Numbering in each group starts at 0 and, in your example, logically ends at 9. Therefore it should be SelectEvery(10, 0, 9).

Although SelectEvery(n, ..., m, ...) where m >= n is allowed, it's not a good idea to use that. For well-defined behavior, m should be strictly less than n.one thing to note is that selectevery is a little odd with frame 0's. i haven't quite worked it out myself, but a script like:

trim(0,10) # gives 11 frames
selectevery(10,1,2,3,4,5,6,7,8,9,10) # gives 10 framesYour clip is 10 frames because you threw away frame 0.
selectevery(10,0,1,2,3,4,5,6,7,8,9,10) # gives 12 frames??It's 12 frames because you no longer discard frame 0. This increases the frame count to 11. Furthermore, you duplicate frame 10 (it's selected twice; once by the 0 and again by the 10), increasing the frame count to 12.

Mug Funky
14th October 2003, 09:35
hehe... yeah, i wasn't quite sure about it, but worked it out as i was typing.

too lazy to edit my post.