Skip to content

The truly free, open-source, local-first, cross-platform CapCut replacement. Scriptable through a JSON-RPC API & MCP.

Make every effect a package

Jareeraa98e6c04932
diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md
index afad0e2d..be7af841 100644
--- a/ARCHITECTURE.md
+++ b/ARCHITECTURE.md
@@ -24,6 +24,7 @@ flowchart LR
end
subgraph ENGINE["the engine"]
PROJECT[concat-project]
+ EFFECTS[concat-effects]
EXPORT[concat-export]
RENDER[concat-render]
MEDIA[concat-media]
@@ -53,10 +54,14 @@ The dependency arrows point one way:
```
concat (window) → concat-speech → concat-host → {export, project, media} → core
→ render → core
+ export → effects → project
```
`concat-core` depends on nothing. `concat-project` knows nothing about
rendering. `concat-media` is the only crate that knows FFmpeg exists.
+`concat-effects` knows what an effect *is* (its manifest and its template)
+and nothing about running one; the decoder runs FFmpeg chains and the
+compositor will run shaders.
| Crate | Lines | Tests | Owns |
|---|---|---|---|
@@ -64,7 +69,8 @@ rendering. `concat-media` is the only crate that knows FFmpeg exists.
| `concat-media` | 3.4k | 39 | Linked FFmpeg: probe, video decode with filter graphs and frame pacing, audio decode through a graph, H.264 encode, AAC mixing through libavfilter, muxing, waveform peaks, the reader pool with its byte-budgeted frame cache, JPEG stills. |
| `concat-project` | 3.3k | 41 | The document: model, every edit command, undo `Editor`, `concat.json` round-trip. |
| `concat-render` | 1.3k | 28 | Compositing. `CpuCompositor` is the reference; `WgpuCompositor` behind `gpu`. |
-| `concat-export` | 2.5k | 32 | Timeline → file: flatten, filtergraph builders (`chains.rs`), the frame-by-frame render loop, the paused monitor's true frame. |
+| `concat-effects` | 1.1k | 22 | Effect packages: the manifest format, the chain-template expression language, the catalogue. Every built-in effect is a folder under `packages/`, compiled in; user packages load from a directory. |
+| `concat-export` | 2.3k | 6 | Timeline → file: flatten, the frame-by-frame render loop, the paused monitor's true frame. Chains come from `concat-effects`. |
| `concat-host` | 3.4k | 22 | Sessions, project folders and recents, media caches beside the project, the monitor's reader pool, the export slot, audio playback, templates, one-at-a-time job slots, app directories. |
| `concat-speech` | 1.2k | 6 | Transcription (whisper.cpp in-process) and text to speech (Kokoro via sherpa-onnx), with model downloads. |
| `concat-cli` | 0.2k | 3 | Probe/render vertical slice for testing the engine without the app. |
@@ -384,7 +390,7 @@ tests, which is fine.
| Area | Tests | Gaps |
|---|---|---|
-| Engine crates | 174 (core 31, media 39, project 41, render 28, export 32, cli 3) | `mix_to_file`/`mux` untested end to end (§8.6); `gpu` feature untested at defaults |
+| Engine crates | 170 (core 31, media 39, project 41, render 28, effects 22, export 6, cli 3) | `mix_to_file`/`mux` untested end to end (§8.6); `gpu` feature untested at defaults |
| Host | 22 | `Playback` (threads, cpal) has unit tests only for the WAV walk and the sweep; no test drives the decode workers |
| Speech | 6 | Model downloads and whisper itself are network- and model-bound; test with `tiny.en` behind an opt-in feature |
| Window | 3 | Formatting helpers only. Drive `Studio` against a `Session` from a headless harness and snapshot what it publishes |
diff --git a/engine/Cargo.lock b/engine/Cargo.lock
index 072914df..c1d1a974 100644
--- a/engine/Cargo.lock
+++ b/engine/Cargo.lock
@@ -1123,11 +1123,22 @@ dependencies = [
name = "concat-core"
version = "0.2.0"
+[[package]]
+name = "concat-effects"
+version = "0.2.0"
+dependencies = [
+ "concat-project",
+ "serde",
+ "thiserror 2.0.20",
+ "toml",
+]
+
[[package]]
name = "concat-export"
version = "0.2.0"
dependencies = [
"concat-core",
+ "concat-effects",
"concat-media",
"concat-project",
"concat-render",
diff --git a/engine/Cargo.toml b/engine/Cargo.toml
index bfeed58a..bce99206 100644
--- a/engine/Cargo.toml
+++ b/engine/Cargo.toml
@@ -16,6 +16,7 @@ concat-render = { path = "crates/concat-render" }
concat-export = { path = "crates/concat-export" }
concat-host = { path = "crates/concat-host" }
concat-speech = { path = "crates/concat-speech" }
+concat-effects = { path = "crates/concat-effects" }
serde_json = "1"
thiserror = "2"
diff --git a/engine/README.md b/engine/README.md
index 24818213..d5ddecc3 100644
--- a/engine/README.md
+++ b/engine/README.md
@@ -10,7 +10,8 @@ The video engine behind Concat. Rust, no GC, no hidden control flow.
| `concat-media` | Getting pixels and samples in and out of files. Links FFmpeg (libav*), and is the only crate that knows it exists. | `concat-core`, ffmpeg-the-third |
| `concat-project` | The edit itself: document model, operations as commands, undo, concat.json IO. | serde, serde_json |
| `concat-render` | Turning a timeline plus a timestamp into one finished frame. | `concat-core`, wgpu (optional) |
-| `concat-export` | Timeline to file: flatten, the filter-chain builders, the frame-by-frame render loop, the paused monitor's true frame. | `concat-core`, `concat-media`, `concat-render`, `concat-project` |
+| `concat-effects` | Effect packages: manifests, chain templates, the catalogue. Each built-in effect is a folder under `packages/`. | `concat-project`, serde, toml |
+| `concat-export` | Timeline to file: flatten, the frame-by-frame render loop, the paused monitor's true frame. | `concat-core`, `concat-media`, `concat-render`, `concat-project`, `concat-effects` |
| `concat-cli` | A binary to drive the above. The vertical slice. | the engine crates |
| `concat-host` | What the window needs that is not the edit: sessions, project folders, previews, playback, templates, job slots. | `concat-media`, `concat-project`, `concat-export`, cpal |
| `concat-speech` | Transcription (whisper.cpp, in-process) and text to speech (Kokoro via sherpa-onnx). | `concat-host`, `concat-media`, whisper-rs, sherpa-onnx |
@@ -21,6 +22,7 @@ The dependency arrows point one way:
```
concat -> concat-speech -> concat-host -> {export, project, media} -> core
-> render -> core
+ export -> effects -> project
```
If you ever find yourself wanting `core` to depend on `media`, something has
diff --git a/engine/crates/concat-effects/Cargo.toml b/engine/crates/concat-effects/Cargo.toml
new file mode 100644
index 00000000..4ea4f4c1
--- /dev/null
+++ b/engine/crates/concat-effects/Cargo.toml
@@ -0,0 +1,17 @@
+[package]
+name = "concat-effects"
+version.workspace = true
+edition.workspace = true
+rust-version.workspace = true
+license.workspace = true
+description = "Effect packages: the catalogue of video effects, audio filters, transitions and generators, loaded from manifests rather than written in code."
+
+[dependencies]
+concat-project.workspace = true
+serde = { version = "1", features = ["derive"] }
+thiserror.workspace = true
+# Manifests are TOML: the format people hand-write. Project files stay JSON.
+toml = "1.1"
+
+[lints]
+workspace = true
diff --git a/engine/crates/concat-effects/build.rs b/engine/crates/concat-effects/build.rs
new file mode 100644
index 00000000..c32648b3
--- /dev/null
+++ b/engine/crates/concat-effects/build.rs
@@ -0,0 +1,54 @@
+// SPDX-License-Identifier: AGPL-3.0-or-later
+// SPDX-FileCopyrightText: 2026 Jareer and Concat contributors
+
+//! Embeds every package under `packages/` into the binary.
+//!
+//! Each package is a folder named after its id, holding `effect.toml` and
+//! optionally `fixtures.toml`. This script lists the folders and writes a
+//! table of `include_str!`s, so adding a built-in effect is adding a folder:
+//! nothing in Rust names it.
+
+use std::fmt::Write as _;
+use std::path::PathBuf;
+
+fn main() {
+ let root = PathBuf::from(std::env::var("CARGO_MANIFEST_DIR").expect("manifest dir"));
+ let packages = root.join("packages");
+ println!("cargo:rerun-if-changed={}", packages.display());
+
+ let mut ids: Vec<String> = std::fs::read_dir(&packages)
+ .expect("packages/ exists")
+ .filter_map(|entry| entry.ok())
+ .filter(|entry| entry.path().join("effect.toml").is_file())
+ .map(|entry| entry.file_name().to_string_lossy().into_owned())
+ .collect();
+ ids.sort();
+
+ let mut table = String::from(
+ "/// Every built-in package: its folder name, its manifest, and its \
+ fixtures if it has any.\n\
+ pub(crate) static BUILTIN_SOURCES: &[(&str, &str, Option<&str>)] = &[\n",
+ );
+ for id in &ids {
+ let dir = packages.join(id);
+ let manifest = dir.join("effect.toml");
+ let fixtures = dir.join("fixtures.toml");
+ println!("cargo:rerun-if-changed={}", manifest.display());
+ println!("cargo:rerun-if-changed={}", fixtures.display());
+ let fixtures = if fixtures.is_file() {
+ format!("Some(include_str!({:?}))", fixtures.display().to_string())
+ } else {
+ "None".to_owned()
+ };
+ writeln!(
+ table,
+ " ({id:?}, include_str!({:?}), {fixtures}),",
+ manifest.display().to_string()
+ )
+ .expect("write");
+ }
+ table.push_str("];\n");
+
+ let out = PathBuf::from(std::env::var("OUT_DIR").expect("out dir")).join("builtins.rs");
+ std::fs::write(out, table).expect("write builtins.rs");
+}
diff --git a/engine/crates/concat-effects/packages/concat.bass/effect.toml b/engine/crates/concat-effects/packages/concat.bass/effect.toml
new file mode 100644
index 00000000..743c7f79
--- /dev/null
+++ b/engine/crates/concat-effects/packages/concat.bass/effect.toml
@@ -0,0 +1,21 @@
+[effect]
+id = "concat.bass"
+name = "Bass"
+kind = "filter"
+category = "Tone"
+order = 20
+intensity = "gain"
+aliases = ["bass"]
+description = "More low end."
+
+[[param]]
+key = "gain"
+label = "Gain"
+min = 0
+max = 12
+default = 5
+step = 0.5
+unit = "dB"
+
+[ffmpeg]
+chain = "bass=g={fixed(gain, 2)}:f=110:w=0.6,alimiter=limit=0.95"
diff --git a/engine/crates/concat-effects/packages/concat.bass/fixtures.toml b/engine/crates/concat-effects/packages/concat.bass/fixtures.toml
new file mode 100644
index 00000000..d148a99b
--- /dev/null
+++ b/engine/crates/concat-effects/packages/concat.bass/fixtures.toml
@@ -0,0 +1,13 @@
+[[case]]
+name = "default"
+chain = "bass=g=5.00:f=110:w=0.6,alimiter=limit=0.95"
+
+[[case]]
+name = "minimum"
+at = "min"
+chain = "bass=g=0.00:f=110:w=0.6,alimiter=limit=0.95"
+
+[[case]]
+name = "maximum"
+at = "max"
+chain = "bass=g=12.00:f=110:w=0.6,alimiter=limit=0.95"
diff --git a/engine/crates/concat-effects/packages/concat.black-white/effect.toml b/engine/crates/concat-effects/packages/concat.black-white/effect.toml
new file mode 100644
index 00000000..e790c9c3
--- /dev/null
+++ b/engine/crates/concat-effects/packages/concat.black-white/effect.toml
@@ -0,0 +1,11 @@
+[effect]
+id = "concat.black-white"
+name = "Black & White"
+kind = "effect"
+category = "Basic"
+order = 10
+aliases = ["black-white"]
+description = "Drops every colour to grey."
+
+[ffmpeg]
+chain = "hue=s=0"
diff --git a/engine/crates/concat-effects/packages/concat.black-white/fixtures.toml b/engine/crates/concat-effects/packages/concat.black-white/fixtures.toml
new file mode 100644
index 00000000..680a5723
--- /dev/null
+++ b/engine/crates/concat-effects/packages/concat.black-white/fixtures.toml
@@ -0,0 +1,3 @@
+[[case]]
+name = "default"
+chain = "hue=s=0"
diff --git a/engine/crates/concat-effects/packages/concat.box-blur/effect.toml b/engine/crates/concat-effects/packages/concat.box-blur/effect.toml
new file mode 100644
index 00000000..5b4f217a
--- /dev/null
+++ b/engine/crates/concat-effects/packages/concat.box-blur/effect.toml
@@ -0,0 +1,22 @@
+[effect]
+id = "concat.box-blur"
+name = "Box Blur"
+kind = "effect"
+category = "Blur"
+order = 21
+intensity = "radius"
+aliases = ["box-blur"]
+description = "A flat, boxy blur."
+
+[[param]]
+key = "radius"
+label = "Radius"
+type = "int"
+min = 1
+max = 30
+default = 6
+step = 1
+unit = "px"
+
+[ffmpeg]
+chain = "boxblur={round(radius)}:1"
diff --git a/engine/crates/concat-effects/packages/concat.box-blur/fixtures.toml b/engine/crates/concat-effects/packages/concat.box-blur/fixtures.toml
new file mode 100644
index 00000000..ac62aa0f
--- /dev/null
+++ b/engine/crates/concat-effects/packages/concat.box-blur/fixtures.toml
@@ -0,0 +1,13 @@
+[[case]]
+name = "default"
+chain = "boxblur=6:1"
+
+[[case]]
+name = "minimum"
+at = "min"
+chain = "boxblur=1:1"
+
+[[case]]
+name = "maximum"
+at = "max"
+chain = "boxblur=30:1"
diff --git a/engine/crates/concat-effects/packages/concat.chipmunk/effect.toml b/engine/crates/concat-effects/packages/concat.chipmunk/effect.toml
new file mode 100644
index 00000000..2b1283b5
--- /dev/null
+++ b/engine/crates/concat-effects/packages/concat.chipmunk/effect.toml
@@ -0,0 +1,24 @@
+[effect]
+id = "concat.chipmunk"
+name = "Chipmunk"
+kind = "filter"
+category = "Voice"
+order = 12
+intensity = "pitch"
+aliases = ["chipmunk"]
+description = "Higher and squeakier."
+
+[[param]]
+key = "pitch"
+label = "Pitch"
+min = 3
+max = 12
+default = 7
+step = 0.5
+unit = "st"
+
+[ffmpeg]
+let = [
+ "ratio = pow(2, pitch / 12)",
+]
+chain = "aresample=48000,asetrate={fixed(48000 * ratio, 6)},aresample=48000,atempo={fixed(1 / ratio, 8)},highpass=f=120,alimiter=limit=0.94"
diff --git a/engine/crates/concat-effects/packages/concat.chipmunk/fixtures.toml b/engine/crates/concat-effects/packages/concat.chipmunk/fixtures.toml
new file mode 100644
index 00000000..6e889b88
--- /dev/null
+++ b/engine/crates/concat-effects/packages/concat.chipmunk/fixtures.toml
@@ -0,0 +1,13 @@
+[[case]]
+name = "default"
+chain = "aresample=48000,asetrate=71918.739690,aresample=48000,atempo=0.66741993,highpass=f=120,alimiter=limit=0.94"
+
+[[case]]
+name = "minimum"
+at = "min"
+chain = "aresample=48000,asetrate=57081.941520,aresample=48000,atempo=0.84089642,highpass=f=120,alimiter=limit=0.94"
+
+[[case]]
+name = "maximum"
+at = "max"
+chain = "aresample=48000,asetrate=96000.000000,aresample=48000,atempo=0.50000000,highpass=f=120,alimiter=limit=0.94"
diff --git a/engine/crates/concat-effects/packages/concat.contrast-pop/effect.toml b/engine/crates/concat-effects/packages/concat.contrast-pop/effect.toml
new file mode 100644
index 00000000..68128dd1
--- /dev/null
+++ b/engine/crates/concat-effects/packages/concat.contrast-pop/effect.toml
@@ -0,0 +1,20 @@
+[effect]
+id = "concat.contrast-pop"
+name = "Contrast Pop"
+kind = "effect"
+category = "Color"
+order = 33
+intensity = "contrast"
+aliases = ["contrast-pop"]
+description = "Deeper shadows, brighter highlights."
+
+[[param]]
+key = "contrast"
+label = "Contrast"
+min = 1
+max = 2
+default = 1.25
+step = 0.05
+
+[ffmpeg]
+chain = "eq=contrast={fixed(contrast, 2)}"
diff --git a/engine/crates/concat-effects/packages/concat.contrast-pop/fixtures.toml b/engine/crates/concat-effects/packages/concat.contrast-pop/fixtures.toml
new file mode 100644
index 00000000..9d58de6d
--- /dev/null
+++ b/engine/crates/concat-effects/packages/concat.contrast-pop/fixtures.toml
@@ -0,0 +1,13 @@
+[[case]]
+name = "default"
+chain = "eq=contrast=1.25"
+
+[[case]]
+name = "minimum"
+at = "min"
+chain = "eq=contrast=1.00"
+
+[[case]]
+name = "maximum"
+at = "max"
+chain = "eq=contrast=2.00"
diff --git a/engine/crates/concat-effects/packages/concat.cool/effect.toml b/engine/crates/concat-effects/packages/concat.cool/effect.toml
new file mode 100644
index 00000000..9f1c059f
--- /dev/null
+++ b/engine/crates/concat-effects/packages/concat.cool/effect.toml
@@ -0,0 +1,21 @@
+[effect]
+id = "concat.cool"
+name = "Cool"
+kind = "effect"
+category = "Color"
+order = 31
+intensity = "temperature"
+aliases = ["cool"]
+description = "Shifts the picture towards daylight shade."
+
+[[param]]
+key = "temperature"
+label = "Temperature"
+min = 7000
+max = 11000
+default = 8500
+step = 50
+unit = "K"
+
+[ffmpeg]
+chain = "colortemperature=temperature={round(temperature)}"
diff --git a/engine/crates/concat-effects/packages/concat.cool/fixtures.toml b/engine/crates/concat-effects/packages/concat.cool/fixtures.toml
new file mode 100644
index 00000000..306f7065
--- /dev/null
+++ b/engine/crates/concat-effects/packages/concat.cool/fixtures.toml
@@ -0,0 +1,13 @@
+[[case]]
+name = "default"
+chain = "colortemperature=temperature=8500"
+
+[[case]]
+name = "minimum"
+at = "min"
+chain = "colortemperature=temperature=7000"
+
+[[case]]
+name = "maximum"
+at = "max"
+chain = "colortemperature=temperature=11000"
diff --git a/engine/crates/concat-effects/packages/concat.deep/effect.toml b/engine/crates/concat-effects/packages/concat.deep/effect.toml
new file mode 100644
index 00000000..1756a730
--- /dev/null
+++ b/engine/crates/concat-effects/packages/concat.deep/effect.toml
@@ -0,0 +1,33 @@
+[effect]
+id = "concat.deep"
+name = "Deep"
+kind = "filter"
+category = "Voice"
+order = 11
+intensity = "pitch"
+aliases = ["deep"]
+description = "Lower and fuller."
+
+[[param]]
+key = "pitch"
+label = "Pitch"
+min = -8
+max = -1
+default = -3
+step = 0.5
+unit = "st"
+
+[[param]]
+key = "body"
+label = "Body"
+min = 0
+max = 8
+default = 3
+step = 0.5
+unit = "dB"
+
+[ffmpeg]
+let = [
+ "ratio = pow(2, pitch / 12)",
+]
+chain = "aresample=48000,asetrate={fixed(48000 * ratio, 6)},aresample=48000,atempo={fixed(1 / ratio, 8)},highpass=f=55,equalizer=f=140:t=q:w=1.0:g={fixed(body, 2)},equalizer=f=2600:t=q:w=0.9:g=-1.2,alimiter=limit=0.94:attack=5:release=60"
diff --git a/engine/crates/concat-effects/packages/concat.deep/fixtures.toml b/engine/crates/concat-effects/packages/concat.deep/fixtures.toml
new file mode 100644
index 00000000..cd73fdeb
--- /dev/null
+++ b/engine/crates/concat-effects/packages/concat.deep/fixtures.toml
@@ -0,0 +1,13 @@
+[[case]]
+name = "default"
+chain = "aresample=48000,asetrate=40363.027932,aresample=48000,atempo=1.18920712,highpass=f=55,equalizer=f=140:t=q:w=1.0:g=3.00,equalizer=f=2600:t=q:w=0.9:g=-1.2,alimiter=limit=0.94:attack=5:release=60"
+
+[[case]]
+name = "minimum"
+at = "min"
+chain = "aresample=48000,asetrate=30238.105197,aresample=48000,atempo=1.58740105,highpass=f=55,equalizer=f=140:t=q:w=1.0:g=0.00,equalizer=f=2600:t=q:w=0.9:g=-1.2,alimiter=limit=0.94:attack=5:release=60"
+
+[[case]]
+name = "maximum"
+at = "max"
+chain = "aresample=48000,asetrate=45305.967009,aresample=48000,atempo=1.05946309,highpass=f=55,equalizer=f=140:t=q:w=1.0:g=8.00,equalizer=f=2600:t=q:w=0.9:g=-1.2,alimiter=limit=0.94:attack=5:release=60"
diff --git a/engine/crates/concat-effects/packages/concat.echo/effect.toml b/engine/crates/concat-effects/packages/concat.echo/effect.toml
new file mode 100644
index 00000000..a0e077a9
--- /dev/null
+++ b/engine/crates/concat-effects/packages/concat.echo/effect.toml
@@ -0,0 +1,29 @@
+[effect]
+id = "concat.echo"
+name = "Echo"
+kind = "filter"
+category = "Space"
+order = 30
+intensity = "decay"
+aliases = ["echo"]
+description = "One repeat, fading."
+
+[[param]]
+key = "delay"
+label = "Delay"
+min = 0.05
+max = 1
+default = 0.25
+step = 0.05
+unit = "s"
+
+[[param]]
+key = "decay"
+label = "Decay"
+min = 0.1
+max = 0.9
+default = 0.4
+step = 0.05
+
+[ffmpeg]
+chain = "aecho=0.8:0.85:{round(delay * 1000)}:{fixed(decay, 2)}"
diff --git a/engine/crates/concat-effects/packages/concat.echo/fixtures.toml b/engine/crates/concat-effects/packages/concat.echo/fixtures.toml
new file mode 100644
index 00000000..05ef0f08
--- /dev/null
+++ b/engine/crates/concat-effects/packages/concat.echo/fixtures.toml
@@ -0,0 +1,13 @@
+[[case]]
+name = "default"
+chain = "aecho=0.8:0.85:250:0.40"
+
+[[case]]
+name = "minimum"
+at = "min"
+chain = "aecho=0.8:0.85:50:0.10"
+
+[[case]]
+name = "maximum"
+at = "max"
+chain = "aecho=0.8:0.85:1000:0.90"
diff --git a/engine/crates/concat-effects/packages/concat.film-grain/effect.toml b/engine/crates/concat-effects/packages/concat.film-grain/effect.toml
new file mode 100644
index 00000000..4b06bad8
--- /dev/null
+++ b/engine/crates/concat-effects/packages/concat.film-grain/effect.toml
@@ -0,0 +1,21 @@
+[effect]
+id = "concat.film-grain"
+name = "Film Grain"
+kind = "effect"
+category = "Stylize"
+order = 41
+intensity = "amount"
+aliases = ["film-grain"]
+description = "Dancing grain, the texture of film stock."
+
+[[param]]
+key = "amount"
+label = "Amount"
+type = "int"
+min = 2
+max = 40
+default = 12
+step = 1
+
+[ffmpeg]
+chain = "noise=alls={round(amount)}:allf=t+u"
diff --git a/engine/crates/concat-effects/packages/concat.film-grain/fixtures.toml b/engine/crates/concat-effects/packages/concat.film-grain/fixtures.toml
new file mode 100644
index 00000000..54c98860
--- /dev/null
+++ b/engine/crates/concat-effects/packages/concat.film-grain/fixtures.toml
@@ -0,0 +1,13 @@
+[[case]]
+name = "default"
+chain = "noise=alls=12:allf=t+u"
+
+[[case]]
+name = "minimum"
+at = "min"
+chain = "noise=alls=2:allf=t+u"
+
+[[case]]
+name = "maximum"
+at = "max"
+chain = "noise=alls=40:allf=t+u"
diff --git a/engine/crates/concat-effects/packages/concat.fisheye/effect.toml b/engine/crates/concat-effects/packages/concat.fisheye/effect.toml
new file mode 100644
index 00000000..d6c1348f
--- /dev/null
+++ b/engine/crates/concat-effects/packages/concat.fisheye/effect.toml
@@ -0,0 +1,24 @@
+[effect]
+id = "concat.fisheye"
+name = "Fisheye"
+kind = "effect"
+category = "Distort"
+order = 52
+intensity = "strength"
+aliases = ["fisheye"]
+description = "The bulge of a very wide lens."
+
+[[param]]
+key = "strength"
+label = "Strength"
+min = 5
+max = 100
+default = 50
+step = 1
+unit = "%"
+
+[ffmpeg]
+let = [
+ "k = strength / 100",
+]
+chain = "lenscorrection=k1={fixed(-0.55 * k, 3)}:k2={fixed(-0.2 * k, 3)}:i=bilinear"
diff --git a/engine/crates/concat-effects/packages/concat.fisheye/fixtures.toml b/engine/crates/concat-effects/packages/concat.fisheye/fixtures.toml
new file mode 100644
index 00000000..a86a30f6
--- /dev/null
+++ b/engine/crates/concat-effects/packages/concat.fisheye/fixtures.toml
@@ -0,0 +1,13 @@
+[[case]]
+name = "default"
+chain = "lenscorrection=k1=-0.275:k2=-0.100:i=bilinear"
+
+[[case]]
+name = "minimum"
+at = "min"
+chain = "lenscorrection=k1=-0.028:k2=-0.010:i=bilinear"
+
+[[case]]
+name = "maximum"
+at = "max"
+chain = "lenscorrection=k1=-0.550:k2=-0.200:i=bilinear"
diff --git a/engine/crates/concat-effects/packages/concat.gaussian-blur/effect.toml b/engine/crates/concat-effects/packages/concat.gaussian-blur/effect.toml
new file mode 100644
index 00000000..5ee89015
--- /dev/null
+++ b/engine/crates/concat-effects/packages/concat.gaussian-blur/effect.toml
@@ -0,0 +1,21 @@
+[effect]
+id = "concat.gaussian-blur"
+name = "Gaussian Blur"
+kind = "effect"
+category = "Blur"
+order = 20
+intensity = "radius"
+aliases = ["gaussian-blur"]
+description = "A soft, even blur."
+
+[[param]]
+key = "radius"
+label = "Radius"
+min = 1
+max = 50
+default = 10
+step = 1
+unit = "px"
+
+[ffmpeg]
+chain = "gblur=sigma={fixed(radius, 1)}"
diff --git a/engine/crates/concat-effects/packages/concat.gaussian-blur/fixtures.toml b/engine/crates/concat-effects/packages/concat.gaussian-blur/fixtures.toml
new file mode 100644
index 00000000..d3f3d88c
--- /dev/null
+++ b/engine/crates/concat-effects/packages/concat.gaussian-blur/fixtures.toml
@@ -0,0 +1,13 @@
+[[case]]
+name = "default"
+chain = "gblur=sigma=10.0"
+
+[[case]]
+name = "minimum"
+at = "min"
+chain = "gblur=sigma=1.0"
+
+[[case]]
+name = "maximum"
+at = "max"
+chain = "gblur=sigma=50.0"
diff --git a/engine/crates/concat-effects/packages/concat.glow/effect.toml b/engine/crates/concat-effects/packages/concat.glow/effect.toml
new file mode 100644
index 00000000..54765bc6
--- /dev/null
+++ b/engine/crates/concat-effects/packages/concat.glow/effect.toml
@@ -0,0 +1,21 @@
+[effect]
+id = "concat.glow"
+name = "Glow"
+kind = "effect"
+category = "Stylize"
+order = 42
+intensity = "amount"
+aliases = ["glow"]
+description = "A soft bloom around the bright parts of the picture."
+
+[[param]]
+key = "amount"
+label = "Amount"
+min = 10
+max = 100
+default = 45
+step = 1
+unit = "%"
+
+[ffmpeg]
+chain = "split[glowa{index}][glowb{index}];[glowb{index}]gblur=sigma=18[glowg{index}];[glowa{index}][glowg{index}]blend=all_mode=screen:all_opacity={fixed(amount / 100, 2)}"
diff --git a/engine/crates/concat-effects/packages/concat.glow/fixtures.toml b/engine/crates/concat-effects/packages/concat.glow/fixtures.toml
new file mode 100644
index 00000000..76db5024
--- /dev/null
+++ b/engine/crates/concat-effects/packages/concat.glow/fixtures.toml
@@ -0,0 +1,13 @@
+[[case]]
+name = "default"
+chain = "split[glowa0][glowb0];[glowb0]gblur=sigma=18[glowg0];[glowa0][glowg0]blend=all_mode=screen:all_opacity=0.45"
+
+[[case]]
+name = "minimum"
+at = "min"
+chain = "split[glowa0][glowb0];[glowb0]gblur=sigma=18[glowg0];[glowa0][glowg0]blend=all_mode=screen:all_opacity=0.10"
+
+[[case]]
+name = "maximum"
+at = "max"
+chain = "split[glowa0][glowb0];[glowb0]gblur=sigma=18[glowg0];[glowa0][glowg0]blend=all_mode=screen:all_opacity=1.00"
diff --git a/engine/crates/concat-effects/packages/concat.invert/effect.toml b/engine/crates/concat-effects/packages/concat.invert/effect.toml
new file mode 100644
index 00000000..e228c60d
--- /dev/null
+++ b/engine/crates/concat-effects/packages/concat.invert/effect.toml
@@ -0,0 +1,11 @@
+[effect]
+id = "concat.invert"
+name = "Invert"
+kind = "effect"
+category = "Basic"
+order = 12
+aliases = ["invert"]
+description = "Every colour becomes its opposite."
+
+[ffmpeg]
+chain = "negate"
diff --git a/engine/crates/concat-effects/packages/concat.invert/fixtures.toml b/engine/crates/concat-effects/packages/concat.invert/fixtures.toml
new file mode 100644
index 00000000..200708dc
--- /dev/null
+++ b/engine/crates/concat-effects/packages/concat.invert/fixtures.toml
@@ -0,0 +1,3 @@
+[[case]]
+name = "default"
+chain = "negate"
diff --git a/engine/crates/concat-effects/packages/concat.mirror/effect.toml b/engine/crates/concat-effects/packages/concat.mirror/effect.toml
new file mode 100644
index 00000000..61af66f0
--- /dev/null
+++ b/engine/crates/concat-effects/packages/concat.mirror/effect.toml
@@ -0,0 +1,11 @@
+[effect]
+id = "concat.mirror"
+name = "Mirror"
+kind = "effect"
+category = "Distort"
+order = 51
+aliases = ["mirror"]
+description = "The left half, reflected onto the right."
+
+[ffmpeg]
+chain = "crop=iw/2:ih:0:0,split[mirl{index}][mirr{index}];[mirr{index}]hflip[mirf{index}];[mirl{index}][mirf{index}]hstack"
diff --git a/engine/crates/concat-effects/packages/concat.mirror/fixtures.toml b/engine/crates/concat-effects/packages/concat.mirror/fixtures.toml
new file mode 100644
index 00000000..eb9c8ae2
--- /dev/null
+++ b/engine/crates/concat-effects/packages/concat.mirror/fixtures.toml
@@ -0,0 +1,3 @@
+[[case]]
+name = "default"
+chain = "crop=iw/2:ih:0:0,split[mirl0][mirr0];[mirr0]hflip[mirf0];[mirl0][mirf0]hstack"
diff --git a/engine/crates/concat-effects/packages/concat.motion-blur/effect.toml b/engine/crates/concat-effects/packages/concat.motion-blur/effect.toml
new file mode 100644
index 00000000..0a620e75
--- /dev/null
+++ b/engine/crates/concat-effects/packages/concat.motion-blur/effect.toml
@@ -0,0 +1,21 @@
+[effect]
+id = "concat.motion-blur"
+name = "Motion Blur"
+kind = "effect"
+category = "Blur"
+order = 22
+intensity = "length"
+aliases = ["motion-blur"]
+description = "A horizontal streak, as if the camera panned."
+
+[[param]]
+key = "length"
+label = "Length"
+min = 2
+max = 60
+default = 18
+step = 1
+unit = "px"
+
+[ffmpeg]
+chain = "gblur=sigma={fixed(length, 1)}:sigmaV=0.1"
diff --git a/engine/crates/concat-effects/packages/concat.motion-blur/fixtures.toml b/engine/crates/concat-effects/packages/concat.motion-blur/fixtures.toml
new file mode 100644
index 00000000..eaf6cfae
--- /dev/null
+++ b/engine/crates/concat-effects/packages/concat.motion-blur/fixtures.toml
@@ -0,0 +1,13 @@
+[[case]]
+name = "default"
+chain = "gblur=sigma=18.0:sigmaV=0.1"
+
+[[case]]
+name = "minimum"
+at = "min"
+chain = "gblur=sigma=2.0:sigmaV=0.1"
+
+[[case]]
+name = "maximum"
+at = "max"
+chain = "gblur=sigma=60.0:sigmaV=0.1"
diff --git a/engine/crates/concat-effects/packages/concat.pixelate/effect.toml b/engine/crates/concat-effects/packages/concat.pixelate/effect.toml
new file mode 100644
index 00000000..df407ff3
--- /dev/null
+++ b/engine/crates/concat-effects/packages/concat.pixelate/effect.toml
@@ -0,0 +1,22 @@
+[effect]
+id = "concat.pixelate"
+name = "Pixelate"
+kind = "effect"
+category = "Distort"
+order = 50
+intensity = "size"
+aliases = ["pixelate"]
+description = "Big square pixels."
+
+[[param]]
+key = "size"
+label = "Size"
+type = "int"
+min = 2
+max = 64
+default = 16
+step = 1
+unit = "px"
+
+[ffmpeg]
+chain = "pixelize=width={round(size)}:height={round(size)}"
diff --git a/engine/crates/concat-effects/packages/concat.pixelate/fixtures.toml b/engine/crates/concat-effects/packages/concat.pixelate/fixtures.toml
new file mode 100644
index 00000000..66381c64
--- /dev/null
+++ b/engine/crates/concat-effects/packages/concat.pixelate/fixtures.toml
@@ -0,0 +1,13 @@
+[[case]]
+name = "default"
+chain = "pixelize=width=16:height=16"
+
+[[case]]
+name = "minimum"
+at = "min"
+chain = "pixelize=width=2:height=2"
+
+[[case]]
+name = "maximum"
+at = "max"
+chain = "pixelize=width=64:height=64"
diff --git a/engine/crates/concat-effects/packages/concat.posterize/effect.toml b/engine/crates/concat-effects/packages/concat.posterize/effect.toml
new file mode 100644
index 00000000..f6d6c24a
--- /dev/null
+++ b/engine/crates/concat-effects/packages/concat.posterize/effect.toml
@@ -0,0 +1,24 @@
+[effect]
+id = "concat.posterize"
+name = "Posterize"
+kind = "effect"
+category = "Stylize"
+order = 43
+intensity = "levels"
+aliases = ["posterize"]
+description = "Flat bands of colour, like a screen print."
+
+[[param]]
+key = "levels"
+label = "Levels"
+type = "int"
+min = 2
+max = 8
+default = 4
+step = 1
+
+[ffmpeg]
+let = [
+ "size = round(256 / max(round(levels), 2))",
+]
+chain = "lutrgb=r=trunc(val/{size})*{size}:g=trunc(val/{size})*{size}:b=trunc(val/{size})*{size}"
diff --git a/engine/crates/concat-effects/packages/concat.posterize/fixtures.toml b/engine/crates/concat-effects/packages/concat.posterize/fixtures.toml
new file mode 100644
index 00000000..d1d5455d
--- /dev/null
+++ b/engine/crates/concat-effects/packages/concat.posterize/fixtures.toml
@@ -0,0 +1,13 @@
+[[case]]
+name = "default"
+chain = "lutrgb=r=trunc(val/64)*64:g=trunc(val/64)*64:b=trunc(val/64)*64"
+
+[[case]]
+name = "minimum"
+at = "min"
+chain = "lutrgb=r=trunc(val/128)*128:g=trunc(val/128)*128:b=trunc(val/128)*128"
+
+[[case]]
+name = "maximum"
+at = "max"
+chain = "lutrgb=r=trunc(val/32)*32:g=trunc(val/32)*32:b=trunc(val/32)*32"
diff --git a/engine/crates/concat-effects/packages/concat.robot/effect.toml b/engine/crates/concat-effects/packages/concat.robot/effect.toml
new file mode 100644
index 00000000..22355198
--- /dev/null
+++ b/engine/crates/concat-effects/packages/concat.robot/effect.toml
@@ -0,0 +1,20 @@
+[effect]
+id = "concat.robot"
+name = "Robot"
+kind = "filter"
+category = "Voice"
+order = 13
+intensity = "depth"
+aliases = ["robot"]
+description = "A metallic, modulated voice."
+
+[[param]]
+key = "depth"
+label = "Depth"
+min = 1
+max = 10
+default = 5
+step = 0.5
+
+[ffmpeg]
+chain = "aphaser=type=t:speed={fixed(0.4 + (depth / 10) * 1.6, 2)}:decay=0.6,flanger=delay=2:depth=4:speed=0.8,equalizer=f=1800:t=q:w=1.2:g=3,alimiter=limit=0.94"
diff --git a/engine/crates/concat-effects/packages/concat.robot/fixtures.toml b/engine/crates/concat-effects/packages/concat.robot/fixtures.toml
new file mode 100644
index 00000000..9b2a924f
--- /dev/null
+++ b/engine/crates/concat-effects/packages/concat.robot/fixtures.toml
@@ -0,0 +1,13 @@
+[[case]]
+name = "default"
+chain = "aphaser=type=t:speed=1.20:decay=0.6,flanger=delay=2:depth=4:speed=0.8,equalizer=f=1800:t=q:w=1.2:g=3,alimiter=limit=0.94"
+
+[[case]]
+name = "minimum"
+at = "min"
+chain = "aphaser=type=t:speed=0.56:decay=0.6,flanger=delay=2:depth=4:speed=0.8,equalizer=f=1800:t=q:w=1.2:g=3,alimiter=limit=0.94"
+
+[[case]]
+name = "maximum"
+at = "max"
+chain = "aphaser=type=t:speed=2.00:decay=0.6,flanger=delay=2:depth=4:speed=0.8,equalizer=f=1800:t=q:w=1.2:g=3,alimiter=limit=0.94"
diff --git a/engine/crates/concat-effects/packages/concat.room/effect.toml b/engine/crates/concat-effects/packages/concat.room/effect.toml
new file mode 100644
index 00000000..adc3140e
--- /dev/null
+++ b/engine/crates/concat-effects/packages/concat.room/effect.toml
@@ -0,0 +1,24 @@
+[effect]
+id = "concat.room"
+name = "Room"
+kind = "filter"
+category = "Space"
+order = 31
+intensity = "size"
+aliases = ["room"]
+description = "The early reflections of a room."
+
+[[param]]
+key = "size"
+label = "Size"
+min = 0
+max = 100
+default = 40
+step = 1
+unit = "%"
+
+[ffmpeg]
+let = [
+ "scale = 0.4 + (size / 100) * 1.6",
+]
+chain = "aecho=0.8:0.88:{round(23 * scale)}|{round(41 * scale)}|{round(67 * scale)}|{round(97 * scale)}:0.320|0.240|0.170|0.110"
diff --git a/engine/crates/concat-effects/packages/concat.room/fixtures.toml b/engine/crates/concat-effects/packages/concat.room/fixtures.toml
new file mode 100644
index 00000000..8655b459
--- /dev/null
+++ b/engine/crates/concat-effects/packages/concat.room/fixtures.toml
@@ -0,0 +1,13 @@
+[[case]]
+name = "default"
+chain = "aecho=0.8:0.88:24|43|70|101:0.320|0.240|0.170|0.110"
+
+[[case]]
+name = "minimum"
+at = "min"
+chain = "aecho=0.8:0.88:9|16|27|39:0.320|0.240|0.170|0.110"
+
+[[case]]
+name = "maximum"
+at = "max"
+chain = "aecho=0.8:0.88:46|82|134|194:0.320|0.240|0.170|0.110"
diff --git a/engine/crates/concat-effects/packages/concat.sepia/effect.toml b/engine/crates/concat-effects/packages/concat.sepia/effect.toml
new file mode 100644
index 00000000..0776038d
--- /dev/null
+++ b/engine/crates/concat-effects/packages/concat.sepia/effect.toml
@@ -0,0 +1,11 @@
+[effect]
+id = "concat.sepia"
+name = "Sepia"
+kind = "effect"
+category = "Basic"
+order = 11
+aliases = ["sepia"]
+description = "The warm brown of an old photograph."
+
+[ffmpeg]
+chain = "colorchannelmixer=.393:.769:.189:0:.349:.686:.168:0:.272:.534:.131"
diff --git a/engine/crates/concat-effects/packages/concat.sepia/fixtures.toml b/engine/crates/concat-effects/packages/concat.sepia/fixtures.toml
new file mode 100644
index 00000000..a70df7d1
--- /dev/null
+++ b/engine/crates/concat-effects/packages/concat.sepia/fixtures.toml
@@ -0,0 +1,3 @@
+[[case]]
+name = "default"
+chain = "colorchannelmixer=.393:.769:.189:0:.349:.686:.168:0:.272:.534:.131"
diff --git a/engine/crates/concat-effects/packages/concat.shake/effect.toml b/engine/crates/concat-effects/packages/concat.shake/effect.toml
new file mode 100644
index 00000000..fa65c60d
--- /dev/null
+++ b/engine/crates/concat-effects/packages/concat.shake/effect.toml
@@ -0,0 +1,35 @@
+[effect]
+id = "concat.shake"
+name = "Shake"
+kind = "effect"
+category = "Distort"
+order = 53
+intensity = "amount"
+aliases = ["shake"]
+description = "A handheld jitter."
+
+[[param]]
+key = "amount"
+label = "Amount"
+type = "int"
+min = 2
+max = 40
+default = 12
+step = 1
+unit = "px"
+
+[[param]]
+key = "speed"
+label = "Speed"
+min = 2
+max = 30
+default = 13
+step = 1
+
+[ffmpeg]
+let = [
+ "a = round(amount)",
+ "f = round(speed)",
+ "f2 = round(f * 1.3)",
+]
+chain = "crop=iw-{2 * a}:ih-{2 * a}:{a}+{a}*sin(t*{f}):{a}+{a}*cos(t*{f2})"
diff --git a/engine/crates/concat-effects/packages/concat.shake/fixtures.toml b/engine/crates/concat-effects/packages/concat.shake/fixtures.toml
new file mode 100644
index 00000000..04ad6691
--- /dev/null
+++ b/engine/crates/concat-effects/packages/concat.shake/fixtures.toml
@@ -0,0 +1,13 @@
+[[case]]
+name = "default"
+chain = "crop=iw-24:ih-24:12+12*sin(t*13):12+12*cos(t*17)"
+
+[[case]]
+name = "minimum"
+at = "min"
+chain = "crop=iw-4:ih-4:2+2*sin(t*2):2+2*cos(t*3)"
+
+[[case]]
+name = "maximum"
+at = "max"
+chain = "crop=iw-80:ih-80:40+40*sin(t*30):40+40*cos(t*39)"
diff --git a/engine/crates/concat-effects/packages/concat.sharpen/effect.toml b/engine/crates/concat-effects/packages/concat.sharpen/effect.toml
new file mode 100644
index 00000000..59a2775f
--- /dev/null
+++ b/engine/crates/concat-effects/packages/concat.sharpen/effect.toml
@@ -0,0 +1,20 @@
+[effect]
+id = "concat.sharpen"
+name = "Sharpen"
+kind = "effect"
+category = "Basic"
+order = 13
+intensity = "amount"
+aliases = ["sharpen"]
+description = "Crisper edges."
+
+[[param]]
+key = "amount"
+label = "Amount"
+min = 0.2
+max = 3
+default = 1
+step = 0.05
+
+[ffmpeg]
+chain = "unsharp=5:5:{fixed(amount, 2)}:5:5:0"
diff --git a/engine/crates/concat-effects/packages/concat.sharpen/fixtures.toml b/engine/crates/concat-effects/packages/concat.sharpen/fixtures.toml
new file mode 100644
index 00000000..20198425
--- /dev/null
+++ b/engine/crates/concat-effects/packages/concat.sharpen/fixtures.toml
@@ -0,0 +1,13 @@
+[[case]]
+name = "default"
+chain = "unsharp=5:5:1.00:5:5:0"
+
+[[case]]
+name = "minimum"
+at = "min"
+chain = "unsharp=5:5:0.20:5:5:0"
+
+[[case]]
+name = "maximum"
+at = "max"
+chain = "unsharp=5:5:3.00:5:5:0"
diff --git a/engine/crates/concat-effects/packages/concat.sweet/effect.toml b/engine/crates/concat-effects/packages/concat.sweet/effect.toml
new file mode 100644
index 00000000..fc23cf67
--- /dev/null
+++ b/engine/crates/concat-effects/packages/concat.sweet/effect.toml
@@ -0,0 +1,35 @@
+[effect]
+id = "concat.sweet"
+name = "Sweet"
+kind = "filter"
+category = "Voice"
+order = 10
+intensity = "amount"
+aliases = ["sweet"]
+description = "A brighter, lighter, closer voice. Pitch at 0 follows the amount."
+
+[[param]]
+key = "amount"
+label = "Amount"
+min = 0
+max = 100
+default = 65
+step = 1
+unit = "%"
+
+[[param]]
+key = "pitch"
+label = "Pitch"
+min = 0
+max = 8
+default = 0
+step = 0.5
+unit = "st"
+
+[ffmpeg]
+let = [
+ "strength = clamp(amount, 0, 100) / 100",
+ "shift = if(pitch > 0, pitch, 1.2 + 3.8 * strength)",
+ "ratio = pow(2, shift / 12)",
+]
+chain = "aresample=48000,asetrate={fixed(48000 * ratio, 6)},aresample=48000,atempo={fixed(1 / ratio, 8)},highpass=f=85,equalizer=f=300:t=q:w=1.1:g=-1.4,equalizer=f=4200:t=q:w=0.8:g={fixed(0.8 + 5.2 * strength, 3)},equalizer=f=10500:t=q:w=0.7:g={fixed(1.0 + 7.0 * strength, 3)},compand=attacks=0.010:decays=0.180:points=-80/-80|-30/-24|-18/-13|-8/-5|0/-1.5:soft-knee=5:gain=1,deesser=i={fixed(0.18 + 0.32 * strength, 3)}:m=0.45:f=0.55,aecho=0.8:0.82:38:{fixed(0.012 + 0.048 * strength, 4)},alimiter=limit=0.94:attack=5:release=60"
diff --git a/engine/crates/concat-effects/packages/concat.sweet/fixtures.toml b/engine/crates/concat-effects/packages/concat.sweet/fixtures.toml
new file mode 100644
index 00000000..4c75fc53
--- /dev/null
+++ b/engine/crates/concat-effects/packages/concat.sweet/fixtures.toml
@@ -0,0 +1,13 @@
+[[case]]
+name = "default"
+chain = "aresample=48000,asetrate=59334.357554,aresample=48000,atempo=0.80897480,highpass=f=85,equalizer=f=300:t=q:w=1.1:g=-1.4,equalizer=f=4200:t=q:w=0.8:g=4.180,equalizer=f=10500:t=q:w=0.7:g=5.550,compand=attacks=0.010:decays=0.180:points=-80/-80|-30/-24|-18/-13|-8/-5|0/-1.5:soft-knee=5:gain=1,deesser=i=0.388:m=0.45:f=0.55,aecho=0.8:0.82:38:0.0432,alimiter=limit=0.94:attack=5:release=60"
+
+[[case]]
+name = "minimum"
+at = "min"
+chain = "aresample=48000,asetrate=51445.126202,aresample=48000,atempo=0.93303299,highpass=f=85,equalizer=f=300:t=q:w=1.1:g=-1.4,equalizer=f=4200:t=q:w=0.8:g=0.800,equalizer=f=10500:t=q:w=0.7:g=1.000,compand=attacks=0.010:decays=0.180:points=-80/-80|-30/-24|-18/-13|-8/-5|0/-1.5:soft-knee=5:gain=1,deesser=i=0.180:m=0.45:f=0.55,aecho=0.8:0.82:38:0.0120,alimiter=limit=0.94:attack=5:release=60"
+
+[[case]]
+name = "maximum"
+at = "max"
+chain = "aresample=48000,asetrate=76195.250494,aresample=48000,atempo=0.62996052,highpass=f=85,equalizer=f=300:t=q:w=1.1:g=-1.4,equalizer=f=4200:t=q:w=0.8:g=6.000,equalizer=f=10500:t=q:w=0.7:g=8.000,compand=attacks=0.010:decays=0.180:points=-80/-80|-30/-24|-18/-13|-8/-5|0/-1.5:soft-knee=5:gain=1,deesser=i=0.500:m=0.45:f=0.55,aecho=0.8:0.82:38:0.0600,alimiter=limit=0.94:attack=5:release=60"
diff --git a/engine/crates/concat-effects/packages/concat.telephone/effect.toml b/engine/crates/concat-effects/packages/concat.telephone/effect.toml
new file mode 100644
index 00000000..804259ec
--- /dev/null
+++ b/engine/crates/concat-effects/packages/concat.telephone/effect.toml
@@ -0,0 +1,20 @@
+[effect]
+id = "concat.telephone"
+name = "Telephone"
+kind = "filter"
+category = "Tone"
+order = 22
+intensity = "drive"
+aliases = ["telephone"]
+description = "The narrow band of a phone line."
+
+[[param]]
+key = "drive"
+label = "Drive"
+min = 0
+max = 10
+default = 3
+step = 0.5
+
+[ffmpeg]
+chain = "highpass=f=400,lowpass=f=3400,equalizer=f=1600:t=q:w=1.4:g={fixed(3 + drive / 2, 2)},alimiter=limit=0.92"
diff --git a/engine/crates/concat-effects/packages/concat.telephone/fixtures.toml b/engine/crates/concat-effects/packages/concat.telephone/fixtures.toml
new file mode 100644
index 00000000..fb92d18b
--- /dev/null
+++ b/engine/crates/concat-effects/packages/concat.telephone/fixtures.toml
@@ -0,0 +1,13 @@
+[[case]]
+name = "default"
+chain = "highpass=f=400,lowpass=f=3400,equalizer=f=1600:t=q:w=1.4:g=4.50,alimiter=limit=0.92"
+
+[[case]]
+name = "minimum"
+at = "min"
+chain = "highpass=f=400,lowpass=f=3400,equalizer=f=1600:t=q:w=1.4:g=3.00,alimiter=limit=0.92"
+
+[[case]]
+name = "maximum"
+at = "max"
+chain = "highpass=f=400,lowpass=f=3400,equalizer=f=1600:t=q:w=1.4:g=8.00,alimiter=limit=0.92"
diff --git a/engine/crates/concat-effects/packages/concat.treble/effect.toml b/engine/crates/concat-effects/packages/concat.treble/effect.toml
new file mode 100644
index 00000000..5b94a7f7
--- /dev/null
+++ b/engine/crates/concat-effects/packages/concat.treble/effect.toml
@@ -0,0 +1,21 @@
+[effect]
+id = "concat.treble"
+name = "Treble"
+kind = "filter"
+category = "Tone"
+order = 21
+intensity = "gain"
+aliases = ["treble"]
+description = "More sparkle."
+
+[[param]]
+key = "gain"
+label = "Gain"
+min = 0
+max = 12
+default = 4
+step = 0.5
+unit = "dB"
+
+[ffmpeg]
+chain = "treble=g={fixed(gain, 2)}:f=9000:w=0.7,alimiter=limit=0.95"
diff --git a/engine/crates/concat-effects/packages/concat.treble/fixtures.toml b/engine/crates/concat-effects/packages/concat.treble/fixtures.toml
new file mode 100644
index 00000000..db4b5ed1
--- /dev/null
+++ b/engine/crates/concat-effects/packages/concat.treble/fixtures.toml
@@ -0,0 +1,13 @@
+[[case]]
+name = "default"
+chain = "treble=g=4.00:f=9000:w=0.7,alimiter=limit=0.95"
+
+[[case]]
+name = "minimum"
+at = "min"
+chain = "treble=g=0.00:f=9000:w=0.7,alimiter=limit=0.95"
+
+[[case]]
+name = "maximum"
+at = "max"
+chain = "treble=g=12.00:f=9000:w=0.7,alimiter=limit=0.95"
diff --git a/engine/crates/concat-effects/packages/concat.vibrance/effect.toml b/engine/crates/concat-effects/packages/concat.vibrance/effect.toml
new file mode 100644
index 00000000..b9c11aa3
--- /dev/null
+++ b/engine/crates/concat-effects/packages/concat.vibrance/effect.toml
@@ -0,0 +1,20 @@
+[effect]
+id = "concat.vibrance"
+name = "Vibrance"
+kind = "effect"
+category = "Color"
+order = 32
+intensity = "intensity"
+aliases = ["vibrance"]
+description = "Richer colour where it is muted, without blowing out what is already strong."
+
+[[param]]
+key = "intensity"
+label = "Intensity"
+min = 0.1
+max = 2
+default = 0.7
+step = 0.05
+
+[ffmpeg]
+chain = "vibrance=intensity={fixed(intensity, 2)}"
diff --git a/engine/crates/concat-effects/packages/concat.vibrance/fixtures.toml b/engine/crates/concat-effects/packages/concat.vibrance/fixtures.toml
new file mode 100644
index 00000000..d6ffbaaf
--- /dev/null
+++ b/engine/crates/concat-effects/packages/concat.vibrance/fixtures.toml
@@ -0,0 +1,13 @@
+[[case]]
+name = "default"
+chain = "vibrance=intensity=0.70"
+
+[[case]]
+name = "minimum"
+at = "min"
+chain = "vibrance=intensity=0.10"
+
+[[case]]
+name = "maximum"
+at = "max"
+chain = "vibrance=intensity=2.00"
diff --git a/engine/crates/concat-effects/packages/concat.vignette/effect.toml b/engine/crates/concat-effects/packages/concat.vignette/effect.toml
new file mode 100644
index 00000000..2645116d
--- /dev/null
+++ b/engine/crates/concat-effects/packages/concat.vignette/effect.toml
@@ -0,0 +1,21 @@
+[effect]
+id = "concat.vignette"
+name = "Vignette"
+kind = "effect"
+category = "Stylize"
+order = 40
+intensity = "strength"
+aliases = ["vignette"]
+description = "Darkened corners that draw the eye to the middle."
+
+[[param]]
+key = "strength"
+label = "Strength"
+min = 10
+max = 100
+default = 50
+step = 1
+unit = "%"
+
+[ffmpeg]
+chain = "vignette=angle={fixed(0.25 + (strength / 100) * 1.05, 3)}"
diff --git a/engine/crates/concat-effects/packages/concat.vignette/fixtures.toml b/engine/crates/concat-effects/packages/concat.vignette/fixtures.toml
new file mode 100644
index 00000000..a0a4098c
--- /dev/null
+++ b/engine/crates/concat-effects/packages/concat.vignette/fixtures.toml
@@ -0,0 +1,13 @@
+[[case]]
+name = "default"
+chain = "vignette=angle=0.775"
+
+[[case]]
+name = "minimum"
+at = "min"
+chain = "vignette=angle=0.355"
+
+[[case]]
+name = "maximum"
+at = "max"
+chain = "vignette=angle=1.300"
diff --git a/engine/crates/concat-effects/packages/concat.warm/effect.toml b/engine/crates/concat-effects/packages/concat.warm/effect.toml
new file mode 100644
index 00000000..35e0808f
--- /dev/null
+++ b/engine/crates/concat-effects/packages/concat.warm/effect.toml
@@ -0,0 +1,21 @@
+[effect]
+id = "concat.warm"
+name = "Warm"
+kind = "effect"
+category = "Color"
+order = 30
+intensity = "temperature"
+aliases = ["warm"]
+description = "Shifts the picture towards candlelight."
+
+[[param]]
+key = "temperature"
+label = "Temperature"
+min = 3000
+max = 6000
+default = 4600
+step = 50
+unit = "K"
+
+[ffmpeg]
+chain = "colortemperature=temperature={round(temperature)}"
diff --git a/engine/crates/concat-effects/packages/concat.warm/fixtures.toml b/engine/crates/concat-effects/packages/concat.warm/fixtures.toml
new file mode 100644
index 00000000..70fca5a0
--- /dev/null
+++ b/engine/crates/concat-effects/packages/concat.warm/fixtures.toml
@@ -0,0 +1,13 @@
+[[case]]
+name = "default"
+chain = "colortemperature=temperature=4600"
+
+[[case]]
+name = "minimum"
+at = "min"
+chain = "colortemperature=temperature=3000"
+
+[[case]]
+name = "maximum"
+at = "max"
+chain = "colortemperature=temperature=6000"
diff --git a/engine/crates/concat-effects/src/catalogue.rs b/engine/crates/concat-effects/src/catalogue.rs
new file mode 100644
index 00000000..62aa82c8
--- /dev/null
+++ b/engine/crates/concat-effects/src/catalogue.rs
@@ -0,0 +1,450 @@
+// SPDX-License-Identifier: AGPL-3.0-or-later
+// SPDX-FileCopyrightText: 2026 Jareer and Concat contributors
+
+//! Packages, and the catalogue that holds them.
+//!
+//! A [`Package`] is a manifest compiled for use: its templates parsed, its
+//! `let` bindings checked, its fixtures loaded. A [`Catalogue`] is every
+//! package the app knows, findable by id or alias, and it is what turns a
+//! clip's applied effects into one FFmpeg chain.
+
+use std::collections::{BTreeMap, HashMap};
+use std::path::Path;
+use std::sync::OnceLock;
+
+use concat_project::model::AppliedFilter;
+use serde::Deserialize;
+
+use crate::Error;
+use crate::expr::{Expr, Value};
+use crate::manifest::{Kind, Manifest};
+use crate::template::Template;
+
+/// A compiled FFmpeg backend.
+#[derive(Clone, Debug)]
+struct Chain {
+ lets: Vec<(String, Expr)>,
+ template: Template,
+}
+
+/// One effect, ready to use.
+#[derive(Clone, Debug)]
+pub struct Package {
+ /// What the package declares.
+ pub manifest: Manifest,
+ chain: Option<Chain>,
+ /// The pinned outputs shipped with the package.
+ pub fixtures: Vec<Fixture>,
+}
+
+/// Where a fixture's parameters start from.
+#[derive(Deserialize, Clone, Copy, PartialEq, Eq, Debug, Default)]
+#[serde(rename_all = "lowercase")]
+pub enum At {
+ /// Every parameter at its default.
+ #[default]
+ Default,
+ /// Every parameter at its minimum.
+ Min,
+ /// Every parameter at its maximum.
+ Max,
+}
+
+/// One pinned case from `fixtures.toml`: these parameters produce exactly
+/// this chain.
+#[derive(Deserialize, Clone, PartialEq, Debug)]
+#[serde(deny_unknown_fields)]
+pub struct Fixture {
+ /// A name for the failure message.
+ #[serde(default)]
+ pub name: String,
+ /// The starting point every parameter takes.
+ #[serde(default)]
+ pub at: At,
+ /// Parameters set on top of `at`.
+ #[serde(default)]
+ pub params: BTreeMap<String, f64>,
+ /// The emitted position the fragment is rendered at.
+ #[serde(default)]
+ pub index: usize,
+ /// The expected chain.
+ pub chain: String,
+}
+
+#[derive(Deserialize)]
+#[serde(deny_unknown_fields)]
+struct FixtureFile {
+ #[serde(default, rename = "case")]
+ cases: Vec<Fixture>,
+}
+
+impl Package {
+ /// Compiles a package from the text of its manifest and, if it ships
+ /// one, its fixtures file.
+ pub fn from_sources(manifest: &str, fixtures: Option<&str>) -> Result<Package, Error> {
+ let manifest = Manifest::parse(manifest)?;
+ let invalid = |message: String| Error::Invalid {
+ id: manifest.effect.id.clone(),
+ message,
+ };
+
+ let chain = match &manifest.ffmpeg {
+ None => None,
+ Some(ffmpeg) => {
+ let mut known: Vec<String> =
+ manifest.params.iter().map(|p| p.key.clone()).collect();
+ known.push("index".to_owned());
+ let mut lets = Vec::new();
+ for binding in &ffmpeg.lets {
+ let Some((name, source)) = binding.split_once('=') else {
+ return Err(invalid(format!(
+ "let `{binding}` is not `name = expression`"
+ )));
+ };
+ let name = name.trim();
+ if known.iter().any(|k| k == name) {
+ return Err(invalid(format!(
+ "let `{name}` shadows a name already defined"
+ )));
+ }
+ let expr = Expr::parse(source.trim())
+ .map_err(|error| invalid(format!("let `{name}`: {error}")))?;
+ check_names(&expr, &known).map_err(invalid)?;
+ known.push(name.to_owned());
+ lets.push((name.to_owned(), expr));
+ }
+ let template = Template::parse(&ffmpeg.chain)
+ .map_err(|error| invalid(format!("chain: {error}")))?;
+ let mut names = Vec::new();
+ template.names(&mut names);
+ for name in names {
+ if !known.contains(&name) {
+ return Err(invalid(format!(
+ "chain reads `{name}`, which is not declared"
+ )));
+ }
+ }
+ Some(Chain { lets, template })
+ }
+ };
+
+ let fixtures = match fixtures {
+ None => Vec::new(),
+ Some(source) => {
+ let file: FixtureFile = toml::from_str(source)
+ .map_err(|error| invalid(format!("fixtures: {error}")))?;
+ file.cases
+ }
+ };
+
+ let package = Package {
+ manifest,
+ chain,
+ fixtures,
+ };
+ // Render at every bound now, so a type error in an expression is a
+ // load failure and never a silent gap in an export.
+ if package.chain.is_some() {
+ for at in [At::Default, At::Min, At::Max] {
+ package
+ .ffmpeg_fragment(&package.params_at(at), 0)
+ .map_err(|error| Error::Invalid {
+ id: package.id().to_owned(),
+ message: format!("chain at {at:?}: {error}"),
+ })?;
+ }
+ }
+ Ok(package)
+ }
+
+ /// The namespaced id.
+ pub fn id(&self) -> &str {
+ &self.manifest.effect.id
+ }
+
+ /// Which catalogue the package belongs to.
+ pub fn kind(&self) -> Kind {
+ self.manifest.effect.kind
+ }
+
+ /// Whether `id` is this package's id or one of its aliases.
+ pub fn answers_to(&self, id: &str) -> bool {
+ self.id() == id || self.manifest.effect.aliases.iter().any(|alias| alias == id)
+ }
+
+ /// Every declared parameter at `at`.
+ pub fn params_at(&self, at: At) -> BTreeMap<String, f64> {
+ self.manifest
+ .params
+ .iter()
+ .map(|param| {
+ let value = match at {
+ At::Default => param.default,
+ At::Min => param.min,
+ At::Max => param.max,
+ };
+ (param.key.clone(), value)
+ })
+ .collect()
+ }
+
+ /// Every declared parameter: the value in `set`, or the default. Keys
+ /// the manifest does not declare are dropped.
+ pub fn resolve(&self, set: &BTreeMap<String, f64>) -> BTreeMap<String, f64> {
+ self.manifest
+ .params
+ .iter()
+ .map(|param| {
+ let value = set.get(&param.key).copied().unwrap_or(param.default);
+ (param.key.clone(), value)
+ })
+ .collect()
+ }
+
+ /// The FFmpeg fragment for these parameters, or `None` when the package
+ /// has no FFmpeg backend. `index` is the fragment's emitted position in
+ /// the clip's chain; any filtergraph labels must embed it.
+ pub fn ffmpeg_fragment(
+ &self,
+ set: &BTreeMap<String, f64>,
+ index: usize,
+ ) -> Result<Option<String>, Error> {
+ let Some(chain) = &self.chain else {
+ return Ok(None);
+ };
+ let mut env: BTreeMap<String, Value> = self
+ .resolve(set)
+ .into_iter()
+ .map(|(key, value)| (key, Value::Float(value)))
+ .collect();
+ env.insert("index".to_owned(), Value::Int(index as i64));
+ let invalid = |message: String| Error::Invalid {
+ id: self.id().to_owned(),
+ message,
+ };
+ for (name, expr) in &chain.lets {
+ let value = expr
+ .eval(&env)
+ .map_err(|error| invalid(format!("let `{name}`: {error}")))?;
+ env.insert(name.clone(), value);
+ }
+ chain
+ .template
+ .render(&env)
+ .map(Some)
+ .map_err(|error| invalid(format!("chain: {error}")))
+ }
+
+ /// Runs every fixture; returns one line per failure.
+ pub fn check_fixtures(&self) -> Vec<String> {
+ let mut failures = Vec::new();
+ for (n, case) in self.fixtures.iter().enumerate() {
+ let mut params = self.params_at(case.at);
+ for (key, value) in &case.params {
+ params.insert(key.clone(), *value);
+ }
+ let label = if case.name.is_empty() {
+ format!("case {}", n + 1)
+ } else {
+ case.name.clone()
+ };
+ match self.ffmpeg_fragment(&params, case.index) {
+ Ok(Some(chain)) if chain == case.chain => {}
+ Ok(Some(chain)) => failures.push(format!(
+ "{}: {label}\n expected {}\n rendered {chain}",
+ self.id(),
+ case.chain
+ )),
+ Ok(None) => failures.push(format!("{}: {label}: no ffmpeg backend", self.id())),
+ Err(error) => failures.push(format!("{}: {label}: {error}", self.id())),
+ }
+ }
+ failures
+ }
+}
+
+fn check_names(expr: &Expr, known: &[String]) -> Result<(), String> {
+ let mut names = Vec::new();
+ expr.names(&mut names);
+ for name in names {
+ if !known.contains(&name) {
+ return Err(format!("reads `{name}`, which is not declared"));
+ }
+ }
+ Ok(())
+}
+
+/// Every package the app knows.
+#[derive(Clone, Debug, Default)]
+pub struct Catalogue {
+ packages: Vec<Package>,
+ by_id: HashMap<String, usize>,
+}
+
+impl Catalogue {
+ /// An empty catalogue.
+ pub fn new() -> Self {
+ Self::default()
+ }
+
+ /// The packages compiled into the binary. Loaded once; a built-in that
+ /// fails to load is a build defect, and the tests catch it.
+ pub fn builtin() -> &'static Catalogue {
+ static BUILTIN: OnceLock<Catalogue> = OnceLock::new();
+ BUILTIN.get_or_init(|| {
+ let mut catalogue = Catalogue::new();
+ for (folder, manifest, fixtures) in crate::builtins::BUILTIN_SOURCES {
+ let package = Package::from_sources(manifest, *fixtures)
+ .unwrap_or_else(|error| panic!("built-in package {folder}: {error}"));
+ assert_eq!(
+ package.id(),
+ *folder,
+ "package folder must be named after its id"
+ );
+ catalogue
+ .add(package)
+ .unwrap_or_else(|error| panic!("built-in package {folder}: {error}"));
+ }
+ catalogue.sort();
+ catalogue
+ })
+ }
+
+ /// Adds a package. Its id and aliases must be new to the catalogue.
+ pub fn add(&mut self, package: Package) -> Result<(), Error> {
+ let mut names = vec![package.id().to_owned()];
+ names.extend(package.manifest.effect.aliases.iter().cloned());
+ for name in &names {
+ if self.by_id.contains_key(name) {
+ return Err(Error::Invalid {
+ id: package.id().to_owned(),
+ message: format!("`{name}` is already taken by another package"),
+ });
+ }
+ }
+ let index = self.packages.len();
+ for name in names {
+ self.by_id.insert(name, index);
+ }
+ self.packages.push(package);
+ Ok(())
+ }
+
+ /// Loads every package folder directly under `dir`. A folder that fails
+ /// is reported and skipped; the rest still load.
+ pub fn load_dir(&mut self, dir: &Path) -> Vec<Error> {
+ let mut errors = Vec::new();
+ let entries = match std::fs::read_dir(dir) {
+ Ok(entries) => entries,
+ Err(error) => {
+ return vec![Error::Io {
+ path: dir.to_path_buf(),
+ message: error.to_string(),
+ }];
+ }
+ };
+ let mut folders: Vec<_> = entries
+ .filter_map(Result::ok)
+ .map(|entry| entry.path())
+ .filter(|path| path.join("effect.toml").is_file())
+ .collect();
+ folders.sort();
+ for folder in folders {
+ let read = |name: &str| std::fs::read_to_string(folder.join(name));
+ let manifest = match read("effect.toml") {
+ Ok(text) => text,
+ Err(error) => {
+ errors.push(Error::Io {
+ path: folder.join("effect.toml"),
+ message: error.to_string(),
+ });
+ continue;
+ }
+ };
+ let fixtures = read("fixtures.toml").ok();
+ match Package::from_sources(&manifest, fixtures.as_deref()).and_then(|p| self.add(p)) {
+ Ok(()) => {}
+ Err(error) => errors.push(error),
+ }
+ }
+ self.sort();
+ errors
+ }
+
+ fn sort(&mut self) {
+ let mut order: Vec<usize> = (0..self.packages.len()).collect();
+ order.sort_by(|&a, &b| {
+ let (a, b) = (
+ &self.packages[a].manifest.effect,
+ &self.packages[b].manifest.effect,
+ );
+ (a.order, a.name.as_str()).cmp(&(b.order, b.name.as_str()))
+ });
+ let packages: Vec<Package> = order.iter().map(|&i| self.packages[i].clone()).collect();
+ self.packages = packages;
+ self.by_id.clear();
+ for (index, package) in self.packages.iter().enumerate() {
+ self.by_id.insert(package.id().to_owned(), index);
+ for alias in &package.manifest.effect.aliases {
+ self.by_id.insert(alias.clone(), index);
+ }
+ }
+ }
+
+ /// The package with this id or alias.
+ pub fn get(&self, id: &str) -> Option<&Package> {
+ self.by_id.get(id).map(|&index| &self.packages[index])
+ }
+
+ /// Every package, in catalogue order.
+ pub fn packages(&self) -> impl Iterator<Item = &Package> {
+ self.packages.iter()
+ }
+
+ /// Every package of one kind, in catalogue order.
+ pub fn of_kind(&self, kind: Kind) -> impl Iterator<Item = &Package> {
+ self.packages
+ .iter()
+ .filter(move |package| package.kind() == kind)
+ }
+
+ /// The complete FFmpeg video filter string for a clip's effects, or the
+ /// empty string if it has none. Effects apply in the order they were
+ /// added.
+ pub fn video_chain(&self, effects: &[AppliedFilter]) -> String {
+ self.compose(Kind::Effect, effects)
+ }
+
+ /// The complete FFmpeg audio filter string for a clip's filters, or the
+ /// empty string if it has none. Filters apply in the order they were
+ /// added: EQ before a limiter is a different sound from the reverse.
+ pub fn audio_chain(&self, filters: &[AppliedFilter]) -> String {
+ self.compose(Kind::Filter, filters)
+ }
+
+ /// Enabled entries of `kind` in applied order, comma-joined. Bypassed
+ /// entries, unknown ids, packages of another kind and packages without
+ /// an FFmpeg backend contribute nothing. The index each fragment is
+ /// rendered at is its *emitted* position, so labels stay stable when a
+ /// bypassed entry sits earlier in the list.
+ fn compose(&self, kind: Kind, applied: &[AppliedFilter]) -> String {
+ let mut fragments: Vec<String> = Vec::new();
+ for applied in applied.iter().filter(|applied| applied.enabled) {
+ let Some(package) = self.get(&applied.id) else {
+ continue;
+ };
+ if package.kind() != kind {
+ continue;
+ }
+ match package.ffmpeg_fragment(&applied.params, fragments.len()) {
+ Ok(Some(fragment)) => fragments.push(fragment),
+ Ok(None) => {}
+ // Every template was rendered at load; a failure here is a
+ // package whose expression only breaks for some value. Drop
+ // the fragment rather than export a broken graph.
+ Err(_) => {}
+ }
+ }
+ fragments.join(",")
+ }
+}
diff --git a/engine/crates/concat-effects/src/expr.rs b/engine/crates/concat-effects/src/expr.rs
new file mode 100644
index 00000000..fa5381cd
--- /dev/null
+++ b/engine/crates/concat-effects/src/expr.rs
@@ -0,0 +1,551 @@
+// SPDX-License-Identifier: AGPL-3.0-or-later
+// SPDX-FileCopyrightText: 2026 Jareer and Concat contributors
+
+//! The expression language inside a template's `{...}` slots.
+//!
+//! Small on purpose: numbers, the parameters, arithmetic, comparison, and a
+//! fixed set of functions. It is the whole of what a package can compute,
+//! which makes it the security boundary as much as a convenience: nothing an
+//! expression evaluates to can be anything but a number or a formatted
+//! number.
+//!
+//! Values carry whether they are integers: `round` yields an integer, which
+//! prints as `12` rather than `12.0`, and integer arithmetic stays integer
+//! except for division. `fixed(x, n)` yields text with exactly `n` decimals,
+//! which is how a filtergraph wants most of its numbers.
+
+use std::collections::BTreeMap;
+use std::fmt;
+
+/// What an expression evaluates to.
+#[derive(Clone, PartialEq, Debug)]
+pub enum Value {
+ /// A whole number: the result of `round`, or arithmetic on whole numbers.
+ Int(i64),
+ /// A real number.
+ Float(f64),
+ /// Text, from `fixed`. Only ever substituted, never computed with.
+ Text(String),
+}
+
+impl Value {
+ fn as_f64(&self, what: &str) -> Result<f64, EvalError> {
+ match self {
+ Value::Int(n) => Ok(*n as f64),
+ Value::Float(x) => Ok(*x),
+ Value::Text(_) => Err(EvalError(format!("{what}: text where a number was needed"))),
+ }
+ }
+}
+
+impl fmt::Display for Value {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ match self {
+ Value::Int(n) => write!(f, "{n}"),
+ Value::Float(x) => write!(f, "{x}"),
+ Value::Text(s) => f.write_str(s),
+ }
+ }
+}
+
+/// Why an expression could not be parsed or evaluated.
+#[derive(Clone, PartialEq, Eq, Debug)]
+pub struct EvalError(pub String);
+
+impl fmt::Display for EvalError {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ f.write_str(&self.0)
+ }
+}
+
+impl std::error::Error for EvalError {}
+
+/// A parsed expression.
+#[derive(Clone, PartialEq, Debug)]
+pub enum Expr {
+ /// A literal number.
+ Number(f64),
+ /// A parameter, a `let` binding, or `index`.
+ Name(String),
+ /// Negation.
+ Neg(Box<Expr>),
+ /// A binary operator applied to two operands.
+ Binary(Op, Box<Expr>, Box<Expr>),
+ /// A function call.
+ Call(String, Vec<Expr>),
+}
+
+/// The binary operators.
+#[derive(Clone, Copy, PartialEq, Eq, Debug)]
+pub enum Op {
+ /// `+`
+ Add,
+ /// `-`
+ Sub,
+ /// `*`
+ Mul,
+ /// `/`
+ Div,
+ /// `<`
+ Lt,
+ /// `>`
+ Gt,
+ /// `<=`
+ Le,
+ /// `>=`
+ Ge,
+ /// `==`
+ Eq,
+ /// `!=`
+ Ne,
+}
+
+/// The functions an expression may call, with their arities.
+const FUNCTIONS: &[(&str, usize)] = &[
+ ("if", 3),
+ ("clamp", 3),
+ ("min", 2),
+ ("max", 2),
+ ("abs", 1),
+ ("floor", 1),
+ ("ceil", 1),
+ ("round", 1),
+ ("sqrt", 1),
+ ("pow", 2),
+ ("fixed", 2),
+];
+
+// ─── parsing ────────────────────────────────────────────────────────────────
+
+#[derive(Clone, PartialEq, Debug)]
+enum Token {
+ Number(f64),
+ Ident(String),
+ Op(Op),
+ Plus,
+ Minus,
+ Star,
+ Slash,
+ LParen,
+ RParen,
+ Comma,
+}
+
+fn tokenize(source: &str) -> Result<Vec<Token>, EvalError> {
+ let chars: Vec<char> = source.chars().collect();
+ let mut tokens = Vec::new();
+ let mut i = 0;
+ while i < chars.len() {
+ let c = chars[i];
+ match c {
+ ' ' | '\t' | '\n' | '\r' => i += 1,
+ '0'..='9' | '.' => {
+ let start = i;
+ while i < chars.len() && (chars[i].is_ascii_digit() || chars[i] == '.') {
+ i += 1;
+ }
+ let text: String = chars[start..i].iter().collect();
+ let number = text
+ .parse::<f64>()
+ .map_err(|_| EvalError(format!("bad number `{text}`")))?;
+ tokens.push(Token::Number(number));
+ }
+ 'a'..='z' | 'A'..='Z' | '_' => {
+ let start = i;
+ while i < chars.len() && (chars[i].is_ascii_alphanumeric() || chars[i] == '_') {
+ i += 1;
+ }
+ tokens.push(Token::Ident(chars[start..i].iter().collect()));
+ }
+ '+' => {
+ tokens.push(Token::Plus);
+ i += 1;
+ }
+ '-' => {
+ tokens.push(Token::Minus);
+ i += 1;
+ }
+ '*' => {
+ tokens.push(Token::Star);
+ i += 1;
+ }
+ '/' => {
+ tokens.push(Token::Slash);
+ i += 1;
+ }
+ '(' => {
+ tokens.push(Token::LParen);
+ i += 1;
+ }
+ ')' => {
+ tokens.push(Token::RParen);
+ i += 1;
+ }
+ ',' => {
+ tokens.push(Token::Comma);
+ i += 1;
+ }
+ '<' | '>' | '=' | '!' => {
+ let next = chars.get(i + 1).copied();
+ let (op, width) = match (c, next) {
+ ('<', Some('=')) => (Op::Le, 2),
+ ('>', Some('=')) => (Op::Ge, 2),
+ ('=', Some('=')) => (Op::Eq, 2),
+ ('!', Some('=')) => (Op::Ne, 2),
+ ('<', _) => (Op::Lt, 1),
+ ('>', _) => (Op::Gt, 1),
+ _ => return Err(EvalError(format!("unexpected `{c}`"))),
+ };
+ tokens.push(Token::Op(op));
+ i += width;
+ }
+ _ => return Err(EvalError(format!("unexpected `{c}`"))),
+ }
+ }
+ Ok(tokens)
+}
+
+struct Parser {
+ tokens: Vec<Token>,
+ at: usize,
+}
+
+impl Parser {
+ fn peek(&self) -> Option<&Token> {
+ self.tokens.get(self.at)
+ }
+
+ fn next(&mut self) -> Option<Token> {
+ let token = self.tokens.get(self.at).cloned();
+ self.at += 1;
+ token
+ }
+
+ fn expect(&mut self, token: Token) -> Result<(), EvalError> {
+ match self.next() {
+ Some(found) if found == token => Ok(()),
+ Some(found) => Err(EvalError(format!("expected {token:?}, found {found:?}"))),
+ None => Err(EvalError(format!("expected {token:?}, found the end"))),
+ }
+ }
+
+ fn comparison(&mut self) -> Result<Expr, EvalError> {
+ let left = self.sum()?;
+ if let Some(Token::Op(op)) = self.peek().cloned() {
+ self.next();
+ let right = self.sum()?;
+ return Ok(Expr::Binary(op, Box::new(left), Box::new(right)));
+ }
+ Ok(left)
+ }
+
+ fn sum(&mut self) -> Result<Expr, EvalError> {
+ let mut left = self.term()?;
+ loop {
+ let op = match self.peek() {
+ Some(Token::Plus) => Op::Add,
+ Some(Token::Minus) => Op::Sub,
+ _ => return Ok(left),
+ };
+ self.next();
+ let right = self.term()?;
+ left = Expr::Binary(op, Box::new(left), Box::new(right));
+ }
+ }
+
+ fn term(&mut self) -> Result<Expr, EvalError> {
+ let mut left = self.unary()?;
+ loop {
+ let op = match self.peek() {
+ Some(Token::Star) => Op::Mul,
+ Some(Token::Slash) => Op::Div,
+ _ => return Ok(left),
+ };
+ self.next();
+ let right = self.unary()?;
+ left = Expr::Binary(op, Box::new(left), Box::new(right));
+ }
+ }
+
+ fn unary(&mut self) -> Result<Expr, EvalError> {
+ if let Some(Token::Minus) = self.peek() {
+ self.next();
+ return Ok(Expr::Neg(Box::new(self.unary()?)));
+ }
+ self.atom()
+ }
+
+ fn atom(&mut self) -> Result<Expr, EvalError> {
+ match self.next() {
+ Some(Token::Number(n)) => Ok(Expr::Number(n)),
+ Some(Token::Ident(name)) => {
+ if let Some(Token::LParen) = self.peek() {
+ self.next();
+ let mut args = Vec::new();
+ if let Some(Token::RParen) = self.peek() {
+ self.next();
+ } else {
+ loop {
+ args.push(self.comparison()?);
+ match self.next() {
+ Some(Token::Comma) => continue,
+ Some(Token::RParen) => break,
+ other => {
+ return Err(EvalError(format!(
+ "expected `,` or `)` in call to {name}, found {other:?}"
+ )));
+ }
+ }
+ }
+ }
+ let Some((_, arity)) = FUNCTIONS.iter().find(|(f, _)| *f == name) else {
+ return Err(EvalError(format!("unknown function `{name}`")));
+ };
+ if args.len() != *arity {
+ return Err(EvalError(format!(
+ "{name} takes {arity} argument(s), given {}",
+ args.len()
+ )));
+ }
+ Ok(Expr::Call(name, args))
+ } else {
+ Ok(Expr::Name(name))
+ }
+ }
+ Some(Token::LParen) => {
+ let inner = self.comparison()?;
+ self.expect(Token::RParen)?;
+ Ok(inner)
+ }
+ Some(other) => Err(EvalError(format!("unexpected {other:?}"))),
+ None => Err(EvalError("unexpected end of expression".to_owned())),
+ }
+ }
+}
+
+impl Expr {
+ /// Parses one expression.
+ pub fn parse(source: &str) -> Result<Expr, EvalError> {
+ let mut parser = Parser {
+ tokens: tokenize(source)?,
+ at: 0,
+ };
+ let expr = parser.comparison()?;
+ if parser.at != parser.tokens.len() {
+ return Err(EvalError(format!("trailing input in `{source}`")));
+ }
+ Ok(expr)
+ }
+
+ /// Every name the expression reads, so a manifest can be checked for
+ /// references to parameters it does not declare.
+ pub fn names(&self, into: &mut Vec<String>) {
+ match self {
+ Expr::Number(_) => {}
+ Expr::Name(name) => into.push(name.clone()),
+ Expr::Neg(inner) => inner.names(into),
+ Expr::Binary(_, left, right) => {
+ left.names(into);
+ right.names(into);
+ }
+ Expr::Call(_, args) => {
+ for arg in args {
+ arg.names(into);
+ }
+ }
+ }
+ }
+
+ /// Evaluates against `env`, the values every name resolves to.
+ pub fn eval(&self, env: &BTreeMap<String, Value>) -> Result<Value, EvalError> {
+ match self {
+ Expr::Number(n) => Ok(Value::Float(*n)),
+ Expr::Name(name) => env
+ .get(name)
+ .cloned()
+ .ok_or_else(|| EvalError(format!("unknown name `{name}`"))),
+ Expr::Neg(inner) => match inner.eval(env)? {
+ Value::Int(n) => Ok(Value::Int(-n)),
+ Value::Float(x) => Ok(Value::Float(-x)),
+ Value::Text(_) => Err(EvalError("cannot negate text".to_owned())),
+ },
+ Expr::Binary(op, left, right) => {
+ let left = left.eval(env)?;
+ let right = right.eval(env)?;
+ binary(*op, &left, &right)
+ }
+ Expr::Call(name, args) => {
+ let values = args
+ .iter()
+ .map(|arg| arg.eval(env))
+ .collect::<Result<Vec<_>, _>>()?;
+ call(name, &values)
+ }
+ }
+ }
+}
+
+fn binary(op: Op, left: &Value, right: &Value) -> Result<Value, EvalError> {
+ if let (Value::Int(a), Value::Int(b)) = (left, right) {
+ let (a, b) = (*a, *b);
+ return Ok(match op {
+ Op::Add => Value::Int(a + b),
+ Op::Sub => Value::Int(a - b),
+ Op::Mul => Value::Int(a * b),
+ Op::Div => Value::Float(a as f64 / b as f64),
+ Op::Lt => Value::Int(i64::from(a < b)),
+ Op::Gt => Value::Int(i64::from(a > b)),
+ Op::Le => Value::Int(i64::from(a <= b)),
+ Op::Ge => Value::Int(i64::from(a >= b)),
+ Op::Eq => Value::Int(i64::from(a == b)),
+ Op::Ne => Value::Int(i64::from(a != b)),
+ });
+ }
+ let a = left.as_f64("operator")?;
+ let b = right.as_f64("operator")?;
+ Ok(match op {
+ Op::Add => Value::Float(a + b),
+ Op::Sub => Value::Float(a - b),
+ Op::Mul => Value::Float(a * b),
+ Op::Div => Value::Float(a / b),
+ Op::Lt => Value::Int(i64::from(a < b)),
+ Op::Gt => Value::Int(i64::from(a > b)),
+ Op::Le => Value::Int(i64::from(a <= b)),
+ Op::Ge => Value::Int(i64::from(a >= b)),
+ Op::Eq => Value::Int(i64::from(a == b)),
+ Op::Ne => Value::Int(i64::from(a != b)),
+ })
+}
+
+fn truthy(value: &Value) -> Result<bool, EvalError> {
+ Ok(value.as_f64("if")? != 0.0)
+}
+
+fn call(name: &str, args: &[Value]) -> Result<Value, EvalError> {
+ let num = |i: usize| args[i].as_f64(name);
+ Ok(match name {
+ "if" => {
+ if truthy(&args[0])? {
+ args[1].clone()
+ } else {
+ args[2].clone()
+ }
+ }
+ "clamp" => match (&args[0], &args[1], &args[2]) {
+ (Value::Int(x), Value::Int(lo), Value::Int(hi)) => Value::Int((*x).clamp(*lo, *hi)),
+ _ => Value::Float(num(0)?.clamp(num(1)?, num(2)?)),
+ },
+ "min" => match (&args[0], &args[1]) {
+ (Value::Int(a), Value::Int(b)) => Value::Int((*a).min(*b)),
+ _ => Value::Float(num(0)?.min(num(1)?)),
+ },
+ "max" => match (&args[0], &args[1]) {
+ (Value::Int(a), Value::Int(b)) => Value::Int((*a).max(*b)),
+ _ => Value::Float(num(0)?.max(num(1)?)),
+ },
+ "abs" => match &args[0] {
+ Value::Int(n) => Value::Int(n.abs()),
+ _ => Value::Float(num(0)?.abs()),
+ },
+ "floor" => Value::Int(num(0)?.floor() as i64),
+ "ceil" => Value::Int(num(0)?.ceil() as i64),
+ // Nearest integer, halves away from zero.
+ "round" => Value::Int(num(0)?.round() as i64),
+ "sqrt" => Value::Float(num(0)?.sqrt()),
+ "pow" => Value::Float(num(0)?.powf(num(1)?)),
+ "fixed" => {
+ let digits = num(1)?;
+ if digits < 0.0 || digits.fract() != 0.0 || digits > 20.0 {
+ return Err(EvalError(format!("fixed: {digits} is not a digit count")));
+ }
+ Value::Text(fixed(num(0)?, digits as usize))
+ }
+ _ => return Err(EvalError(format!("unknown function `{name}`"))),
+ })
+}
+
+/// `value` with exactly `digits` decimals. Negative zero prints unsigned, so
+/// a slider at 0 never emits `-0.00`.
+pub fn fixed(value: f64, digits: usize) -> String {
+ let value = if value == 0.0 { 0.0 } else { value };
+ format!("{value:.digits$}")
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ fn eval(source: &str, vars: &[(&str, Value)]) -> Value {
+ let env: BTreeMap<String, Value> = vars
+ .iter()
+ .map(|(k, v)| ((*k).to_owned(), v.clone()))
+ .collect();
+ Expr::parse(source)
+ .expect("parses")
+ .eval(&env)
+ .expect("evaluates")
+ }
+
+ #[test]
+ fn arithmetic_keeps_precedence() {
+ assert_eq!(eval("1 + 2 * 3", &[]), Value::Float(7.0));
+ assert_eq!(eval("(1 + 2) * 3", &[]), Value::Float(9.0));
+ assert_eq!(eval("-2 * -3", &[]), Value::Float(6.0));
+ assert_eq!(eval("10 / 4", &[]), Value::Float(2.5));
+ }
+
+ #[test]
+ fn round_yields_integers_and_integer_arithmetic_stays_integer() {
+ assert_eq!(eval("round(12.4)", &[]), Value::Int(12));
+ assert_eq!(eval("round(2.5)", &[]), Value::Int(3));
+ // A literal is a real number, so mixing one in yields a real.
+ assert_eq!(eval("round(12) * 2", &[]), Value::Float(24.0));
+ assert_eq!(eval("round(12) * round(2)", &[]), Value::Int(24));
+ assert_eq!(eval("round(12) / 2", &[]), Value::Float(6.0));
+ assert_eq!(eval("round(13 * 1.3)", &[]), Value::Int(17));
+ assert_eq!(eval("round(12.4)", &[]).to_string(), "12");
+ }
+
+ #[test]
+ fn fixed_formats_like_the_chains_always_have() {
+ assert_eq!(eval("fixed(0.5, 2)", &[]).to_string(), "0.50");
+ assert_eq!(eval("fixed(-0.0, 3)", &[]).to_string(), "0.000");
+ assert_eq!(
+ eval("fixed(48000 * pow(2, 12 / 12), 6)", &[]).to_string(),
+ "96000.000000"
+ );
+ assert_eq!(eval("fixed(-0.55 * 0.05, 3)", &[]).to_string(), "-0.028");
+ }
+
+ #[test]
+ fn conditionals_and_comparisons() {
+ let vars = [("pitch", Value::Float(0.0)), ("s", Value::Float(0.65))];
+ assert_eq!(
+ eval("if(pitch > 0, pitch, 1.2 + 3.8 * s)", &vars),
+ Value::Float(1.2 + 3.8 * 0.65)
+ );
+ assert_eq!(eval("if(3 >= 3, 1, 2)", &[]), Value::Float(1.0));
+ assert_eq!(eval("clamp(150, 0, 100) / 100", &[]), Value::Float(1.0));
+ assert_eq!(eval("max(round(1.6), 2)", &[]), Value::Float(2.0));
+ assert_eq!(eval("max(round(1.6), round(2))", &[]), Value::Int(2));
+ }
+
+ #[test]
+ fn names_are_reported_and_unknown_ones_fail() {
+ let expr = Expr::parse("a + max(b, 2) * index").expect("parses");
+ let mut names = Vec::new();
+ expr.names(&mut names);
+ assert_eq!(names, ["a", "b", "index"]);
+ assert!(expr.eval(&BTreeMap::new()).is_err());
+ }
+
+ #[test]
+ fn bad_input_is_an_error_not_a_panic() {
+ assert!(Expr::parse("1 +").is_err());
+ assert!(Expr::parse("foo(1)").is_err());
+ assert!(Expr::parse("round(1, 2)").is_err());
+ assert!(Expr::parse("1 & 2").is_err());
+ assert!(Expr::parse("(1").is_err());
+ assert!(Expr::parse("1 2").is_err());
+ }
+}
diff --git a/engine/crates/concat-effects/src/lib.rs b/engine/crates/concat-effects/src/lib.rs
new file mode 100644
index 00000000..dbec4bdf
--- /dev/null
+++ b/engine/crates/concat-effects/src/lib.rs
@@ -0,0 +1,256 @@
+// SPDX-License-Identifier: AGPL-3.0-or-later
+// SPDX-FileCopyrightText: 2026 Jareer and Concat contributors
+
+//! Effect packages.
+//!
+//! An effect is a folder: `effect.toml` declares its id, its parameters and
+//! one backend, and `fixtures.toml` pins what it produces. The built-in
+//! packages under `packages/` are compiled into the binary; user packages
+//! load from a directory at run time. The window shows the parameters, the
+//! engine runs the backend, and nothing in Rust names an individual effect.
+//!
+//! Two backends exist. `[ffmpeg]` is a filter-chain template with
+//! `{expression}` slots ([`template`], [`expr`]), run inside the decoder's
+//! filtergraph where the chains have always run. `[wgsl]` is a shader,
+//! declared here and run by the compositor.
+//!
+//! The document is untouched by any of this: a clip still stores
+//! `{ id, params, enabled }`, and an id the catalogue does not know is
+//! skipped at render time.
+
+pub mod catalogue;
+pub mod expr;
+pub mod manifest;
+pub mod template;
+
+mod builtins {
+ include!(concat!(env!("OUT_DIR"), "/builtins.rs"));
+}
+
+pub use catalogue::{At, Catalogue, Fixture, Package};
+pub use manifest::{Kind, Manifest, Param, ParamType};
+
+/// Why a package could not be loaded.
+#[derive(thiserror::Error, Debug)]
+pub enum Error {
+ /// The manifest, a template or a fixture is wrong.
+ #[error("{id}: {message}")]
+ Invalid {
+ /// The package's id, or `?` when the manifest did not parse far
+ /// enough to have one.
+ id: String,
+ /// What is wrong.
+ message: String,
+ },
+ /// A package file could not be read.
+ #[error("{path}: {message}")]
+ Io {
+ /// The file.
+ path: std::path::PathBuf,
+ /// The system's reason.
+ message: String,
+ },
+}
+
+#[cfg(test)]
+mod tests {
+ use std::collections::BTreeMap;
+
+ use concat_project::model::AppliedFilter;
+
+ use super::*;
+
+ fn applied(id: &str, params: &[(&str, f64)]) -> AppliedFilter {
+ AppliedFilter {
+ id: id.to_owned(),
+ params: params
+ .iter()
+ .map(|(key, value)| ((*key).to_owned(), *value))
+ .collect(),
+ enabled: true,
+ }
+ }
+
+ #[test]
+ fn every_built_in_package_loads_and_its_fixtures_pass() {
+ let catalogue = Catalogue::builtin();
+ assert!(catalogue.packages().count() >= 28);
+ let failures: Vec<String> = catalogue
+ .packages()
+ .flat_map(|package| package.check_fixtures())
+ .collect();
+ assert!(failures.is_empty(), "\n{}", failures.join("\n"));
+ }
+
+ #[test]
+ fn every_ffmpeg_package_pins_its_default_and_every_slider_bound() {
+ // A package without fixtures is a package nobody has looked at.
+ let mut gaps = Vec::new();
+ for package in Catalogue::builtin().packages() {
+ if package.manifest.ffmpeg.is_none() {
+ continue;
+ }
+ let has = |at: At| {
+ package
+ .fixtures
+ .iter()
+ .any(|case| case.at == at && case.params.is_empty())
+ };
+ if !has(At::Default) {
+ gaps.push(format!("{}: no default case", package.id()));
+ }
+ if !package.manifest.params.is_empty() {
+ if !has(At::Min) {
+ gaps.push(format!("{}: no min case", package.id()));
+ }
+ if !has(At::Max) {
+ gaps.push(format!("{}: no max case", package.id()));
+ }
+ }
+ }
+ assert!(gaps.is_empty(), "\n{}", gaps.join("\n"));
+ }
+
+ #[test]
+ fn built_in_ids_are_namespaced_and_bare_aliases_still_resolve() {
+ let catalogue = Catalogue::builtin();
+ for package in catalogue.packages() {
+ assert!(package.id().starts_with("concat."), "{}", package.id());
+ }
+ assert_eq!(catalogue.get("glow").map(Package::id), Some("concat.glow"));
+ assert_eq!(
+ catalogue.get("concat.glow").map(Package::id),
+ Some("concat.glow")
+ );
+ assert!(catalogue.get("from-the-future").is_none());
+ }
+
+ #[test]
+ fn stacked_effects_join_with_commas_in_applied_order() {
+ let catalogue = Catalogue::builtin();
+ assert_eq!(
+ catalogue.video_chain(&[applied("gaussian-blur", &[]), applied("black-white", &[])]),
+ "gblur=sigma=10.0,hue=s=0"
+ );
+ assert_eq!(
+ catalogue.video_chain(&[applied("black-white", &[]), applied("gaussian-blur", &[])]),
+ "hue=s=0,gblur=sigma=10.0"
+ );
+ }
+
+ #[test]
+ fn a_bypassed_entry_contributes_nothing_and_consumes_no_index() {
+ let catalogue = Catalogue::builtin();
+ let mut sepia = applied("sepia", &[]);
+ sepia.enabled = false;
+ assert_eq!(
+ catalogue.video_chain(&[
+ applied("invert", &[]),
+ sepia.clone(),
+ applied("black-white", &[])
+ ]),
+ "negate,hue=s=0"
+ );
+ let skipped = catalogue.video_chain(&[sepia, applied("mirror", &[])]);
+ assert!(skipped.contains("[mirl0]"), "was: {skipped}");
+ }
+
+ #[test]
+ fn stacking_one_labelled_effect_twice_keeps_its_graph_labels_distinct() {
+ let chain = Catalogue::builtin().video_chain(&[applied("glow", &[]), applied("glow", &[])]);
+ assert!(chain.contains("[glowa0]"), "was: {chain}");
+ assert!(chain.contains("[glowa1]"), "was: {chain}");
+ }
+
+ #[test]
+ fn unknown_ids_and_wrong_kinds_are_skipped() {
+ let catalogue = Catalogue::builtin();
+ assert_eq!(
+ catalogue.video_chain(&[applied("from-the-future", &[]), applied("invert", &[])]),
+ "negate"
+ );
+ // An audio filter in the video list is not a video effect.
+ assert_eq!(
+ catalogue.video_chain(&[applied("bass", &[]), applied("invert", &[])]),
+ "negate"
+ );
+ assert_eq!(
+ catalogue.audio_chain(&[applied("invert", &[]), applied("echo", &[])]),
+ "aecho=0.8:0.85:250:0.40"
+ );
+ assert_eq!(catalogue.video_chain(&[]), "");
+ }
+
+ #[test]
+ fn stray_parameter_keys_are_dropped_and_missing_ones_default() {
+ let catalogue = Catalogue::builtin();
+ assert_eq!(
+ catalogue.video_chain(&[applied("sharpen", &[("amount", 2.0), ("bogus", 99.0)])]),
+ "unsharp=5:5:2.00:5:5:0"
+ );
+ assert_eq!(
+ catalogue.video_chain(&[applied("shake", &[("amount", 20.0)])]),
+ "crop=iw-40:ih-40:20+20*sin(t*13):20+20*cos(t*17)"
+ );
+ assert_eq!(
+ catalogue.audio_chain(&[applied("echo", &[("delay", 0.5)])]),
+ "aecho=0.8:0.85:500:0.40"
+ );
+ }
+
+ #[test]
+ fn a_user_package_loads_from_a_directory_and_a_broken_one_is_reported() {
+ let dir = std::env::temp_dir().join(format!("concat-effects-{}", std::process::id()));
+ let _ = std::fs::remove_dir_all(&dir);
+ let good = dir.join("alice.tint");
+ std::fs::create_dir_all(&good).expect("mkdir");
+ std::fs::write(
+ good.join("effect.toml"),
+ r#"
+ [effect]
+ id = "alice.tint"
+ name = "Tint"
+ kind = "effect"
+ [[param]]
+ key = "hue"
+ label = "Hue"
+ max = 360
+ default = 90
+ [ffmpeg]
+ chain = "hue=h={round(hue)}"
+ "#,
+ )
+ .expect("write");
+ let bad = dir.join("bob.broken");
+ std::fs::create_dir_all(&bad).expect("mkdir");
+ std::fs::write(bad.join("effect.toml"), "[effect]\nid = \"bob.broken\"\n").expect("write");
+
+ let mut catalogue = Catalogue::new();
+ let errors = catalogue.load_dir(&dir);
+ assert_eq!(errors.len(), 1, "{errors:?}");
+ assert!(
+ errors[0].to_string().contains("bob.broken") || errors[0].to_string().contains("?")
+ );
+ assert_eq!(
+ catalogue.video_chain(&[applied("alice.tint", &[("hue", 45.0)])]),
+ "hue=h=45"
+ );
+ let _ = std::fs::remove_dir_all(&dir);
+ }
+
+ #[test]
+ fn a_duplicate_id_is_refused() {
+ let mut catalogue = Catalogue::new();
+ let package = || {
+ Package::from_sources(
+ "[effect]\nid = \"a.b\"\nname = \"B\"\nkind = \"effect\"\n[ffmpeg]\nchain = \"negate\"\n",
+ None,
+ )
+ .expect("loads")
+ };
+ catalogue.add(package()).expect("first");
+ assert!(catalogue.add(package()).is_err());
+ assert_eq!(catalogue.video_chain(&[applied("a.b", &[])]), "negate");
+ let _ = BTreeMap::<String, f64>::new();
+ }
+}
diff --git a/engine/crates/concat-effects/src/manifest.rs b/engine/crates/concat-effects/src/manifest.rs
new file mode 100644
index 00000000..5050814a
--- /dev/null
+++ b/engine/crates/concat-effects/src/manifest.rs
@@ -0,0 +1,384 @@
+// SPDX-License-Identifier: AGPL-3.0-or-later
+// SPDX-FileCopyrightText: 2026 Jareer and Concat contributors
+
+//! The manifest: what a package declares about itself.
+//!
+//! `effect.toml` names the package, lists its parameters, and carries one
+//! backend - an FFmpeg chain template, or a WGSL shader. The parameters are
+//! the whole of what the window shows a user; the backend is the whole of
+//! what the engine runs. A manifest that declares a parameter its backend
+//! never reads, or reads one it never declares, is rejected at load.
+
+use serde::Deserialize;
+
+use crate::Error;
+
+/// A parsed `effect.toml`.
+#[derive(Deserialize, Clone, PartialEq, Debug)]
+#[serde(deny_unknown_fields)]
+pub struct Manifest {
+ /// Identity and placement.
+ pub effect: Meta,
+ /// The knobs, in the order the inspector shows them.
+ #[serde(default, rename = "param")]
+ pub params: Vec<Param>,
+ /// The FFmpeg backend, when the package is a filter chain.
+ #[serde(default)]
+ pub ffmpeg: Option<Ffmpeg>,
+ /// The WGSL backend, when the package is a shader.
+ #[serde(default)]
+ pub wgsl: Option<Wgsl>,
+}
+
+/// The `[effect]` table.
+#[derive(Deserialize, Clone, PartialEq, Debug)]
+#[serde(deny_unknown_fields)]
+pub struct Meta {
+ /// Namespaced, `author.name`, lower-case. Written into project files,
+ /// so it is forever.
+ pub id: String,
+ /// What the catalogue card says.
+ pub name: String,
+ /// Which catalogue the package belongs to.
+ pub kind: Kind,
+ /// The shelf the card sits on, e.g. "Blur". Free text.
+ #[serde(default)]
+ pub category: String,
+ /// The package's own version, bumped when its output changes.
+ #[serde(default = "one")]
+ pub version: u32,
+ /// The parameter the simple view shows as the one slider.
+ #[serde(default)]
+ pub intensity: Option<String>,
+ /// Earlier ids this package answers to, so projects that stored them
+ /// keep rendering.
+ #[serde(default)]
+ pub aliases: Vec<String>,
+ /// Sort key within the category; ties break on name.
+ #[serde(default)]
+ pub order: i32,
+ /// A sentence for the tooltip.
+ #[serde(default)]
+ pub description: String,
+}
+
+fn one() -> u32 {
+ 1
+}
+
+/// Which catalogue a package belongs to.
+#[derive(Deserialize, Clone, Copy, PartialEq, Eq, Hash, Debug)]
+#[serde(rename_all = "lowercase")]
+pub enum Kind {
+ /// A video effect: image in, image out.
+ Effect,
+ /// An audio filter: sound in, sound out.
+ Filter,
+ /// A transition: two images and a progress, one image out.
+ Transition,
+ /// A generator: no input, an image out.
+ Generator,
+}
+
+/// One `[[param]]`.
+#[derive(Deserialize, Clone, PartialEq, Debug)]
+#[serde(deny_unknown_fields)]
+pub struct Param {
+ /// The name the backend reads and the document stores.
+ pub key: String,
+ /// What the control is labelled.
+ pub label: String,
+ /// What kind of control, and how the number is interpreted.
+ #[serde(default, rename = "type")]
+ pub kind: ParamType,
+ /// Lowest value.
+ #[serde(default)]
+ pub min: f64,
+ /// Highest value.
+ #[serde(default = "unit")]
+ pub max: f64,
+ /// The value an untouched control means.
+ #[serde(default)]
+ pub default: f64,
+ /// Slider increment; 0 means continuous.
+ #[serde(default)]
+ pub step: f64,
+ /// Displayed after the number: "%", "dB", "K", "s".
+ #[serde(default)]
+ pub unit: String,
+ /// Whether the control can carry keyframes.
+ #[serde(default)]
+ pub animate: bool,
+ /// For `enum`: the values the document may hold.
+ #[serde(default)]
+ pub values: Vec<f64>,
+ /// For `enum`: what each value is called, in `values` order.
+ #[serde(default)]
+ pub labels: Vec<String>,
+}
+
+fn unit() -> f64 {
+ 1.0
+}
+
+/// The kinds of parameter. The document stores every kind as a number.
+#[derive(Deserialize, Clone, Copy, PartialEq, Eq, Debug, Default)]
+#[serde(rename_all = "lowercase")]
+pub enum ParamType {
+ /// A real number on a slider.
+ #[default]
+ Float,
+ /// A whole number on a stepper.
+ Int,
+ /// A toggle, stored as 0 or 1.
+ Bool,
+ /// One of `values`, chosen from a list.
+ Enum,
+ /// A colour, stored as packed RGBA.
+ Color,
+ /// A position on the picture, stored as two keys `<key>.x` and `<key>.y`
+ /// in the 0..1 square.
+ Point,
+}
+
+/// The `[ffmpeg]` table: a filter chain template.
+#[derive(Deserialize, Clone, PartialEq, Debug)]
+#[serde(deny_unknown_fields)]
+pub struct Ffmpeg {
+ /// Named intermediate values, `"name = expression"`, evaluated in order
+ /// before the chain. Each may read the parameters and the names before
+ /// it.
+ #[serde(default, rename = "let")]
+ pub lets: Vec<String>,
+ /// The chain template: FFmpeg filter syntax with `{expression}` slots.
+ pub chain: String,
+}
+
+/// The `[wgsl]` table: a shader.
+#[derive(Deserialize, Clone, PartialEq, Debug)]
+#[serde(deny_unknown_fields)]
+pub struct Wgsl {
+ /// The shader file, beside the manifest.
+ pub entry: String,
+ /// Render passes, in order. Empty means one pass to the output.
+ #[serde(default, rename = "pass")]
+ pub passes: Vec<Pass>,
+}
+
+/// One render pass of a WGSL package.
+#[derive(Deserialize, Clone, PartialEq, Debug)]
+#[serde(deny_unknown_fields)]
+pub struct Pass {
+ /// The texture the pass writes, readable by later passes. Absent for
+ /// the final pass, which writes the output.
+ #[serde(default)]
+ pub target: Option<String>,
+ /// The target's size as an expression over `WIDTH` and `HEIGHT`; absent
+ /// means the output size.
+ #[serde(default)]
+ pub size: Option<String>,
+}
+
+fn is_ident(text: &str) -> bool {
+ let mut chars = text.chars();
+ matches!(chars.next(), Some(c) if c.is_ascii_lowercase() || c == '_')
+ && chars.all(|c| c.is_ascii_lowercase() || c.is_ascii_digit() || c == '_')
+}
+
+fn is_id_segment(text: &str) -> bool {
+ !text.is_empty()
+ && text
+ .chars()
+ .all(|c| c.is_ascii_lowercase() || c.is_ascii_digit() || c == '-')
+}
+
+impl Manifest {
+ /// Parses and validates `source`.
+ pub fn parse(source: &str) -> Result<Manifest, Error> {
+ let manifest: Manifest = toml::from_str(source).map_err(|error| Error::Invalid {
+ id: "?".to_owned(),
+ message: error.to_string(),
+ })?;
+ manifest.validate()?;
+ Ok(manifest)
+ }
+
+ fn invalid(&self, message: impl Into<String>) -> Error {
+ Error::Invalid {
+ id: self.effect.id.clone(),
+ message: message.into(),
+ }
+ }
+
+ fn validate(&self) -> Result<(), Error> {
+ let id = &self.effect.id;
+ let namespaced = id
+ .split_once('.')
+ .is_some_and(|(author, name)| is_id_segment(author) && is_id_segment(name));
+ if !namespaced {
+ return Err(
+ self.invalid("id must be `author.name`, lower-case letters, digits and hyphens")
+ );
+ }
+ if self.effect.name.trim().is_empty() {
+ return Err(self.invalid("name is empty"));
+ }
+ for alias in &self.effect.aliases {
+ if !is_id_segment(alias)
+ && !alias
+ .split_once('.')
+ .is_some_and(|(a, n)| is_id_segment(a) && is_id_segment(n))
+ {
+ return Err(self.invalid(format!("alias `{alias}` is not an id")));
+ }
+ }
+ let mut seen = std::collections::HashSet::new();
+ for param in &self.params {
+ if !is_ident(&param.key) {
+ return Err(self.invalid(format!(
+ "parameter key `{}` must be lower-case letters, digits and underscores",
+ param.key
+ )));
+ }
+ if param.key == "index" {
+ return Err(self.invalid("`index` is reserved"));
+ }
+ if !seen.insert(param.key.as_str()) {
+ return Err(self.invalid(format!("parameter `{}` is declared twice", param.key)));
+ }
+ if param.label.trim().is_empty() {
+ return Err(self.invalid(format!("parameter `{}` has no label", param.key)));
+ }
+ if param.min > param.max {
+ return Err(self.invalid(format!("parameter `{}`: min is above max", param.key)));
+ }
+ if param.default < param.min || param.default > param.max {
+ return Err(self.invalid(format!(
+ "parameter `{}`: default {} is outside {}..{}",
+ param.key, param.default, param.min, param.max
+ )));
+ }
+ if param.kind == ParamType::Enum {
+ if param.values.is_empty() {
+ return Err(self.invalid(format!("enum `{}` lists no values", param.key)));
+ }
+ if param.values.len() != param.labels.len() {
+ return Err(self.invalid(format!(
+ "enum `{}` has {} values and {} labels",
+ param.key,
+ param.values.len(),
+ param.labels.len()
+ )));
+ }
+ }
+ }
+ if let Some(intensity) = &self.effect.intensity
+ && !self.params.iter().any(|param| &param.key == intensity)
+ {
+ return Err(self.invalid(format!(
+ "intensity names `{intensity}`, which is not a parameter"
+ )));
+ }
+ match (&self.ffmpeg, &self.wgsl) {
+ (None, None) => {
+ return Err(self.invalid("no backend: add an [ffmpeg] or a [wgsl] table"));
+ }
+ (Some(_), Some(_)) => {
+ return Err(self.invalid("two backends: keep one of [ffmpeg] and [wgsl]"));
+ }
+ _ => {}
+ }
+ if self.ffmpeg.is_some() && matches!(self.effect.kind, Kind::Transition | Kind::Generator) {
+ return Err(self.invalid("an [ffmpeg] package must be an effect or a filter"));
+ }
+ if self.wgsl.is_some() && self.effect.kind == Kind::Filter {
+ return Err(self.invalid("a [wgsl] package cannot be an audio filter"));
+ }
+ Ok(())
+ }
+
+ /// The declared parameter with this key.
+ pub fn param(&self, key: &str) -> Option<&Param> {
+ self.params.iter().find(|param| param.key == key)
+ }
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ const GOOD: &str = r#"
+ [effect]
+ id = "concat.blur"
+ name = "Blur"
+ kind = "effect"
+ category = "Blur"
+ intensity = "radius"
+ aliases = ["blur"]
+
+ [[param]]
+ key = "radius"
+ label = "Radius"
+ min = 1
+ max = 50
+ default = 10
+ unit = "px"
+
+ [ffmpeg]
+ chain = "gblur=sigma={fixed(radius, 1)}"
+ "#;
+
+ #[test]
+ fn a_good_manifest_parses() {
+ let manifest = Manifest::parse(GOOD).expect("parses");
+ assert_eq!(manifest.effect.id, "concat.blur");
+ assert_eq!(manifest.effect.version, 1);
+ assert_eq!(manifest.params[0].kind, ParamType::Float);
+ assert_eq!(manifest.params[0].step, 0.0);
+ assert!(manifest.ffmpeg.is_some());
+ }
+
+ fn rejects(source: &str, needle: &str) {
+ let error = Manifest::parse(source).expect_err("rejected").to_string();
+ assert!(error.contains(needle), "{error}");
+ }
+
+ #[test]
+ fn bad_manifests_are_rejected_with_a_reason() {
+ rejects(&GOOD.replace("concat.blur", "blur"), "author.name");
+ rejects(&GOOD.replace("concat.blur", "Concat.Blur"), "author.name");
+ rejects(
+ &GOOD.replace("intensity = \"radius\"", "intensity = \"sigma\""),
+ "intensity",
+ );
+ rejects(&GOOD.replace("default = 10", "default = 99"), "outside");
+ rejects(
+ &GOOD.replace(
+ "[ffmpeg]\n chain = \"gblur=sigma={fixed(radius, 1)}\"",
+ "",
+ ),
+ "no backend",
+ );
+ rejects(
+ &GOOD.replace("key = \"radius\"", "key = \"index\""),
+ "reserved",
+ );
+ rejects(
+ &GOOD.replace("unit = \"px\"", "units = \"px\""),
+ "unknown field",
+ );
+ rejects(
+ &GOOD.replace("kind = \"effect\"", "kind = \"transition\""),
+ "effect or a filter",
+ );
+ }
+
+ #[test]
+ fn enum_parameters_pair_values_with_labels() {
+ let source = GOOD.replace(
+ "unit = \"px\"",
+ "type = \"enum\"\n values = [1, 2]\n labels = [\"One\"]",
+ );
+ rejects(&source, "labels");
+ }
+}
diff --git a/engine/crates/concat-effects/src/template.rs b/engine/crates/concat-effects/src/template.rs
new file mode 100644
index 00000000..e9256ff6
--- /dev/null
+++ b/engine/crates/concat-effects/src/template.rs
@@ -0,0 +1,121 @@
+// SPDX-License-Identifier: AGPL-3.0-or-later
+// SPDX-FileCopyrightText: 2026 Jareer and Concat contributors
+
+//! Chain templates: literal text with `{expression}` slots.
+//!
+//! `{{` and `}}` are literal braces. Everything between a single `{` and
+//! its `}` is an expression (see [`crate::expr`]) whose value is substituted
+//! as text. The output is an FFmpeg filter fragment, so the literal parts
+//! are FFmpeg syntax and the slots are the numbers a parameter decides.
+
+use std::collections::BTreeMap;
+
+use crate::expr::{EvalError, Expr, Value};
+
+/// A parsed template.
+#[derive(Clone, PartialEq, Debug)]
+pub struct Template {
+ parts: Vec<Part>,
+}
+
+#[derive(Clone, PartialEq, Debug)]
+enum Part {
+ Literal(String),
+ Slot(Expr),
+}
+
+impl Template {
+ /// Parses `source`. Every slot is parsed now, so a malformed expression
+ /// fails at load rather than at render.
+ pub fn parse(source: &str) -> Result<Template, EvalError> {
+ let mut parts = Vec::new();
+ let mut literal = String::new();
+ let mut rest = source;
+ while !rest.is_empty() {
+ if let Some(after) = rest.strip_prefix("{{") {
+ literal.push('{');
+ rest = after;
+ } else if let Some(after) = rest.strip_prefix("}}") {
+ literal.push('}');
+ rest = after;
+ } else if let Some(after) = rest.strip_prefix('{') {
+ let Some(end) = after.find('}') else {
+ return Err(EvalError(format!("unclosed `{{` in `{source}`")));
+ };
+ if !literal.is_empty() {
+ parts.push(Part::Literal(std::mem::take(&mut literal)));
+ }
+ parts.push(Part::Slot(Expr::parse(&after[..end])?));
+ rest = &after[end + 1..];
+ } else if rest.starts_with('}') {
+ return Err(EvalError(format!("stray `}}` in `{source}`")));
+ } else {
+ let next = rest.find(['{', '}']).unwrap_or(rest.len());
+ literal.push_str(&rest[..next]);
+ rest = &rest[next..];
+ }
+ }
+ if !literal.is_empty() {
+ parts.push(Part::Literal(literal));
+ }
+ Ok(Template { parts })
+ }
+
+ /// Every name any slot reads.
+ pub fn names(&self, into: &mut Vec<String>) {
+ for part in &self.parts {
+ if let Part::Slot(expr) = part {
+ expr.names(into);
+ }
+ }
+ }
+
+ /// The template with every slot evaluated against `env`.
+ pub fn render(&self, env: &BTreeMap<String, Value>) -> Result<String, EvalError> {
+ let mut out = String::new();
+ for part in &self.parts {
+ match part {
+ Part::Literal(text) => out.push_str(text),
+ Part::Slot(expr) => out.push_str(&expr.eval(env)?.to_string()),
+ }
+ }
+ Ok(out)
+ }
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ fn env(vars: &[(&str, Value)]) -> BTreeMap<String, Value> {
+ vars.iter()
+ .map(|(k, v)| ((*k).to_owned(), v.clone()))
+ .collect()
+ }
+
+ #[test]
+ fn slots_substitute_and_braces_escape() {
+ let template =
+ Template::parse("gblur=sigma={fixed(radius, 1)}:x={{literal}}").expect("parses");
+ let out = template
+ .render(&env(&[("radius", Value::Float(10.0))]))
+ .expect("renders");
+ assert_eq!(out, "gblur=sigma=10.0:x={literal}");
+ }
+
+ #[test]
+ fn a_slot_may_be_used_twice() {
+ let template = Template::parse("trunc(val/{size})*{size}").expect("parses");
+ let out = template
+ .render(&env(&[("size", Value::Int(64))]))
+ .expect("renders");
+ assert_eq!(out, "trunc(val/64)*64");
+ }
+
+ #[test]
+ fn malformed_templates_fail_at_parse() {
+ assert!(Template::parse("gblur={radius").is_err());
+ assert!(Template::parse("gblur=radius}").is_err());
+ assert!(Template::parse("gblur={1 +}").is_err());
+ }
+}
diff --git a/engine/crates/concat-export/Cargo.toml b/engine/crates/concat-export/Cargo.toml
index 4807468d..54016d85 100644
--- a/engine/crates/concat-export/Cargo.toml
+++ b/engine/crates/concat-export/Cargo.toml
@@ -16,6 +16,7 @@ concat-core.workspace = true
concat-media.workspace = true
concat-render.workspace = true
concat-project = { path = "../concat-project" }
+concat-effects.workspace = true
serde = { version = "1", features = ["derive"] }
[lints]
diff --git a/engine/crates/concat-export/src/chains.rs b/engine/crates/concat-export/src/chains.rs
index fbcaed28..818c950b 100644
--- a/engine/crates/concat-export/src/chains.rs
+++ b/engine/crates/concat-export/src/chains.rs
@@ -3,1116 +3,47 @@
//! The FFmpeg filter-chain builders: video effects and audio filters.
//!
-//! Two catalogues - video effects and audio filters - and the composition
-//! that turns a clip's applied entries into one filter string. The strings
-//! are the ground truth for exported pixels and sound, and the tests at the
-//! bottom of this file pin the exact chain for every catalogue entry at its
-//! default, minimum and maximum settings, character for character. Number
-//! formatting matters as much as the maths: "0.5" and "0.50" are different
-//! bytes in a filtergraph even when they are the same sigma, so every
-//! interpolation fixes its precision on purpose.
-//!
-//! Composition: enabled entries in applied order, comma-joined, bypassed
-//! entries and unknown ids skipped, missing parameters falling back to the
-//! catalogue defaults. An empty result is the empty string - the spelling
-//! of "no chain".
-
-use std::collections::BTreeMap;
+//! The chains come from the effect catalogue (`concat-effects`): every
+//! built-in effect is a package whose manifest carries its template, and
+//! whose fixtures pin the exact string at its default, minimum and maximum
+//! settings. What this module owns is the seam the exporter and the
+//! decoder call through.
+use concat_effects::Catalogue;
use concat_project::model::AppliedFilter;
-/// One slider on a catalogue entry: its key, the range the UI allows, and
-/// the value an untouched slider means.
-struct Param {
- key: &'static str,
- // The bounds are read only by the pinning tests, which push every
- // slider to each end - dead code to a plain build.
- #[cfg_attr(not(test), allow(dead_code))]
- min: f64,
- #[cfg_attr(not(test), allow(dead_code))]
- max: f64,
- default: f64,
-}
-
-/// The resolved parameter values for one applied entry: every declared key
-/// present, either the user's number or the default.
-struct Params(BTreeMap<&'static str, f64>);
-
-impl Params {
- /// The value for a declared key. A chain function asking for a key its
- /// entry does not declare is a bug the tests catch, so this indexes.
- fn get(&self, key: &str) -> f64 {
- self.0[key]
- }
-}
-
-/// One catalogue entry: the id projects store, its sliders, and the function
-/// from resolved parameters to an FFmpeg filter fragment.
-struct Entry {
- id: &'static str,
- params: &'static [Param],
- /// Builds the fragment. `index` is the fragment's emitted position in
- /// the clip's chain: any filtergraph labels MUST embed it, or stacking
- /// the same effect twice duplicates labels and FFmpeg rejects the graph.
- chain: fn(&Params, usize) -> String,
-}
-
-/// Formats an `f64` the way JS `value.toFixed(digits)` does.
-///
-/// Both languages round the same IEEE double to decimal, so the only real
-/// divergences are exact decimal ties (JS rounds them away from zero, Rust
-/// to even - unreachable from the catalogues' slider grids) and negative
-/// zero, which JS prints unsigned and this normalises to match.
-fn fixed(value: f64, digits: usize) -> String {
- let value = if value == 0.0 { 0.0 } else { value };
- format!("{value:.digits$}")
-}
-
-/// `Math.round` for the non-negative values the catalogues produce: nearest
-/// integer, halves up. (JS and Rust disagree only on negative halves, which
-/// no slider range here can reach.)
-fn round(value: f64) -> i64 {
- value.round() as i64
-}
-
-// ─── the video effect catalogue ─────────────────────────────────────────────
-
-fn fx_black_white(_: &Params, _index: usize) -> String {
- "hue=s=0".to_owned()
-}
-
-fn fx_sepia(_: &Params, _index: usize) -> String {
- // The standard sepia matrix, the same one the CSS filter defines.
- "colorchannelmixer=.393:.769:.189:0:.349:.686:.168:0:.272:.534:.131".to_owned()
-}
-
-fn fx_invert(_: &Params, _index: usize) -> String {
- "negate".to_owned()
-}
-
-fn fx_sharpen(p: &Params, _index: usize) -> String {
- let amount = fixed(p.get("amount"), 2);
- format!("unsharp=5:5:{amount}:5:5:0")
-}
-
-fn fx_gaussian_blur(p: &Params, _index: usize) -> String {
- let sigma = fixed(p.get("radius"), 1);
- format!("gblur=sigma={sigma}")
-}
-
-fn fx_box_blur(p: &Params, _index: usize) -> String {
- let radius = round(p.get("radius"));
- format!("boxblur={radius}:1")
-}
-
-fn fx_motion_blur(p: &Params, _index: usize) -> String {
- // Gaussian in one axis only is the streak; the tiny vertical sigma keeps
- // the filter happy without visibly blurring that axis.
- let sigma = fixed(p.get("length"), 1);
- format!("gblur=sigma={sigma}:sigmaV=0.1")
-}
-
-fn fx_temperature(p: &Params, _index: usize) -> String {
- let temperature = round(p.get("temperature"));
- format!("colortemperature=temperature={temperature}")
-}
-
-fn fx_vibrance(p: &Params, _index: usize) -> String {
- let intensity = fixed(p.get("intensity"), 2);
- format!("vibrance=intensity={intensity}")
-}
-
-fn fx_contrast_pop(p: &Params, _index: usize) -> String {
- let contrast = fixed(p.get("contrast"), 2);
- format!("eq=contrast={contrast}")
-}
-
-fn fx_vignette(p: &Params, _index: usize) -> String {
- // The filter's angle runs 0..PI/2, wider being darker corners; the slider
- // maps into the range that reads as a vignette rather than a tunnel.
- let angle = fixed(0.25 + (p.get("strength") / 100.0) * 1.05, 3);
- format!("vignette=angle={angle}")
-}
-
-fn fx_film_grain(p: &Params, _index: usize) -> String {
- // Temporal (t) so the grain dances like film instead of sitting still.
- let amount = round(p.get("amount"));
- format!("noise=alls={amount}:allf=t+u")
-}
-
-/// Graph labels embed the emitted index so two glows on one clip cannot
-/// collide in a single filtergraph: fixed labels would make FFmpeg reject
-/// the graph.
-fn fx_glow(p: &Params, index: usize) -> String {
- // Screen-blend a blurred copy over itself - the classic bloom.
- let opacity = fixed(p.get("amount") / 100.0, 2);
- format!(
- "split[glowa{index}][glowb{index}];[glowb{index}]gblur=sigma=18[glowg{index}];\
- [glowa{index}][glowg{index}]blend=all_mode=screen:all_opacity={opacity}"
- )
-}
-
-fn fx_posterize(p: &Params, _index: usize) -> String {
- let size = round(256.0 / round(p.get("levels")).max(2) as f64);
- let band = format!("trunc(val/{size})*{size}");
- format!("lutrgb=r={band}:g={band}:b={band}")
-}
-
-fn fx_pixelate(p: &Params, _index: usize) -> String {
- let size = round(p.get("size"));
- format!("pixelize=width={size}:height={size}")
-}
-
-/// Labels embed the emitted index for the same reason as [`fx_glow`]:
-/// stacking mirror twice must not duplicate a filtergraph label.
-fn fx_mirror(_: &Params, index: usize) -> String {
- format!(
- "crop=iw/2:ih:0:0,split[mirl{index}][mirr{index}];[mirr{index}]hflip[mirf{index}];\
- [mirl{index}][mirf{index}]hstack"
- )
-}
-
-fn fx_fisheye(p: &Params, _index: usize) -> String {
- // Negative correction coefficients produce barrel distortion - the bulge.
- let k = p.get("strength") / 100.0;
- let k1 = fixed(-0.55 * k, 3);
- let k2 = fixed(-0.2 * k, 3);
- format!("lenscorrection=k1={k1}:k2={k2}:i=bilinear")
-}
-
-fn fx_shake(p: &Params, _index: usize) -> String {
- // A jittering crop window; the decoder's guard scale stretches the
- // slightly smaller window back to full size afterwards.
- let a = round(p.get("amount"));
- let f = round(p.get("speed"));
- let f2 = round(f as f64 * 1.3);
- format!(
- "crop=iw-{}:ih-{}:{a}+{a}*sin(t*{f}):{a}+{a}*cos(t*{f2})",
- 2 * a,
- 2 * a
- )
-}
-
-/// Every video effect, in the catalogue's order. Ids are forever: they are
-/// written into project files.
-static EFFECTS: &[Entry] = &[
- Entry {
- id: "black-white",
- params: &[],
- chain: fx_black_white,
- },
- Entry {
- id: "sepia",
- params: &[],
- chain: fx_sepia,
- },
- Entry {
- id: "invert",
- params: &[],
- chain: fx_invert,
- },
- Entry {
- id: "sharpen",
- params: &[Param {
- key: "amount",
- min: 0.2,
- max: 3.0,
- default: 1.0,
- }],
- chain: fx_sharpen,
- },
- Entry {
- id: "gaussian-blur",
- params: &[Param {
- key: "radius",
- min: 1.0,
- max: 50.0,
- default: 10.0,
- }],
- chain: fx_gaussian_blur,
- },
- Entry {
- id: "box-blur",
- params: &[Param {
- key: "radius",
- min: 1.0,
- max: 30.0,
- default: 6.0,
- }],
- chain: fx_box_blur,
- },
- Entry {
- id: "motion-blur",
- params: &[Param {
- key: "length",
- min: 2.0,
- max: 60.0,
- default: 18.0,
- }],
- chain: fx_motion_blur,
- },
- Entry {
- id: "warm",
- params: &[Param {
- key: "temperature",
- min: 3000.0,
- max: 6000.0,
- default: 4600.0,
- }],
- chain: fx_temperature,
- },
- Entry {
- id: "cool",
- params: &[Param {
- key: "temperature",
- min: 7000.0,
- max: 11000.0,
- default: 8500.0,
- }],
- chain: fx_temperature,
- },
- Entry {
- id: "vibrance",
- params: &[Param {
- key: "intensity",
- min: 0.1,
- max: 2.0,
- default: 0.7,
- }],
- chain: fx_vibrance,
- },
- Entry {
- id: "contrast-pop",
- params: &[Param {
- key: "contrast",
- min: 1.0,
- max: 2.0,
- default: 1.25,
- }],
- chain: fx_contrast_pop,
- },
- Entry {
- id: "vignette",
- params: &[Param {
- key: "strength",
- min: 10.0,
- max: 100.0,
- default: 50.0,
- }],
- chain: fx_vignette,
- },
- Entry {
- id: "film-grain",
- params: &[Param {
- key: "amount",
- min: 2.0,
- max: 40.0,
- default: 12.0,
- }],
- chain: fx_film_grain,
- },
- Entry {
- id: "glow",
- params: &[Param {
- key: "amount",
- min: 10.0,
- max: 100.0,
- default: 45.0,
- }],
- chain: fx_glow,
- },
- Entry {
- id: "posterize",
- params: &[Param {
- key: "levels",
- min: 2.0,
- max: 8.0,
- default: 4.0,
- }],
- chain: fx_posterize,
- },
- Entry {
- id: "pixelate",
- params: &[Param {
- key: "size",
- min: 2.0,
- max: 64.0,
- default: 16.0,
- }],
- chain: fx_pixelate,
- },
- Entry {
- id: "mirror",
- params: &[],
- chain: fx_mirror,
- },
- Entry {
- id: "fisheye",
- params: &[Param {
- key: "strength",
- min: 5.0,
- max: 100.0,
- default: 50.0,
- }],
- chain: fx_fisheye,
- },
- Entry {
- id: "shake",
- params: &[
- Param {
- key: "amount",
- min: 2.0,
- max: 40.0,
- default: 12.0,
- },
- Param {
- key: "speed",
- min: 2.0,
- max: 30.0,
- default: 13.0,
- },
- ],
- chain: fx_shake,
- },
-];
-
-// ─── the audio filter catalogue ─────────────────────────────────────────────
-
-/// Pitch shift that moves the formants with the pitch.
-///
-/// Raising the sample rate and then resampling back shifts everything - which
-/// is why it sounds like a different voice rather than the same voice
-/// transposed. `atempo` then puts the duration back, because `asetrate` alone
-/// would also make the clip shorter.
-///
-/// This is the technique the whole Voice category is built on.
-fn pitch_shift(semitone_shift: f64) -> Vec<String> {
- let ratio = 2f64.powf(semitone_shift / 12.0);
- vec![
- "aresample=48000".to_owned(),
- format!("asetrate={}", fixed(48000.0 * ratio, 6)),
- "aresample=48000".to_owned(),
- format!("atempo={}", fixed(1.0 / ratio, 8)),
- ]
-}
-
-fn af_sweet(p: &Params, _index: usize) -> String {
- let strength = p.get("amount").clamp(0.0, 100.0) / 100.0;
- let pitch = p.get("pitch");
-
- // The coefficients are steeper than a textbook "sweet voice" chain on
- // purpose: at the slider's midpoint the change has to be audible.
- let shift = if pitch > 0.0 {
- pitch
- } else {
- 1.2 + 3.8 * strength
- };
- let presence = fixed(0.8 + 5.2 * strength, 3);
- let air = fixed(1.0 + 7.0 * strength, 3);
- let deess = fixed(0.18 + 0.32 * strength, 3);
- let echo = fixed(0.012 + 0.048 * strength, 4);
-
- let mut parts = pitch_shift(shift);
- parts.extend([
- "highpass=f=85".to_owned(),
- "equalizer=f=300:t=q:w=1.1:g=-1.4".to_owned(),
- format!("equalizer=f=4200:t=q:w=0.8:g={presence}"),
- format!("equalizer=f=10500:t=q:w=0.7:g={air}"),
- "compand=attacks=0.010:decays=0.180:points=-80/-80|-30/-24|-18/-13|-8/-5|0/-1.5:soft-knee=5:gain=1"
- .to_owned(),
- format!("deesser=i={deess}:m=0.45:f=0.55"),
- format!("aecho=0.8:0.82:38:{echo}"),
- "alimiter=limit=0.94:attack=5:release=60".to_owned(),
- ]);
- parts.join(",")
-}
-
-fn af_deep(p: &Params, _index: usize) -> String {
- let body = fixed(p.get("body"), 2);
- let mut parts = pitch_shift(p.get("pitch"));
- parts.extend([
- "highpass=f=55".to_owned(),
- format!("equalizer=f=140:t=q:w=1.0:g={body}"),
- "equalizer=f=2600:t=q:w=0.9:g=-1.2".to_owned(),
- "alimiter=limit=0.94:attack=5:release=60".to_owned(),
- ]);
- parts.join(",")
-}
-
-fn af_chipmunk(p: &Params, _index: usize) -> String {
- let mut parts = pitch_shift(p.get("pitch"));
- parts.extend([
- "highpass=f=120".to_owned(),
- "alimiter=limit=0.94".to_owned(),
- ]);
- parts.join(",")
-}
-
-fn af_robot(p: &Params, _index: usize) -> String {
- // aphaser caps speed at 2, so depth maps into 0.4-2.0 rather than being
- // halved - which put it out of range and made the filter refuse.
- let speed = fixed(0.4 + (p.get("depth") / 10.0) * 1.6, 2);
- [
- format!("aphaser=type=t:speed={speed}:decay=0.6"),
- "flanger=delay=2:depth=4:speed=0.8".to_owned(),
- "equalizer=f=1800:t=q:w=1.2:g=3".to_owned(),
- "alimiter=limit=0.94".to_owned(),
- ]
- .join(",")
-}
-
-fn af_bass(p: &Params, _index: usize) -> String {
- let gain = fixed(p.get("gain"), 2);
- format!("bass=g={gain}:f=110:w=0.6,alimiter=limit=0.95")
-}
-
-fn af_treble(p: &Params, _index: usize) -> String {
- let gain = fixed(p.get("gain"), 2);
- format!("treble=g={gain}:f=9000:w=0.7,alimiter=limit=0.95")
-}
-
-fn af_telephone(p: &Params, _index: usize) -> String {
- let gain = fixed(3.0 + p.get("drive") / 2.0, 2);
- [
- "highpass=f=400".to_owned(),
- "lowpass=f=3400".to_owned(),
- format!("equalizer=f=1600:t=q:w=1.4:g={gain}"),
- "alimiter=limit=0.92".to_owned(),
- ]
- .join(",")
-}
-
-fn af_echo(p: &Params, _index: usize) -> String {
- let delay = round(p.get("delay") * 1000.0);
- let decay = fixed(p.get("decay"), 2);
- format!("aecho=0.8:0.85:{delay}:{decay}")
-}
-
-fn af_room(p: &Params, _index: usize) -> String {
- let scale = 0.4 + (p.get("size") / 100.0) * 1.6;
- let taps = [23.0, 41.0, 67.0, 97.0]
- .iter()
- .map(|ms| round(ms * scale).to_string())
- .collect::<Vec<_>>()
- .join("|");
- let gains = [0.32, 0.24, 0.17, 0.11]
- .iter()
- .map(|g| fixed(*g, 3))
- .collect::<Vec<_>>()
- .join("|");
- format!("aecho=0.8:0.88:{taps}:{gains}")
-}
-
-/// Every audio filter, in the catalogue's order. Same forever-ids rule as
-/// the effects.
-static FILTERS: &[Entry] = &[
- Entry {
- id: "sweet",
- params: &[
- Param {
- key: "amount",
- min: 0.0,
- max: 100.0,
- default: 65.0,
- },
- // 0 means "follow amount", which is what the original did when
- // no explicit pitch was passed.
- Param {
- key: "pitch",
- min: 0.0,
- max: 8.0,
- default: 0.0,
- },
- ],
- chain: af_sweet,
- },
- Entry {
- id: "deep",
- params: &[
- Param {
- key: "pitch",
- min: -8.0,
- max: -1.0,
- default: -3.0,
- },
- Param {
- key: "body",
- min: 0.0,
- max: 8.0,
- default: 3.0,
- },
- ],
- chain: af_deep,
- },
- Entry {
- id: "chipmunk",
- params: &[Param {
- key: "pitch",
- min: 3.0,
- max: 12.0,
- default: 7.0,
- }],
- chain: af_chipmunk,
- },
- Entry {
- id: "robot",
- params: &[Param {
- key: "depth",
- min: 1.0,
- max: 10.0,
- default: 5.0,
- }],
- chain: af_robot,
- },
- Entry {
- id: "bass",
- params: &[Param {
- key: "gain",
- min: 0.0,
- max: 12.0,
- default: 5.0,
- }],
- chain: af_bass,
- },
- Entry {
- id: "treble",
- params: &[Param {
- key: "gain",
- min: 0.0,
- max: 12.0,
- default: 4.0,
- }],
- chain: af_treble,
- },
- Entry {
- id: "telephone",
- params: &[Param {
- key: "drive",
- min: 0.0,
- max: 10.0,
- default: 3.0,
- }],
- chain: af_telephone,
- },
- Entry {
- id: "echo",
- params: &[
- Param {
- key: "delay",
- min: 0.05,
- max: 1.0,
- default: 0.25,
- },
- Param {
- key: "decay",
- min: 0.1,
- max: 0.9,
- default: 0.4,
- },
- ],
- chain: af_echo,
- },
- Entry {
- id: "room",
- params: &[Param {
- key: "size",
- min: 0.0,
- max: 100.0,
- default: 40.0,
- }],
- chain: af_room,
- },
-];
-
-// ─── composition ────────────────────────────────────────────────────────────
-
-/// Fills in any parameter the clip did not set, and drops any stray key the
-/// entry does not declare.
-fn resolve(entry: &Entry, set: &BTreeMap<String, f64>) -> Params {
- Params(
- entry
- .params
- .iter()
- .map(|param| {
- (
- param.key,
- set.get(param.key).copied().unwrap_or(param.default),
- )
- })
- .collect(),
- )
-}
-
-/// The shared composition rule: enabled entries in applied order, comma-
-/// joined; bypassed entries and ids the catalogue does not know contribute
-/// nothing. Empty result is the empty string.
-fn compose(catalogue: &[Entry], applied: &[AppliedFilter]) -> String {
- // The index passed to each builder is the fragment's *emitted* position,
- // not its list position - labels stay stable when a bypassed entry sits
- // earlier in the list. Mirrors buildEffectChain exactly.
- let mut fragments: Vec<String> = Vec::new();
- for applied in applied.iter().filter(|applied| applied.enabled) {
- let Some(entry) = catalogue.iter().find(|entry| entry.id == applied.id) else {
- continue;
- };
- let fragment = (entry.chain)(&resolve(entry, &applied.params), fragments.len());
- fragments.push(fragment);
- }
- fragments.join(",")
-}
-
/// The complete FFmpeg *video* filter string for a clip's effects, or the
/// empty string if it has none. Effects apply in the order they were added.
pub fn video_effect_chain(effects: &[AppliedFilter]) -> String {
- compose(EFFECTS, effects)
+ Catalogue::builtin().video_chain(effects)
}
/// The complete FFmpeg *audio* filter string for a clip's filters, or the
/// empty string if it has none. Filters apply in the order they were added:
/// EQ before a limiter is a different sound from the reverse.
pub fn audio_filter_chain(filters: &[AppliedFilter]) -> String {
- compose(FILTERS, filters)
+ Catalogue::builtin().audio_chain(filters)
}
-// ─── tests: the pinned strings ──────────────────────────────────────────────
-
#[cfg(test)]
mod tests {
use super::*;
- fn applied(id: &str, params: &[(&str, f64)]) -> AppliedFilter {
- AppliedFilter {
- id: id.to_owned(),
- params: params
- .iter()
- .map(|(key, value)| ((*key).to_owned(), *value))
- .collect(),
- enabled: true,
- }
- }
-
- fn one_effect(id: &str, params: &[(&str, f64)]) -> String {
- video_effect_chain(&[applied(id, params)])
- }
-
- fn one_filter(id: &str, params: &[(&str, f64)]) -> String {
- audio_filter_chain(&[applied(id, params)])
- }
-
- /// The definition's sliders, all pushed to one bound.
- fn at_bound(catalogue: &[Entry], id: &str, minimum: bool) -> AppliedFilter {
- let entry = catalogue
- .iter()
- .find(|entry| entry.id == id)
- .expect("known id");
+ fn applied(id: &str) -> AppliedFilter {
AppliedFilter {
id: id.to_owned(),
- params: entry
- .params
- .iter()
- .map(|param| {
- (
- param.key.to_owned(),
- if minimum { param.min } else { param.max },
- )
- })
- .collect(),
+ params: Default::default(),
enabled: true,
}
}
- /// Asserts a fixture table covers exactly the given ids - a new
- /// catalogue entry must pin its strings here.
- fn assert_covers(table: &[(&str, &str)], mut ids: Vec<&str>, which: &str) {
- let mut covered: Vec<&str> = table.iter().map(|(id, _)| *id).collect();
- covered.sort_unstable();
- ids.sort_unstable();
- assert_eq!(
- covered, ids,
- "the {which} fixture table must cover the catalogue"
- );
- }
-
- fn parameterised(catalogue: &[Entry]) -> Vec<&'static str> {
- catalogue
- .iter()
- .filter(|entry| !entry.params.is_empty())
- .map(|entry| entry.id)
- .collect()
- }
-
- // The expected strings below pin the exporter's bytes.
-
- const EFFECT_DEFAULTS: &[(&str, &str)] = &[
- ("black-white", "hue=s=0"),
- (
- "sepia",
- "colorchannelmixer=.393:.769:.189:0:.349:.686:.168:0:.272:.534:.131",
- ),
- ("invert", "negate"),
- ("sharpen", "unsharp=5:5:1.00:5:5:0"),
- ("gaussian-blur", "gblur=sigma=10.0"),
- ("box-blur", "boxblur=6:1"),
- ("motion-blur", "gblur=sigma=18.0:sigmaV=0.1"),
- ("warm", "colortemperature=temperature=4600"),
- ("cool", "colortemperature=temperature=8500"),
- ("vibrance", "vibrance=intensity=0.70"),
- ("contrast-pop", "eq=contrast=1.25"),
- ("vignette", "vignette=angle=0.775"),
- ("film-grain", "noise=alls=12:allf=t+u"),
- (
- "glow",
- "split[glowa0][glowb0];[glowb0]gblur=sigma=18[glowg0];\
- [glowa0][glowg0]blend=all_mode=screen:all_opacity=0.45",
- ),
- (
- "posterize",
- "lutrgb=r=trunc(val/64)*64:g=trunc(val/64)*64:b=trunc(val/64)*64",
- ),
- ("pixelate", "pixelize=width=16:height=16"),
- (
- "mirror",
- "crop=iw/2:ih:0:0,split[mirl0][mirr0];[mirr0]hflip[mirf0];[mirl0][mirf0]hstack",
- ),
- ("fisheye", "lenscorrection=k1=-0.275:k2=-0.100:i=bilinear"),
- ("shake", "crop=iw-24:ih-24:12+12*sin(t*13):12+12*cos(t*17)"),
- ];
-
- const EFFECT_MINIMA: &[(&str, &str)] = &[
- ("sharpen", "unsharp=5:5:0.20:5:5:0"),
- ("gaussian-blur", "gblur=sigma=1.0"),
- ("box-blur", "boxblur=1:1"),
- ("motion-blur", "gblur=sigma=2.0:sigmaV=0.1"),
- ("warm", "colortemperature=temperature=3000"),
- ("cool", "colortemperature=temperature=7000"),
- ("vibrance", "vibrance=intensity=0.10"),
- ("contrast-pop", "eq=contrast=1.00"),
- ("vignette", "vignette=angle=0.355"),
- ("film-grain", "noise=alls=2:allf=t+u"),
- (
- "glow",
- "split[glowa0][glowb0];[glowb0]gblur=sigma=18[glowg0];\
- [glowa0][glowg0]blend=all_mode=screen:all_opacity=0.10",
- ),
- (
- "posterize",
- "lutrgb=r=trunc(val/128)*128:g=trunc(val/128)*128:b=trunc(val/128)*128",
- ),
- ("pixelate", "pixelize=width=2:height=2"),
- ("fisheye", "lenscorrection=k1=-0.028:k2=-0.010:i=bilinear"),
- ("shake", "crop=iw-4:ih-4:2+2*sin(t*2):2+2*cos(t*3)"),
- ];
-
- const EFFECT_MAXIMA: &[(&str, &str)] = &[
- ("sharpen", "unsharp=5:5:3.00:5:5:0"),
- ("gaussian-blur", "gblur=sigma=50.0"),
- ("box-blur", "boxblur=30:1"),
- ("motion-blur", "gblur=sigma=60.0:sigmaV=0.1"),
- ("warm", "colortemperature=temperature=6000"),
- ("cool", "colortemperature=temperature=11000"),
- ("vibrance", "vibrance=intensity=2.00"),
- ("contrast-pop", "eq=contrast=2.00"),
- ("vignette", "vignette=angle=1.300"),
- ("film-grain", "noise=alls=40:allf=t+u"),
- (
- "glow",
- "split[glowa0][glowb0];[glowb0]gblur=sigma=18[glowg0];\
- [glowa0][glowg0]blend=all_mode=screen:all_opacity=1.00",
- ),
- (
- "posterize",
- "lutrgb=r=trunc(val/32)*32:g=trunc(val/32)*32:b=trunc(val/32)*32",
- ),
- ("pixelate", "pixelize=width=64:height=64"),
- ("fisheye", "lenscorrection=k1=-0.550:k2=-0.200:i=bilinear"),
- ("shake", "crop=iw-80:ih-80:40+40*sin(t*30):40+40*cos(t*39)"),
- ];
-
- const FILTER_DEFAULTS: &[(&str, &str)] = &[
- (
- "sweet",
- "aresample=48000,asetrate=59334.357554,aresample=48000,atempo=0.80897480,\
- highpass=f=85,equalizer=f=300:t=q:w=1.1:g=-1.4,\
- equalizer=f=4200:t=q:w=0.8:g=4.180,equalizer=f=10500:t=q:w=0.7:g=5.550,\
- compand=attacks=0.010:decays=0.180:points=-80/-80|-30/-24|-18/-13|-8/-5|0/-1.5:soft-knee=5:gain=1,\
- deesser=i=0.388:m=0.45:f=0.55,aecho=0.8:0.82:38:0.0432,\
- alimiter=limit=0.94:attack=5:release=60",
- ),
- (
- "deep",
- "aresample=48000,asetrate=40363.027932,aresample=48000,atempo=1.18920712,\
- highpass=f=55,equalizer=f=140:t=q:w=1.0:g=3.00,\
- equalizer=f=2600:t=q:w=0.9:g=-1.2,alimiter=limit=0.94:attack=5:release=60",
- ),
- (
- "chipmunk",
- "aresample=48000,asetrate=71918.739690,aresample=48000,atempo=0.66741993,\
- highpass=f=120,alimiter=limit=0.94",
- ),
- (
- "robot",
- "aphaser=type=t:speed=1.20:decay=0.6,flanger=delay=2:depth=4:speed=0.8,\
- equalizer=f=1800:t=q:w=1.2:g=3,alimiter=limit=0.94",
- ),
- ("bass", "bass=g=5.00:f=110:w=0.6,alimiter=limit=0.95"),
- ("treble", "treble=g=4.00:f=9000:w=0.7,alimiter=limit=0.95"),
- (
- "telephone",
- "highpass=f=400,lowpass=f=3400,equalizer=f=1600:t=q:w=1.4:g=4.50,alimiter=limit=0.92",
- ),
- ("echo", "aecho=0.8:0.85:250:0.40"),
- (
- "room",
- "aecho=0.8:0.88:24|43|70|101:0.320|0.240|0.170|0.110",
- ),
- ];
-
- const FILTER_MINIMA: &[(&str, &str)] = &[
- (
- "sweet",
- "aresample=48000,asetrate=51445.126202,aresample=48000,atempo=0.93303299,\
- highpass=f=85,equalizer=f=300:t=q:w=1.1:g=-1.4,\
- equalizer=f=4200:t=q:w=0.8:g=0.800,equalizer=f=10500:t=q:w=0.7:g=1.000,\
- compand=attacks=0.010:decays=0.180:points=-80/-80|-30/-24|-18/-13|-8/-5|0/-1.5:soft-knee=5:gain=1,\
- deesser=i=0.180:m=0.45:f=0.55,aecho=0.8:0.82:38:0.0120,\
- alimiter=limit=0.94:attack=5:release=60",
- ),
- (
- "deep",
- "aresample=48000,asetrate=30238.105197,aresample=48000,atempo=1.58740105,\
- highpass=f=55,equalizer=f=140:t=q:w=1.0:g=0.00,\
- equalizer=f=2600:t=q:w=0.9:g=-1.2,alimiter=limit=0.94:attack=5:release=60",
- ),
- (
- "chipmunk",
- "aresample=48000,asetrate=57081.941520,aresample=48000,atempo=0.84089642,\
- highpass=f=120,alimiter=limit=0.94",
- ),
- (
- "robot",
- "aphaser=type=t:speed=0.56:decay=0.6,flanger=delay=2:depth=4:speed=0.8,\
- equalizer=f=1800:t=q:w=1.2:g=3,alimiter=limit=0.94",
- ),
- ("bass", "bass=g=0.00:f=110:w=0.6,alimiter=limit=0.95"),
- ("treble", "treble=g=0.00:f=9000:w=0.7,alimiter=limit=0.95"),
- (
- "telephone",
- "highpass=f=400,lowpass=f=3400,equalizer=f=1600:t=q:w=1.4:g=3.00,alimiter=limit=0.92",
- ),
- ("echo", "aecho=0.8:0.85:50:0.10"),
- ("room", "aecho=0.8:0.88:9|16|27|39:0.320|0.240|0.170|0.110"),
- ];
-
- const FILTER_MAXIMA: &[(&str, &str)] = &[
- (
- "sweet",
- "aresample=48000,asetrate=76195.250494,aresample=48000,atempo=0.62996052,\
- highpass=f=85,equalizer=f=300:t=q:w=1.1:g=-1.4,\
- equalizer=f=4200:t=q:w=0.8:g=6.000,equalizer=f=10500:t=q:w=0.7:g=8.000,\
- compand=attacks=0.010:decays=0.180:points=-80/-80|-30/-24|-18/-13|-8/-5|0/-1.5:soft-knee=5:gain=1,\
- deesser=i=0.500:m=0.45:f=0.55,aecho=0.8:0.82:38:0.0600,\
- alimiter=limit=0.94:attack=5:release=60",
- ),
- (
- "deep",
- "aresample=48000,asetrate=45305.967009,aresample=48000,atempo=1.05946309,\
- highpass=f=55,equalizer=f=140:t=q:w=1.0:g=8.00,\
- equalizer=f=2600:t=q:w=0.9:g=-1.2,alimiter=limit=0.94:attack=5:release=60",
- ),
- (
- // +12 semitones is exactly double: the one point the maths comes
- // out round.
- "chipmunk",
- "aresample=48000,asetrate=96000.000000,aresample=48000,atempo=0.50000000,\
- highpass=f=120,alimiter=limit=0.94",
- ),
- (
- // Depth 10 must land exactly on aphaser's speed cap of 2, never
- // above it - above the cap the filter refuses the whole export.
- "robot",
- "aphaser=type=t:speed=2.00:decay=0.6,flanger=delay=2:depth=4:speed=0.8,\
- equalizer=f=1800:t=q:w=1.2:g=3,alimiter=limit=0.94",
- ),
- ("bass", "bass=g=12.00:f=110:w=0.6,alimiter=limit=0.95"),
- ("treble", "treble=g=12.00:f=9000:w=0.7,alimiter=limit=0.95"),
- (
- "telephone",
- "highpass=f=400,lowpass=f=3400,equalizer=f=1600:t=q:w=1.4:g=8.00,alimiter=limit=0.92",
- ),
- ("echo", "aecho=0.8:0.85:1000:0.90"),
- (
- "room",
- "aecho=0.8:0.88:46|82|134|194:0.320|0.240|0.170|0.110",
- ),
- ];
-
- #[test]
- fn every_effect_at_its_default_settings() {
- let ids: Vec<&str> = EFFECTS.iter().map(|entry| entry.id).collect();
- assert_covers(EFFECT_DEFAULTS, ids, "effect defaults");
- for (id, expected) in EFFECT_DEFAULTS {
- // No params passed: resolve must fill every default.
- assert_eq!(one_effect(id, &[]), *expected, "{id}");
- }
- }
-
- #[test]
- fn every_effect_at_its_sliders_minimum() {
- assert_covers(EFFECT_MINIMA, parameterised(EFFECTS), "effect minima");
- for (id, expected) in EFFECT_MINIMA {
- let chain = video_effect_chain(&[at_bound(EFFECTS, id, true)]);
- assert_eq!(chain, *expected, "{id}");
- }
- }
-
- #[test]
- fn every_effect_at_its_sliders_maximum() {
- assert_covers(EFFECT_MAXIMA, parameterised(EFFECTS), "effect maxima");
- for (id, expected) in EFFECT_MAXIMA {
- let chain = video_effect_chain(&[at_bound(EFFECTS, id, false)]);
- assert_eq!(chain, *expected, "{id}");
- }
- }
-
- #[test]
- fn every_filter_at_its_default_settings() {
- let ids: Vec<&str> = FILTERS.iter().map(|entry| entry.id).collect();
- assert_covers(FILTER_DEFAULTS, ids, "filter defaults");
- for (id, expected) in FILTER_DEFAULTS {
- assert_eq!(one_filter(id, &[]), *expected, "{id}");
- }
- }
-
- #[test]
- fn every_filter_at_its_sliders_minimum() {
- assert_covers(FILTER_MINIMA, parameterised(FILTERS), "filter minima");
- for (id, expected) in FILTER_MINIMA {
- let chain = audio_filter_chain(&[at_bound(FILTERS, id, true)]);
- assert_eq!(chain, *expected, "{id}");
- }
- }
-
- #[test]
- fn every_filter_at_its_sliders_maximum() {
- assert_covers(FILTER_MAXIMA, parameterised(FILTERS), "filter maxima");
- for (id, expected) in FILTER_MAXIMA {
- let chain = audio_filter_chain(&[at_bound(FILTERS, id, false)]);
- assert_eq!(chain, *expected, "{id}");
- }
- }
-
- #[test]
- fn stacked_effects_join_with_commas_in_applied_order() {
- assert_eq!(
- video_effect_chain(&[applied("gaussian-blur", &[]), applied("black-white", &[])]),
- "gblur=sigma=10.0,hue=s=0"
- );
- // The reverse order is a different picture and a different string.
- assert_eq!(
- video_effect_chain(&[applied("black-white", &[]), applied("gaussian-blur", &[])]),
- "hue=s=0,gblur=sigma=10.0"
- );
- }
-
#[test]
- fn a_bypassed_effect_contributes_nothing() {
- let mut sepia = applied("sepia", &[]);
- sepia.enabled = false;
+ fn the_exporter_reaches_the_built_in_catalogue() {
+ assert_eq!(video_effect_chain(&[applied("black-white")]), "hue=s=0");
assert_eq!(
- video_effect_chain(&[applied("invert", &[]), sepia, applied("black-white", &[])]),
- "negate,hue=s=0"
- );
- }
-
- #[test]
- fn stacking_one_labelled_effect_twice_keeps_its_graph_labels_distinct() {
- // Labels embed the emitted index. With fixed labels, two glows on
- // one clip would duplicate [glowa] in a single filtergraph and
- // FFmpeg would reject it - the whole export would fail.
- let chain = video_effect_chain(&[applied("glow", &[]), applied("glow", &[])]);
- assert!(chain.contains("[glowa0]"), "was: {chain}");
- assert!(chain.contains("[glowa1]"), "was: {chain}");
-
- // A bypassed entry does not consume an index: labels follow emission.
- let mut sepia = applied("sepia", &[]);
- sepia.enabled = false;
- let skipped = video_effect_chain(&[sepia, applied("mirror", &[])]);
- assert!(skipped.contains("[mirl0]"), "was: {skipped}");
- }
-
- #[test]
- fn an_unknown_effect_id_is_skipped_not_exported_as_garbage() {
- // A project written by a newer Concat may carry effects this build
- // does not know. The chain must stay valid for the ones it does.
- assert_eq!(
- video_effect_chain(&[applied("from-the-future", &[]), applied("invert", &[])]),
- "negate"
- );
- }
-
- #[test]
- fn no_effects_means_the_empty_string() {
- // The spelling of "no chain" is "".
- assert_eq!(video_effect_chain(&[]), "");
- let mut off = applied("invert", &[]);
- off.enabled = false;
- assert_eq!(video_effect_chain(&[off]), "");
- }
-
- #[test]
- fn stray_parameter_keys_are_dropped_and_missing_ones_default() {
- assert_eq!(
- one_effect("sharpen", &[("amount", 2.0), ("bogus", 99.0)]),
- "unsharp=5:5:2.00:5:5:0"
- );
- assert_eq!(
- one_effect("shake", &[("amount", 20.0)]),
- "crop=iw-40:ih-40:20+20*sin(t*13):20+20*cos(t*17)"
- );
- }
-
- #[test]
- fn stacked_filters_join_with_commas_in_applied_order() {
- // EQ into a limiter is a different sound from a limiter into EQ; the
- // array's order is the contract.
- assert_eq!(
- audio_filter_chain(&[applied("bass", &[]), applied("echo", &[])]),
- "bass=g=5.00:f=110:w=0.6,alimiter=limit=0.95,aecho=0.8:0.85:250:0.40"
- );
- }
-
- #[test]
- fn a_bypassed_filter_contributes_nothing() {
- let mut bass = applied("bass", &[]);
- bass.enabled = false;
- assert_eq!(
- audio_filter_chain(&[bass, applied("echo", &[])]),
- "aecho=0.8:0.85:250:0.40"
- );
- }
-
- #[test]
- fn an_unknown_filter_id_is_skipped_not_exported_as_garbage() {
- assert_eq!(
- audio_filter_chain(&[applied("from-the-future", &[]), applied("echo", &[])]),
+ audio_filter_chain(&[applied("echo")]),
"aecho=0.8:0.85:250:0.40"
);
- }
-
- #[test]
- fn no_audible_filters_means_the_empty_string() {
- assert_eq!(audio_filter_chain(&[]), "");
- let mut off = applied("bass", &[]);
- off.enabled = false;
- assert_eq!(audio_filter_chain(&[off]), "");
- }
-
- #[test]
- fn a_set_parameter_overrides_the_default() {
- // One filter with one slider moved off its default.
- assert_eq!(
- one_filter("echo", &[("delay", 0.5)]),
- "aecho=0.8:0.85:500:0.40"
- );
+ assert_eq!(video_effect_chain(&[]), "");
}
}