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.2

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.2
File Size Uploaded Provenance Actions
vsfgs-1.1.2.tar.gz 1.7 MB With provenance Details for vsfgs-1.1.2.tar.gz

Built distributions (wheels)

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

Total release size: 4.3 MB

Release files / vsfgs-1.1.2.tar.gz

Download URL vsfgs-1.1.2.tar.gz
Size 1.7 MB
Tags Source
SHA-256 checksum
How to use checksums
1786b42a4f2a1b5cf035867bd2e6e4fe4feb07c9768eaaea5662e18900aa3211
BLAKE2b-256 checksum
How to use checksums
bed287e07a888d4d29b0b628ccc86bfd0f2e7938c0d0a0fefbf97f658a8c23c4
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 14, 2026.

Transparency log

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

Download URL vsfgs-1.1.2-py3-none-win_amd64.whl
Size 80.5 kB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
d4927838b261dc3d4aef79827cf9fc76cbc9b5841690e43cdf0d473203fdabef
BLAKE2b-256 checksum
How to use checksums
b4282590263871c735369242e8a41599649ede04dcd12fc99b52945c0e96be87
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 14, 2026.

Transparency log

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

Download URL vsfgs-1.1.2-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
ccf23f42514525d681eba4e6ac7c983ee714f618d773f82e47a1f06412559896
BLAKE2b-256 checksum
How to use checksums
541c388f891c120f50b4256b871986738be98ce99fe346f7e9762f9d9d4b8731
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 14, 2026.

Transparency log

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

Download URL vsfgs-1.1.2-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
eeaf42644df732def3eda45fec32de06b2d9d0ca711108ef3ee1b03ba6f77911
BLAKE2b-256 checksum
How to use checksums
b66b7072dbd81a8530431524e9e566a148a1b0cbcba2227342075937b93422d5
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 14, 2026.

Transparency log

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

Download URL vsfgs-1.1.2-py3-none-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Size 97.9 kB
Tags Linux glibc 2.24+ x86-64 Linux glibc 2.28+ x86-64 Python 3
SHA-256 checksum
How to use checksums
af76c9b240fd963694c3e1781d5c3f252add6e06662fa33f5fab095ae6056f78
BLAKE2b-256 checksum
How to use checksums
bf038e1199d7b39e571674423c6fd13327e27ef1cab59152a6d4e93ef35df147
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 14, 2026.

Transparency log

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

Download URL vsfgs-1.1.2-py3-none-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Size 58.5 kB
Tags Linux glibc 2.24+ ARM64 Linux glibc 2.28+ ARM64 Python 3
SHA-256 checksum
How to use checksums
686bbabe2f2aa87426faa7e22ba635f5be37d31d151946520ba70799f24cb9ca
BLAKE2b-256 checksum
How to use checksums
e2a4a98d98817cf33215da74315b4b0ec66c3a2377bb94edc9b3e9ad33ec7553
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 14, 2026.

Transparency log

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

Download URL vsfgs-1.1.2-py3-none-macosx_11_0_arm64.whl
Size 55.3 kB
Tags Python 3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
5edf0430f6ecfa6d8c2c0ea63b6ec46d8706ee706df30106d071b88d609db57b
BLAKE2b-256 checksum
How to use checksums
6787d29ed60245fdcb40c40a3af1be4d5141c7acbedb8af5cfb643eb97c7b3c1
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 14, 2026.

Transparency log

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

Download URL vsfgs-1.1.2-py3-none-macosx_10_13_x86_64.whl
Size 82.8 kB
Tags Python 3 macOS 10.13+ x86-64
SHA-256 checksum
How to use checksums
b7da09728aed035b197349e5458cd008b7a2454f29e78b83c7b93d096cdb98e2
BLAKE2b-256 checksum
How to use checksums
7e377ddb802874b6f1d347c40289ddfbe73dff9cc18b8f5fa10d2163609bcafe
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 14, 2026.

Transparency log

Security for vsfgs 1.1.2

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.2.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 14, 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