Sampler

An Avisynth filter for pulling samples from a clip

By Ross Thomas <ross@grinfinity.com>

There is no copyright on this code, and there are no conditions on its distribution or use. Do with it what you will.

Description

This is a very simple Avisynth filter to construct "sample strips" from the source clip. This concept is best explained with an example. Suppose you had a source clip that was 10 frames in length, and you used this filter to extract 3 samples, each 2 frames in length. The resulting clip would be exactly 6 frames long, and would be made up of the 1st, 2nd, 5th, 6th, 9th and 10th frames of the original clip. Or, graphically, this clip:

<--Sample 1->               <--Sample 2->               <--Sample 3->

.----. .----. .----. .----. .----. .----. .----. .----. .----. .----.
| 1 | | 2 | | 3 | | 4 | | 5 | | 6 | | 7 | | 8 | | 9 | | 10 |
'----' '----' '----' '----' '----' '----' '----' '----' '----' '----'

becomes this clip:

<--Sample 1-> <--Sample 2-> <--Sample 3->
.----. .----. .----. .----. .----. .----.
| 1 | | 2 | | 5 | | 6 | | 9 | | 10 |
'----' '----' '----' '----' '----' '----'

In other words, this filter pulls out the specified number of evenly distributed samples of the specified length from the source clip and concatenates them into one clip which will always be precisely samples-times-sample-length frames long.

Usage

Sampler(clip clip, int samples, int length)

Parameter Meaning Default
clip

Specifies the clip to affect.

last

samples The number of samples to take from the clip. Running time of clip in minutes
length The length of each sample in frames.

1 second (i.e., the clip's frame rate rounded to the nearest integer)

Known Issues

TODO

Author

Ross Thomas <ross@grinfinity.com>

History

Version Description
0.2a Changed defaults to samples=movie_length_in_minutes and length=one_second.
0.2 Added audio support. Recompiled 2.5 with latest avisynth.h and renamed AvisynthPluginInit to AvisynthPluginInit2. Enabled "full optimization" for release builds.
0.1a AKA stupid bugfix release 1: 2.5 version is now actually compiled for 2.5 and not 2.0. Added SetCacheHints for 2.5 version and fixed, er, minor documentation bug ;).
0.1 First release. Alpha code. Danger, Will Robinson!