Skip to main content

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. vsfgs gives 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 using MergeDiff.

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 dav1d assembly optimizations (drastically improves grain synthesis performance).
    • Windows: choco install nasm
    • Linux: sudo apt-get install nasm or sudo dnf install nasm
    • macOS: brew install nasm

Build Steps

  1. Clone the repository recursively to fetch the dav1d submodule:

    git clone --recursive https://github.com/PingWer/vs-fgs.git
    cd vs-fgs
    
  2. 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.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for vsfgs 1.1.1
File Size Uploaded Provenance Actions
vsfgs-1.1.1.tar.gz 1.7 MB With provenance Details for vsfgs-1.1.1.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for vsfgs 1.1.1
File Actions
vsfgs-1.1.1-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details for vsfgs-1.1.1-py3-none-win_amd64.whl
vsfgs-1.1.1-py3-none-musllinux_1_2_x86_64.whl Python 3 none Linux musl 1.2+ x86-64 Details for vsfgs-1.1.1-py3-none-musllinux_1_2_x86_64.whl
vsfgs-1.1.1-py3-none-musllinux_1_2_aarch64.whl Python 3 none Linux musl 1.2+ ARM64 Details for vsfgs-1.1.1-py3-none-musllinux_1_2_aarch64.whl
vsfgs-1.1.1-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 for vsfgs-1.1.1-py3-none-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
vsfgs-1.1.1-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 for vsfgs-1.1.1-py3-none-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
vsfgs-1.1.1-py3-none-macosx_11_0_arm64.whl Python 3 none macOS 11.0+ ARM64 Details for vsfgs-1.1.1-py3-none-macosx_11_0_arm64.whl
vsfgs-1.1.1-py3-none-macosx_10_13_x86_64.whl Python 3 none macOS 10.13+ x86-64 Details for vsfgs-1.1.1-py3-none-macosx_10_13_x86_64.whl

Total release size: 4.3 MB

Release files / vsfgs-1.1.1.tar.gz

Download URL vsfgs-1.1.1.tar.gz
Size 1.7 MB
Tags Source
SHA-256 checksum
How to use checksums
44653a29018b74864553bf30b17d45de5ce1b8e8ba0e6bbdf259c13f7b4a98db
BLAKE2b-256 checksum
How to use checksums
ec8a5cf203d001b282ff976754a194d71822d26638e0e4a88fb9574cc62046c5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 10, 2026.

Transparency log

Release files / vsfgs-1.1.1-py3-none-win_amd64.whl

Download URL vsfgs-1.1.1-py3-none-win_amd64.whl
Size 79.8 kB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
2996ec42b827f9c9c566508be045dfdc31d0284913f93d70357befcfe4da7527
BLAKE2b-256 checksum
How to use checksums
5b738b4c9be15e85a424cc4e121248162b55b3278504ede339ea520971769846
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 10, 2026.

Transparency log

Release files / vsfgs-1.1.1-py3-none-musllinux_1_2_x86_64.whl

Download URL vsfgs-1.1.1-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
23e3ee9286d960d659897f48f13942157a39f6a9a7769b39727a1f398a28937a
BLAKE2b-256 checksum
How to use checksums
2bde5fd72ad724d1d118220949410e866f6c054b51695bc9d48f5631d4183977
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 10, 2026.

Transparency log

Release files / vsfgs-1.1.1-py3-none-musllinux_1_2_aarch64.whl

Download URL vsfgs-1.1.1-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
78d42812fcaeed0899e2e9210fe41218726107b5df8e90c72ad272da77397fca
BLAKE2b-256 checksum
How to use checksums
1039dd6aa323b33b1733a2fc1f273681816cceba4be009edb06d7c30b40b04d3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 10, 2026.

Transparency log

Release files / vsfgs-1.1.1-py3-none-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl

Download URL vsfgs-1.1.1-py3-none-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Size 97.2 kB
Tags Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64 Python 3
SHA-256 checksum
How to use checksums
ad8b30475701a66718be913c60c4edd3b66dcb33999cb8d4ac95ee57df028425
BLAKE2b-256 checksum
How to use checksums
e398e51ca8384de5e1cf11b5db43dfffec2fb471c67e9ada237ecdf6d83d3b40
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 10, 2026.

Transparency log

Release files / vsfgs-1.1.1-py3-none-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl

Download URL vsfgs-1.1.1-py3-none-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Size 57.8 kB
Tags Linux glibc 2.24+ ARM64 Linux glibc 2.28+ ARM64 Python 3
SHA-256 checksum
How to use checksums
6a4e7357b6137a625fad8fd518c15ad52dc8aa00127b87589b09c2addcf9150f
BLAKE2b-256 checksum
How to use checksums
a43fe832a91048d8a30e30bc691780c45f01780aa9f8307b7727d56f330bd2d7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 10, 2026.

Transparency log

Release files / vsfgs-1.1.1-py3-none-macosx_11_0_arm64.whl

Download URL vsfgs-1.1.1-py3-none-macosx_11_0_arm64.whl
Size 54.7 kB
Tags Python 3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
1b9ce9052bd336ef06247c23b5e0ac4577c87f6f773434db0cce297495c72e7a
BLAKE2b-256 checksum
How to use checksums
a0fd01cbb8b45e340378788bfba7df927e66b793ad48e809875d6ef55ec91587
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 10, 2026.

Transparency log

Release files / vsfgs-1.1.1-py3-none-macosx_10_13_x86_64.whl

Download URL vsfgs-1.1.1-py3-none-macosx_10_13_x86_64.whl
Size 82.1 kB
Tags Python 3 macOS 10.13+ x86-64
SHA-256 checksum
How to use checksums
bf702dcb2e53d4935fda06cd618563b1640aad248efe20299381bd79b47ea9c1
BLAKE2b-256 checksum
How to use checksums
66fecf0a567514662c0242a25103d6b34d193581884e5e328988992c2d912f68
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 10, 2026.

Transparency log

Security for vsfgs 1.1.1

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.

Full provenance

All 8 files in this release have been uploaded with provenance metadata.

Select from 8 files

Attestation for vsfgs-1.1.1.tar.gz

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 Nov 10, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page