Home

Awesome

AviSynth Filter and VapourSynth Filter

DirectShow filters that put AviSynth or VapourSynth into video playing, by loading a script and feed the generated frames to video player.

Each filter takes video samples from upstream, feeds them to the frame server in compatible format, and delivers the transformed output frames to downstream.

If you used ffdshow's AviSynth plugin before, you may find these filters similar in many ways. On top of that, our filters are actively adding new features.

Features

Requirement

Install

Uninstall

Run uninstall.cmd to unregister the filters and clean up user data.

安装

卸载

运行 uninstall.cmd 删除注册信息和用户信息。

Usage

Common

By default, 10-bit and 16-bit input formats are enabled for best video quality. However, not all video renderers are capable of processing these data. If you do not have such a video renderer installed, leaving these options on might cause compatibility issues. In that case, you should open the settings page of the filter and untick the relevant checkboxes.

Examples of 10/16-bit capable video renderers: madVR, MPC Video Renderer.

Examples of video renderers having issues: Enhanced Video Renderer (related issue), PotPlayer "Built-in" video renderers (related issue).

The following Reserved Frame Properties are generated (AviSynth+ v3.6.0 and above, VapourSynth):

AviSynth Filter

The filter exposes the following functions to the AviSynth script:

AvsFilterSource()

The source function which returns an IClip object. Similar to other source functions like AviSource().

This function takes no argument.

AvsFilterDisconnect()

This function serves as a heuristic to disconnect the filter itself from DirectShow filter graph. Put at the end of the script file.

It can be used to avoid unnecessary processing and improve performance if the script does not modify the source. Avoid to use it during live reloading.

A good example is if your script applies modifications based on video metadata (e.g. FPS < 30), without using this function, even if the condition does not hold the filter still needs to copy every frame. At best, it wastes both CPU and memory resource for nothing. At worst, it breaks hardware acceleration chain for certain filters. For instance, when LAV Filters connects directly to madVR in D3D11 mode, the GPU decoded frames are not copied to memory. If any filter goes between them, the frame needs to be copied.

This function takes no argument.

AvsFilterGetSourcePath()

Returns the path to the source video file.

This function takes no argument.

VapourSynth

The filter exposes the following variables to the VapourSynth Python script:

VpsFilterSource

This variable has the type of VideoNode. It serves as the source clip.

Note that the fps property of the video node is set to the average framerate instead of 0 / 1, regardless if frames have variable frame durations. It is equivalent to mpv's container_fps variable.

VpsFilterDisconnect

This variable does not exist at the entry of the script. Upon return, if this variable exists and has an non-zero value, it disconnects the filter itself from DirectShow filter graph.

VpsFilterSourcePath

Represents the path to the source video file.

API and Remote Control

Since version 0.6.0, these filters allow other programs to remotely control it via API. By default the functionality is disabled and can be activated from settings (requires restarting the video player after changing).

For details of the API, please refer to the comments in source file api.h.

Example scripts

Add a line of text to videos with less than 20 FPS. Otherwise disconnect the filter.

AviSynth

AvsFilterSource()

fps = Round(FrameRate())
if (fps < 20) {
    Subtitle("This video has low FPS")
    Prefetch(4)
} else {
    AvsFilterDisconnect()
}

VapourSynth

from vapoursynth import core
import math

fps = round(VpsFilterSource.fps)
if fps < 20:
    core.text.Text(VpsFilterSource, 'This video has low FPS').set_output()
else:
    VpsFilterDisconnect = True

Build

A script build.ps1 is included to automate the build process. It obtains dependencies and starts compilation. Before running build.ps1, make sure you have the latest Visual Studio and git installed. When running the script, pass the target configuration and platform as arguments, e.g. build.ps1 -configuration Debug -platform x64 or build.ps1 -configuration Release -platform x86.

Credit

Thanks to Milardo from Doom9's Forum for help initially testing the project.

Thanks to chainikdn from SVP team for contributing features.