Skip to main content

Grain Overlay and Generate functions for VapourSynth


Installation

pip install -U vs_grain

For older vapoursynth versions below R74, follow the manual installation steps here.


Generate Realistic Film Grain

Helper function for the very realistic grain generator fgrain that animates the grain, adds opacity options, and support for YUV. Grain is only applied to luma. Requires an Nvidia GPU.

import vs_grain
clip = vs_grain.fgrain(clip, iterations=800, size=0.3, deviation=0.0, blur=0.8, opacity=[0.5, 0.5, 0.5], num_streams=1)

clip
Clip to apply grain to.
Must be in YUV or GRAY format.

iterations
Higher values look more realistic. Lower values are faster but result in grain that looks less natural.

size
Average size of grain particles.

deviation
Deviation of size, or how much variation there is in the size of grain particles. High values can cause bad outputs, use with caution.

blur
Generates smoother grain.

opacity
Opacity of generated grain. Can be a list [0.5, 1.0, 0.5] for shadows/midtones/highlights, or a single value for everything.

num_streams
Number of parallel GPU streams. For high end GPUs higher can be a bit faster, but requires more VRAM.


Overlay Grain Clip

Bring your own grain clip and overlay it on top of your base clip. This automatically loops the grain clip, crops if too large or stacks if too small.

import vs_grain
clip = vs_grain.overlay(clip, grain, blend_mode="overlay", size=1.0, blur=0.0, opacity=[1.0, 1.0, 1.0], planes=[0, 1, 2])

clip
Clip to apply grain to.
Must be in YUV or GRAY format.

grain
Grain clip to overlay. This is expected to be grain on a neutral mid-gray background.
Must be the same format as the base clip.

blend_mode
Method used to blend the grain clip with the base clip. Available blend modes:

  • grainshow Shows the grain without blending.
  • grainmerge Grain is applied everywhere with the same impact.
  • grainextract Inverse of grainmerge. Removes grain added via grainmerge.
  • overlay Grain has strongest impact in midtones and fades toward shadows/highlights.
  • hardlight Opposite of overlay, meaning grain gets stronger toward shadows/highlights.
  • softlight Similar to overlay, but dark grains get weaker in shadows and bright grains get weaker in highlights.
  • vividlight Dark grains get stronger in shadows and bright grains get stronger in highlights.

size
Multiplicator to resize grain clip. Will automatically crop if too large or repeat if too small.

blur
Smoothes the grain by blurring the grain clip.

opacity
Opacity of grain clip. Can be a list [0.5, 1.0, 0.5] for shadows/midtones/highlights, or a single value for everything.

planes
Which planes should be affected by the grain clip. Any unmentioned planes will simply be copied.
If nothing is set, the grain will be applied to all planes.

Metadata

Release files for vs-grain 2.1.0

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

Source distribution (sdist)

Source distribution for vs-grain 2.1.0
File Size Uploaded Provenance Actions
vs_grain-2.1.0.tar.gz 7.2 kB With provenance Details for vs_grain-2.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for vs-grain 2.1.0
File Interpreter ABI Platform Actions
vs_grain-2.1.0-py3-none-any.whl Python 3 none any Details for vs_grain-2.1.0-py3-none-any.whl

Total release size: 15.0 kB

Release files / vs_grain-2.1.0.tar.gz

Download URL vs_grain-2.1.0.tar.gz
Size 7.2 kB
Tags Source
SHA-256 checksum
How to use checksums
276d5224de4bb39a11595c705a65604b79023d70ba3f5b2da57c5af37e752e3a
BLAKE2b-256 checksum
How to use checksums
e7015ba3cafac14cb13c4b405706c9a7c0ce085381479ef82ad61fb5711d0daa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 Jul 15, 2026.

Transparency log

Release files / vs_grain-2.1.0-py3-none-any.whl

Download URL vs_grain-2.1.0-py3-none-any.whl
Size 7.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6323bb6acb14a9f2eea495bd305dec931618f3d94b62ffb1555c006df875d43c
BLAKE2b-256 checksum
How to use checksums
e1248e4f61fe0c7edd0ad9caf2bbd08f50daa9e0e4ec05d261029e35a5c4ff2d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 Jul 15, 2026.

Transparency log

Security for vs-grain 2.1.0

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 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for vs_grain-2.1.0.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 Jul 15, 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.

Release history Release notifications | RSS feed

This release

2.1.0 This release

2 release files Full provenance

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