Vapoursynth functions to generate realistic film grain (via fgrain) and for overlaying external grain clips.
Project description
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.
[!TIP] If fgrain is too slow for you, try generating a short grain clip on neutral mid-gray background and then use the overlay function to apply it to the whole clip.
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:
grainshowShows the grain without blending.grainmergeGrain is applied everywhere with the same impact.grainextractInverse of grainmerge. Removes grain added via grainmerge.overlayGrain has strongest impact in midtones and fades toward shadows/highlights.hardlightOpposite of overlay, meaning grain gets stronger toward shadows/highlights.softlightSimilar to overlay, but dark grains get weaker in shadows and bright grains get weaker in highlights.vividlightDark 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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file vs_grain-2.1.0.tar.gz.
File metadata
- Download URL: vs_grain-2.1.0.tar.gz
- Upload date:
- Size: 7.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
276d5224de4bb39a11595c705a65604b79023d70ba3f5b2da57c5af37e752e3a
|
|
| MD5 |
d90c1ba0ab1c184d8a83f2c68a2eaa52
|
|
| BLAKE2b-256 |
e7015ba3cafac14cb13c4b405706c9a7c0ce085381479ef82ad61fb5711d0daa
|
Provenance
The following attestation bundles were made for vs_grain-2.1.0.tar.gz:
Publisher:
publish.yml on pifroggi/vs_grain
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
vs_grain-2.1.0.tar.gz -
Subject digest:
276d5224de4bb39a11595c705a65604b79023d70ba3f5b2da57c5af37e752e3a - Sigstore transparency entry: 2171184048
- Sigstore integration time:
-
Permalink:
pifroggi/vs_grain@f632bb23481c671057265f1230607f3b4a444464 -
Branch / Tag:
refs/tags/v2.1.0 - Owner: https://github.com/pifroggi
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@f632bb23481c671057265f1230607f3b4a444464 -
Trigger Event:
release
-
Statement type:
File details
Details for the file vs_grain-2.1.0-py3-none-any.whl.
File metadata
- Download URL: vs_grain-2.1.0-py3-none-any.whl
- Upload date:
- Size: 7.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6323bb6acb14a9f2eea495bd305dec931618f3d94b62ffb1555c006df875d43c
|
|
| MD5 |
563132b4bd7ffcb338d22420c3b9ad73
|
|
| BLAKE2b-256 |
e1248e4f61fe0c7edd0ad9caf2bbd08f50daa9e0e4ec05d261029e35a5c4ff2d
|
Provenance
The following attestation bundles were made for vs_grain-2.1.0-py3-none-any.whl:
Publisher:
publish.yml on pifroggi/vs_grain
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
vs_grain-2.1.0-py3-none-any.whl -
Subject digest:
6323bb6acb14a9f2eea495bd305dec931618f3d94b62ffb1555c006df875d43c - Sigstore transparency entry: 2171184078
- Sigstore integration time:
-
Permalink:
pifroggi/vs_grain@f632bb23481c671057265f1230607f3b4a444464 -
Branch / Tag:
refs/tags/v2.1.0 - Owner: https://github.com/pifroggi
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@f632bb23481c671057265f1230607f3b4a444464 -
Trigger Event:
release
-
Statement type: