vs-fgs
A VapourSynth plugin for applying Film Grain Synthesis' table (FGS) using the dav1d decoder.
Since dav1d is widely regarded as the best and fastest AV1 decoder available, its FGS engine is fully spec-compliant with AFGS1 (AOMedia Film Grain Synthesis 1), guaranteeing highly accurate, performant, and standardized grain generation.
vsfgs parses standard FGS text files and applies film grain to the input clip natively in 8-bit, 10-bit, or 12-bit YUV.
Why this plugin
Film Grain Synthesis (FGS) represents a massive step forward in video compression, allowing to model film grain mathematically rather than encoding random noise.
This plugin was built with two primary goals in mind:
- Visualizing and Fine-Tuning FGS: It serves as a "real-time" visualization tool during your encoding pipeline. By rendering the grain dynamically, you can preview, adjust, and perfectly tune your FGS tables in relation to the actual video content (especially when paired with tools like FGSE).
- Grain Baking: Not all target codecs (e.g. H.264, VP9, HEVC) support FGS playback, and you don't always want to distribute video files with separate grain metadata.
vsfgsgives you the ability to bake the high-quality, standardized AFGS1 grain directly into the video stream before handing it off to your encoder.
Furthermore, this tool is future-proof for processing official AV1 streams (e.g. Netflix) that already have FGS embedded inside them, allowing you to seamlessly visualize or bake their grain during filtering and re-encoding.
Installation
pip install vsfgs
Usage
import vapoursynth as vs
import vsfgs
core = vs.core
# Load your video clip using your preferred source filter (e.g. BestSource, LSMASH, etc.)
clip = core.bs.VideoSource("source.mkv")
# Apply Film Grain Synthesis using a grain table (.bin or .txt):
# - ignore_chroma: If True, grain is only applied to Luma (Chroma is copied).
# - static: If True, uses the seed from the FGS table for all frames (if dynamic FGS, per event). If False, rotates the seed for each frame. Note: for `.bin` files, dynamic_seed is disabled automatically.
# - simd: Hardware SIMD architecture ('auto', 'avx512', 'avx2', 'sse41', 'sse3', 'sse2', or 'none'/'c' for plain C). Defaults to 'auto'.
clip = vsfgs.apply_fgs(clip, "grain_table.bin", ignore_chroma=False, static=False, simd="auto")
clip.set_output()
For detailed parameter types and descriptions, check the function docstrings.
Frame Properties
For each processed frame, vsfgs outputs the exact seed integer used during synthesis into the VapourSynth frame properties: FGS_Seed
Input Format & Advanced Customization
vsfgs supports input grain files in both standard .txt (AFGS1 textual format) and directly compiled .bin (Binary format). It allows for extreme and advanced customization of the film grain synthesis pattern.
For complete details on the required text syntax, binary packing parameters, and an advanced visual editor to create and fine-tune these tables, please refer to the FGSEditor wiki: https://github.com/PingWer/FGSEditor
Technical & Implementation Notes
High Bit-Depth & Precision Preservation
The underlying dav1d FGS synthesis engine strictly operates on 8-bit, 10-bit, or 12-bit integer YUV clips.
To support higher bit-depths (>12-bit integer or Float formats) without quality loss:
- The input clip is temporarily converted to 12-bit integer using
dither_type="none". - Film grain is synthesized at 12-bit depth.
- The isolated grain pattern (delta) is extracted via
MakeDiff, scaled back to match the original clip format, and applied onto the untouched original clip usingMergeDiff.
This approach completely eliminates quantization and dithering alterations.
Performance & Compatibility
vsfgs uses dav1d's hand-written Assembly instructions (AVX-512, AVX2, SSE3 ...), resulting in extremely high throughput with almost zero overhead.
Platform Support:
| OS | Architecture | Supported | Tested |
|---|---|---|---|
| Windows | x86_64, ARM64 | ✅ | ✅ |
| Linux | x86_64, aarch64 | ✅ | ✅ |
| macOS | x86_64, Apple Silicon | ✅ | ❌ |
Benchmark Comparison (2,000 frames of real 1080p source via BestSource):
Tests compared vsfgs against Grainer.GAUSS (from vsjetpack). It also demonstrates the speedup of dav1d's hardware SIMD Assembly optimizations over unvectorized reference C code (simd='none').
| Format | Baseline (BestSource + 16bit conversion) | vsfgs (SIMD: Auto / AVX-512) |
vsfgs (SIMD: None / Plain C) |
Grainer.GAUSS (vsjetpack) |
|---|---|---|---|---|
| YUV420P16 | ~1128 FPS | ~557 FPS | ~514 FPS | ~347 FPS |
| YUV422P16 | ~866 FPS | ~434 FPS | ~425 FPS | ~322 FPS |
| YUV444P16 | ~649 FPS | ~305 FPS | ~299 FPS | ~279 FPS |
Building from Source
To compile the plugin manually, you must have a working C++ toolchain and Meson setup. The plugin depends on dav1d, which will be built automatically as a Meson subproject.
Prerequisites
- Python 3.13+ (or newer)
- C++ Compiler: GCC/Clang (Linux/macOS) or MSVC (Windows)
- Meson & Ninja: Build system (
pip install meson ninja) - nasm: Highly recommended for x86/x64 systems to enable
dav1dassembly optimizations (drastically improves grain synthesis performance).- Windows:
choco install nasm - Linux:
sudo apt-get install nasmorsudo dnf install nasm - macOS:
brew install nasm
- Windows:
Build Steps
-
Clone the repository recursively to fetch the
dav1dsubmodule:git clone --recursive https://github.com/PingWer/vs-fgs.git cd vs-fgs
-
Build and install the plugin directly into your active Python environment:
pip install .
Standalone Build (Without Python Installation)
If you only want to compile the VapourSynth plugin binary (DLL/SO/DYLIB) without installing it via pip, you can use Meson directly:
meson setup build --buildtype=release --vsenv
meson compile -C build
TODO
Any suggestions are welcome! But, the plugin is basically feature complete.
Community & Support
For questions, feedback, or troubleshooting, feel free to join and reach out on the AV1 Weeb edition Discord server
License
This project is licensed under the MIT License.
Third-Party Licenses
This project includes and statically links code from dav1d (located in subprojects/dav1d), which is licensed under the BSD 2-Clause License:
Copyright © 2018-2025, VideoLAN and dav1d authors. All rights reserved.
Licensed under the BSD 2-Clause License.
Metadata
Release files for vsfgs 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| vsfgs-1.1.0.tar.gz | 1.7 MB | Details |
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| vsfgs-1.1.0-py3-none-win_amd64.whl | Python 3 | none | Windows x86-64 | Details |
| vsfgs-1.1.0-py3-none-musllinux_1_2_x86_64.whl | Python 3 | none | Linux musl 1.2+ x86-64 | Details |
| vsfgs-1.1.0-py3-none-musllinux_1_2_aarch64.whl | Python 3 | none | Linux musl 1.2+ ARM64 | Details |
| vsfgs-1.1.0-py3-none-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl | Python 3 | none | Linux glibc 2.24+ x86-64, Linux glibc 2.28+ x86-64 | Details |
| vsfgs-1.1.0-py3-none-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl | Python 3 | none | Linux glibc 2.28+ ARM64, Linux glibc 2.24+ ARM64 | Details |
| vsfgs-1.1.0-py3-none-macosx_11_0_arm64.whl | Python 3 | none | macOS 11.0+ ARM64 | Details |
| vsfgs-1.1.0-py3-none-macosx_10_13_x86_64.whl | Python 3 | none | macOS 10.13+ x86-64 | Details |
Total release size: 4.3 MB
Release files / vsfgs-1.1.0.tar.gz
| Download URL | vsfgs-1.1.0.tar.gz |
|---|---|
| Size | 1.7 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
99a3cc17c6127993044dbbacee97a1be2b726c2daf935363045e0e482e8d25fd
|
|
BLAKE2b-256 checksum How to use checksums |
874dbf1abc86f5e303509a5abb4809003e944d1ccd6af217a991b408b0259a1c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 3, 2026.
Transparency logRelease files / vsfgs-1.1.0-py3-none-win_amd64.whl
| Download URL | vsfgs-1.1.0-py3-none-win_amd64.whl |
|---|---|
| Size | 79.6 kB |
| Tags | Python 3 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
2ee9f3247727b734e98b884cde552e6239ec3edca695b62ed58279369740a6d8
|
|
BLAKE2b-256 checksum How to use checksums |
07c9708205d5008e945b4f0e595d959a865ebc145d432a7898880e2956d522ee
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 3, 2026.
Transparency logRelease files / vsfgs-1.1.0-py3-none-musllinux_1_2_x86_64.whl
| Download URL | vsfgs-1.1.0-py3-none-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 1.1 MB |
| Tags | Linux musl 1.2+ x86-64 Python 3 |
|
SHA-256 checksum How to use checksums |
5095bd2a3cfb9c65993eafe95f111eee7020b463896ef31e5a09b2bad0636050
|
|
BLAKE2b-256 checksum How to use checksums |
80c1cfafa7b9a7953d4f4364a8ae25638d9972189344fe24e7a2b7c49ca7126c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 3, 2026.
Transparency logRelease files / vsfgs-1.1.0-py3-none-musllinux_1_2_aarch64.whl
| Download URL | vsfgs-1.1.0-py3-none-musllinux_1_2_aarch64.whl |
|---|---|
| Size | 1.0 MB |
| Tags | Linux musl 1.2+ ARM64 Python 3 |
|
SHA-256 checksum How to use checksums |
136ea8866bf8fd50c9f9fda1235308d68d3eaa58e15021aace0e7e603a805c84
|
|
BLAKE2b-256 checksum How to use checksums |
d78af735a8dd81e7ba2b0e64b626189d0a71d275e2ae40b7e41ec5d40ce516a2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 3, 2026.
Transparency logRelease files / vsfgs-1.1.0-py3-none-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
| Download URL | vsfgs-1.1.0-py3-none-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl |
|---|---|
| Size | 97.0 kB |
| Tags | Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64 Python 3 |
|
SHA-256 checksum How to use checksums |
17377573b77fa7cd88eb38ce244a08274ede1fac69ad51d1fdd01d848b0cf839
|
|
BLAKE2b-256 checksum How to use checksums |
f60a8ace1c17500000e25c69ef7cb6041625f36067228cb9ed2938e90f7e6902
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 3, 2026.
Transparency logRelease files / vsfgs-1.1.0-py3-none-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
| Download URL | vsfgs-1.1.0-py3-none-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl |
|---|---|
| Size | 57.6 kB |
| Tags | Linux glibc 2.24+ ARM64 Linux glibc 2.28+ ARM64 Python 3 |
|
SHA-256 checksum How to use checksums |
8d447a518d0a15878c0e6062620bd0e95c6337c2117a9691d65d5a58473a0a34
|
|
BLAKE2b-256 checksum How to use checksums |
b491a0346e166ee012f1e5a7a8b7703760ac31d153b9e3a50b5ad7585a846cca
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 3, 2026.
Transparency logRelease files / vsfgs-1.1.0-py3-none-macosx_11_0_arm64.whl
| Download URL | vsfgs-1.1.0-py3-none-macosx_11_0_arm64.whl |
|---|---|
| Size | 54.4 kB |
| Tags | Python 3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
a321080f00369067db3b47180822f1971986ff8944d5d0bc9d792ac19fd98242
|
|
BLAKE2b-256 checksum How to use checksums |
912b21e3525750744a5ffe8ebf01b873f64b7de54c9ad0110c77cece2094041c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 3, 2026.
Transparency logRelease files / vsfgs-1.1.0-py3-none-macosx_10_13_x86_64.whl
| Download URL | vsfgs-1.1.0-py3-none-macosx_10_13_x86_64.whl |
|---|---|
| Size | 81.9 kB |
| Tags | Python 3 macOS 10.13+ x86-64 |
|
SHA-256 checksum How to use checksums |
08979e8b84838847764251c2605c3c6729799a68e795b5b5dd35bf307bc3e01c
|
|
BLAKE2b-256 checksum How to use checksums |
d26eed01c79ab015813f1d5cb864732877d16dfc45432d2a91d8b218f2599db1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 3, 2026.
Transparency log