Avisynth SelectRangeEvery

From wiki.selur.net
Jump to navigation Jump to search

SelectRangeEvery keeps a block of consecutive frames at regular intervals and drops everything else. It is a core filter of AviSynth+, no plugin is needed.

Filtering → Avisynth → Frame → Reduction

SelectRangeEvery controls in Hybrid
SelectRangeEvery controls in Hybrid

What it does

The clip is cut into cycles of Every frames. From each cycle a block of Length frames, starting Offset frames into the cycle, is kept. The usual use is to cut a short sample out of a long source, for example 50 frames out of every 1500, to compare encoder settings.

Settings

Control Parameter Range Hybrid default Meaning
SelectRangeEvery – on/off off Enables the filter.
Every every 1–1000000 1500 Length of one cycle in frames.
Length length 1–1000000 50 Frames kept per cycle.
Offset offset 0–100000 0 Where the kept block starts inside the cycle.
Adjust FPS – on/off on On: the frame rate is lowered by length / every, so the playing time of the result stays close to the original. Off: the frame rate stays and the clip gets shorter.

Example

Default settings on a 10-bit YUV 4:2:0 source with 30 fps. The result plays at 1 fps:

# adjusting frame count using SelectRangeEvery
SelectRangeEvery(every=1500,length=50,offset=0).AssumeFPS(last.FrameRateNumerator * 1, last.FrameRateDenominator * 30)

How Hybrid calls it

  • Hybrid always writes every, length and offset as named parameters. No plugin is loaded and Hybrid adds no conversion; every color space and bit depth works.
  • The filter needs progressive input and is placed directly after SelectEvery.
  • SelectRangeEvery keeps the frame rate by itself. With Adjust FPS on, Hybrid appends AssumeFPS with the fraction length / every (reduced), so the rate becomes rate × length / every. With it off nothing is appended.
  • Hybrid uses the resulting frame count, which takes the offset into account, and the frame rate for the following steps.
  • SelectRangeEvery also offers the common options and can be added to the filter queue several times.

Background

Example from the AviSynth+ documentation: every 280, length 14, offset 0 keeps frames 0–13, 280–293, 560–573 and so on; with offset 2 it keeps 2–15, 282–295 and so on. The filter's audio parameter is not offered in Hybrid.

See also: Vapoursynth SelectRangeEvery, SelectEvery

Sources