cranexpr
cranexpr is like std.Expr
but built on top of Cranelift. It's a VapourSynth
plugin that allows one to evaluate an expression per pixel.
Examples
Median of 3 clips:
core.cranexpr.Expr([x, y, z], "x y min x y max z min max")
Flip a clip horizontally:
core.cranexpr.Expr([x], "width X - 1 - Y x[]")
3x3 box blur:
core.cranexpr.Expr([x], "x[-1,-1] x[0,-1] x[1,-1] x[-1,0] x x[1,0] x[-1,1] x[0,1] x[1,1] + + + + + + + + 9 /")
Features
- Arithmetic:
+,-,*,/,%,pow,exp,log,sqrt. - Trigonometry:
sin,cos,tan,atan2. - Comparison:
>,<,=,>=,<=. - Logical:
and,or,xor,not. - Bitwise:
bitand,bitor,bitxor,bitnot. - Clamping:
min,max,clip(alias:clamp). - Rounding:
floor,round,trunc. - Ternary (if/else):
?. sgn: Returns the sign of a value (-1 if negative, 1 if positive, 0 if zero).- Constants:
width: Width of the plane.height: Height of the plane.N: Current frame number.pi: π.
- Stack manipulation:
dropN,drop: drops the top N values from the stack.dropis equivalent todrop1.dupN,dup: allows a value N steps up in the stack to be duplicated. The top value of the stack has index 0 meaning thatdupis equivalent todup0.swapN,swap: allows a value N steps up in the stack to be swapped. The top value of the stack has index 0 meaning thatswapis equivalent toswap1. This is becauseswapNalways swaps with the topmost value at index 0.
- Variables:
var!: Pops the top value from the stack and stores it in a variable namedvar.var@: Pushes the value of the variablevaronto the stack.
- Frame property access:
clip.PropertyName.- Accesses a numeric frame property from the given clip.
- If the property is missing, its value will be
NaN. - If the property is not a numeric frame property, its value will be the first byte.
- Relative pixel access:
clip[relX, relY]:[mode].- Accesses a pixel relative to the current coordinate (
X,Y).relXandrelYmust be integer constants. - If no suffix is provided, the edge behavior is determined by the filter's
boundaryparameter.:c: Forces clamped boundary.:m: Forces mirrored boundary.
- Accesses a pixel relative to the current coordinate (
- Absolute pixel access:
absX absY clip[]:[mode].- Accesses a pixel at an absolute coordinate. It pops
absYthenabsXfrom the stack. These coordinates can be computed by expressions. - If the coordinates are not integers, they will be rounded half to even.
- Example:
X 2 / Y x[]reads the pixel at half the current X coordinate from the first clip, using the default clamp mode. - Boundary Suffixes:
:c: Forces clamped boundary.:m: Forces mirrored boundary.
- Accesses a pixel at an absolute coordinate. It pops
- Supports any number of input clips.
srcNmay be used to access theN-th input clip. Shorthand aliasesx,y,z,a,b,c, etc. map tosrc0,src1,src2,src3,src4,src5, etc., up towbeingsrc25. Beyond that, usesrcN.
Install
pip install vapoursynth-cranexpr
API
cranexpr.Expr(
clips: vs.VideoNode | Sequence[vs.VideoNode],
expr: str | list[str],
format: int | None = None,
boundary: Literal[0, 1] = 0,
) -> vs.VideoNode
clips— Input video nodes.expr— Reverse Polish Notation (RPN) expression(s) for each plane. The expression given for the previous plane is used if the list contains fewer expressions than the input clip has planes. This means that a single expression will be applied to all planes by default.format— By default the output format is the same as the first input clip's format. This can be overridden by setting this parameter.boundary— Boundary mode.0for clamping,1for mirroring.
cranexpr.PropExpr(
clips: vs.VideoNode | Sequence[vs.VideoNode],
**kwargs: str,
) -> vs.VideoNode
clips— Input video nodes. The first clip's format is used for the output.**kwargs— Each keyword argument maps a frame property name to a RPN expression. The expression is evaluated once per frame and the result is written back as a frame property on the output.
PropExpr evaluates expressions that produce scalar values and stores them as
frame properties on the output frame. All expressions are evaluated before any
properties are written.
If the computed value is an exact integer, then it is stored as an integer frame property. Otherwise it is stored as a float.
PropExpr supports all operators supported by Expr except those that access
pixel values (x/y/srcN as pixel values, relative pixel access like
x[-1,0], absolute pixel access like x[], and the per-pixel coordinate
variables X and Y).
cranexpr.Select(
clip_src: vs.VideoNode | Sequence[vs.VideoNode],
prop_src: vs.VideoNode | Sequence[vs.VideoNode],
expr: str | list[str],
) -> vs.VideoNode
clip_src— Candidate clips. All must have the same format and dimensions.prop_src— Clips whose frame properties the expression may read.expr— Reverse Polish Notation (RPN) expression(s) for each plane. The expression given for the previous plane is used if the list contains fewer expressions than the input clip has planes. This means that a single expression will be applied to all planes by default.
Select evaluates a RPN expression once per frame (per plane) and uses the
result as an index to pick a clip from clip_src to satisfy the current frame
request. It is designed to replace many uses of std.FrameEval where you want
to compute a metric from frame properties and then choose one of several clips
to use.
For each output frame and each plane, the filter evaluates the plane's
expression, rounds the result to the nearest integer, clamps it to the range
[0, len(clip_src) - 1], then takes that plane from clip_src[index]'s frame
n.
Select supports all operators supported by Expr except those that access
pixel values (x/y/srcN as pixel values, relative pixel access like
x[-1,0], absolute pixel access like x[], and the per-pixel coordinate
variables X and Y).
Unlike Expr, where a non-existent frame property evaluates to NaN, Select
uses 0.0 instead.
Metadata
Release files for vapoursynth-cranexpr 0.12.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 | Provenance | Actions |
|---|---|---|---|---|
| vapoursynth_cranexpr-0.12.0.tar.gz | 102.5 kB | With provenance | Details for vapoursynth_cranexpr-0.12.0.tar.gz |
Built distributions (wheels)
| File | Actions Reset | |||
|---|---|---|---|---|
| vapoursynth_cranexpr-0.12.0-py3-none-win_amd64.whl | Python 3 | none | Windows x86-64 | Details for vapoursynth_cranexpr-0.12.0-py3-none-win_amd64.whl |
| vapoursynth_cranexpr-0.12.0-py3-none-manylinux_2_28_x86_64.whl | Python 3 | none | Linux glibc 2.28+ x86-64 | Details for vapoursynth_cranexpr-0.12.0-py3-none-manylinux_2_28_x86_64.whl |
| vapoursynth_cranexpr-0.12.0-py3-none-manylinux_2_28_aarch64.whl | Python 3 | none | Linux glibc 2.28+ ARM64 | Details for vapoursynth_cranexpr-0.12.0-py3-none-manylinux_2_28_aarch64.whl |
| vapoursynth_cranexpr-0.12.0-py3-none-macosx_13_0_x86_64.whl | Python 3 | none | macOS 13.0+ x86-64 | Details for vapoursynth_cranexpr-0.12.0-py3-none-macosx_13_0_x86_64.whl |
| vapoursynth_cranexpr-0.12.0-py3-none-macosx_13_0_arm64.whl | Python 3 | none | macOS 13.0+ ARM64 | Details for vapoursynth_cranexpr-0.12.0-py3-none-macosx_13_0_arm64.whl |
Total release size: 15.8 MB
Release files / vapoursynth_cranexpr-0.12.0.tar.gz
| Download URL | vapoursynth_cranexpr-0.12.0.tar.gz |
|---|---|
| Size | 102.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
218afaaf546aa52bb828bdb12fac88c7132b7bab1214bb875acd44b30afac864
|
|
BLAKE2b-256 checksum How to use checksums |
e9654ce977b877b41b46a95a224dab3dd5cf3205cfd523c56d9c102a06110426
|
| 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 Aug 4, 2026.
Transparency logRelease files / vapoursynth_cranexpr-0.12.0-py3-none-win_amd64.whl
| Download URL | vapoursynth_cranexpr-0.12.0-py3-none-win_amd64.whl |
|---|---|
| Size | 4.9 MB |
| Tags | Python 3 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
8d9a327623ff665a5ef917cbf789ee5b16d010d3e12524ba9fc3491500b952c8
|
|
BLAKE2b-256 checksum How to use checksums |
bf7ff483c6bfcae598e0874d42a391368dedfa6e5094fec0b5fec81ad827f1a5
|
| 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 Aug 4, 2026.
Transparency logRelease files / vapoursynth_cranexpr-0.12.0-py3-none-manylinux_2_28_x86_64.whl
| Download URL | vapoursynth_cranexpr-0.12.0-py3-none-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 5.3 MB |
| Tags | Linux glibc 2.28+ x86-64 Python 3 |
|
SHA-256 checksum How to use checksums |
d976f5423604c041956a9b3b5d32a10d61839f2bb473f2bfb8d33692bdaf0949
|
|
BLAKE2b-256 checksum How to use checksums |
d05b14757f41255d5d67c6614c05feb830bf6c09499cd99c86b23aa6560b2098
|
| 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 Aug 4, 2026.
Transparency logRelease files / vapoursynth_cranexpr-0.12.0-py3-none-manylinux_2_28_aarch64.whl
| Download URL | vapoursynth_cranexpr-0.12.0-py3-none-manylinux_2_28_aarch64.whl |
|---|---|
| Size | 1.1 MB |
| Tags | Linux glibc 2.28+ ARM64 Python 3 |
|
SHA-256 checksum How to use checksums |
cb1a852a843f1e3d3d002b1388cf7357708a6ecb7fd47038f2ea7542c2c64b31
|
|
BLAKE2b-256 checksum How to use checksums |
b6242f49873917d902d10634e37f88332d899d35809e7b6842077da3feb102c9
|
| 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 Aug 4, 2026.
Transparency logRelease files / vapoursynth_cranexpr-0.12.0-py3-none-macosx_13_0_x86_64.whl
| Download URL | vapoursynth_cranexpr-0.12.0-py3-none-macosx_13_0_x86_64.whl |
|---|---|
| Size | 3.3 MB |
| Tags | Python 3 macOS 13.0+ x86-64 |
|
SHA-256 checksum How to use checksums |
b82eb473e1e0263de6d1f6978ce0647d885f53747d8b6ad9ab9a3b2f6693531a
|
|
BLAKE2b-256 checksum How to use checksums |
af1af8e029bbc30e84719cf53f748b850703cf830b8882149a575555972adcc9
|
| 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 Aug 4, 2026.
Transparency logRelease files / vapoursynth_cranexpr-0.12.0-py3-none-macosx_13_0_arm64.whl
| Download URL | vapoursynth_cranexpr-0.12.0-py3-none-macosx_13_0_arm64.whl |
|---|---|
| Size | 1.1 MB |
| Tags | Python 3 macOS 13.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
36db8ab08e4753a08453a1aa107830f3686a5ea050bf06d6bf5030f6b024bc95
|
|
BLAKE2b-256 checksum How to use checksums |
2cebf2f4fd5fba5c37912fc12695a30b152be7b0a5a86bd7a9bffb1481c030a4
|
| 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 Aug 4, 2026.
Transparency logSecurity for vapoursynth-cranexpr 0.12.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 6 files in this release have been uploaded with provenance metadata.
Attestation for vapoursynth_cranexpr-0.12.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 Aug 4, 2026.
Transparency logA 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.