Skip to content

FilmCraft: An open-source, nonlinear video editor written by scratch in pure Rust

Merge video transitions (M5.10) into integration; effects.list keeps folder (leaf) and adds path

Brandon Thomasd67f1010649b
diff --cc crates/engine/src/commands.rs
index 860ca254e,079d4580d..bb0070930
--- a/crates/engine/src/commands.rs
+++ b/crates/engine/src/commands.rs
@@@ -2419,18 -2368,136 +2431,141 @@@ fn nest(s: &mut Session, p: &Value) ->
.map(|n| json!({"sequence": n.0}))
}
+ /// `effects.list`: every effect definition with its Effects-panel folder (optionally filtered by
+ /// kind or folder prefix); `detail` adds each parameter's label, type, default and choices.
+ fn list_effects(p: &Value) -> Value {
+ let kind = str_p(p, "kind");
+ let folder = str_p(p, "folder");
+ let detail = p.get("detail").and_then(Value::as_bool).unwrap_or(false);
+ let out = filmcraft_project::effect_defs()
+ .iter()
+ .filter(|d| kind.is_none_or(|k| format!("{:?}", d.kind).eq_ignore_ascii_case(k)))
+ .filter(|d| folder.is_none_or(|f| d.category.join("/").starts_with(f)))
+ .map(|d| {
+ let mut v = json!({
+ "id": d.id,
+ "name": d.name,
+ "kind": format!("{:?}", d.kind),
+ "category": d.category,
- "folder": d.category.join("/"),
++ "folder": d.category.get(1),
++ "path": d.category.join("/"),
+ "params": d.params.iter().map(|p| p.id).collect::<Vec<_>>(),
+ "badges": {"accelerated": d.accelerated, "float32": d.float32, "yuv": d.yuv},
+ });
+ if detail {
+ v["paramInfo"] = Value::Array(d.params.iter().map(param_info).collect());
+ }
+ v
+ })
+ .collect();
+ Value::Array(out)
+ }
+
+ fn param_info(p: &filmcraft_project::ParamDef) -> Value {
+ use filmcraft_project::ParamKind as K;
+ let mut j = json!({"id": p.id, "label": p.label, "animatable": p.animatable, "default": serde_json::to_value(&p.default).unwrap_or_default()});
+ let ty = match &p.kind {
+ K::Choice(opts) => {
+ j["options"] = json!(opts);
+ "choice"
+ }
+ K::Float { min, max, unit, .. } => {
+ j["min"] = json!(min);
+ j["max"] = json!(max);
+ j["unit"] = json!(unit);
+ "float"
+ }
+ K::Point => "point",
+ K::Color => "color",
+ K::Bool => "bool",
+ K::Angle => "angle",
+ K::Text => "text",
+ K::Curve { .. } => "curve",
+ K::Wheel => "wheel",
+ K::Path => "path",
+ };
+ j["type"] = json!(ty);
+ j
+ }
+
+ /// Set transition parameters from a JSON object (`{"direction": 1}` or `{"direction": "From East"}`,
+ /// colours as `"#rrggbb"` or `[r,g,b]`, points as `[x,y]`). Floats are clamped to their range.
+ fn set_transition_params(e: &mut filmcraft_project::EffectInstance, params: &Value, cmd: &str) -> Result<()> {
+ use filmcraft_project::{ParamKind as K, ParamValue as V};
+ let Some(obj) = params.as_object() else { return Err(bad(cmd, "`params` must be an object")) };
+ let def = e.def().ok_or_else(|| bad(cmd, "unknown transition"))?;
+ for (k, v) in obj {
+ let pd = def.param(k).ok_or_else(|| bad(cmd, format!("`{}` has no param `{k}`", def.name)))?;
+ let val = match (&pd.kind, v) {
+ (K::Choice(opts), Value::String(sv)) => {
+ V::Choice(opts.iter().position(|o| o.eq_ignore_ascii_case(sv)).ok_or_else(|| bad(cmd, format!("`{k}` must be one of {opts:?}")))? as u32)
+ }
+ _ => json_to_param(&pd.default, v).ok_or_else(|| bad(cmd, format!("`{k}`: value has the wrong type")))?,
+ };
+ let val = match (&pd.kind, val) {
+ (K::Choice(opts), V::Choice(c)) if c as usize >= opts.len() => return Err(bad(cmd, format!("`{k}` must be < {}", opts.len()))),
+ (K::Float { min, max, .. }, V::Float(f)) => V::Float(f.clamp(*min, *max)),
+ (_, v) => v,
+ };
+ match e.param_mut(k) {
+ Some(prm) => prm.value = val,
+ None => {
+ e.params.insert(k.clone(), filmcraft_project::Param::new(val));
+ }
+ }
+ }
+ Ok(())
+ }
+
+ /// `sequence.setTransition`: edit an applied transition's settings (Effect Controls).
+ fn set_transition(s: &mut Session, p: &Value) -> Result<Value> {
+ const CMD: &str = "sequence.setTransition";
+ let id = p.get("transition").and_then(Value::as_u64).ok_or_else(|| bad(CMD, "need `transition`"))?;
+ let q = s.active_sequence().ok_or(EngineError::NoSequence)?;
+ let found = q.video_tracks.iter().chain(q.audio_tracks.iter()).find_map(|tr| tr.transitions.iter().find(|x| x.id.0 == id)).cloned();
+ let mut cur = found.ok_or_else(|| bad(CMD, format!("no transition {id}")))?;
+ if p.get("reset").and_then(Value::as_bool).unwrap_or(false)
+ && let Some(def) = cur.effect.def()
+ {
+ cur.effect = def.instance();
+ }
+ if let Some(params) = p.get("params") {
+ set_transition_params(&mut cur.effect, params, CMD)?;
+ }
+ if let Some(r) = p.get("reverse").and_then(Value::as_bool) {
+ cur.reverse = r;
+ }
+ let name = cur.effect.def().map_or("Transition", |d| d.name).to_string();
+ s.edit_sequence(&format!("Edit {name}"), |q, _, _| {
+ for tr in q.video_tracks.iter_mut().chain(q.audio_tracks.iter_mut()) {
+ if let Some(x) = tr.transitions.iter_mut().find(|x| x.id.0 == id) {
+ x.effect = cur.effect.clone();
+ x.reverse = cur.reverse;
+ }
+ }
+ Ok(())
+ })?;
+ Ok(json!({"transition": id, "effect": cur.effect.effect, "reverse": cur.reverse}))
+ }
+
fn apply_transition(s: &mut Session, p: &Value, kind: TrackKind) -> Result<Value> {
let eff_id = str_p(p, "effect")
.map(str::to_string)
.unwrap_or_else(|| if kind == TrackKind::Video { s.state.default_video_transition.clone() } else { s.state.default_audio_transition.clone() });
- let def = filmcraft_project::effect::find_effect_by_name(&eff_id).ok_or_else(|| bad("transition", format!("unknown transition `{eff_id}`")))?;
+ let ekind = if kind == TrackKind::Video { filmcraft_project::EffectKind::VideoTransition } else { filmcraft_project::EffectKind::AudioTransition };
+ let def = filmcraft_project::vtransition::find_transition(&eff_id, ekind).ok_or_else(|| bad("transition", format!("unknown transition `{eff_id}`")))?;
+ let mut instance = def.instance();
+ if let Some(params) = p.get("params") {
+ set_transition_params(&mut instance, params, "transition")?;
+ }
+ let reverse = p.get("reverse").and_then(Value::as_bool).unwrap_or(false);
let rate = s.sequence_rate();
- let frames = p.get("frames").and_then(Value::as_i64).unwrap_or(s.project.settings.default_transition_duration_frames);
- let dur = rate.tick_of(frames);
+ // Settings ▸ Timeline ▸ Video / Audio Transition Default Duration
+ let dur = match p.get("frames").and_then(Value::as_i64) {
+ Some(frames) => rate.tick_of(frames),
+ None if kind == TrackKind::Video => s.prefs.timeline.video_transition_duration(rate),
+ None => s.prefs.timeline.audio_transition_duration(rate),
+ };
let t = s.playhead();
let clip = clip_p(p, "clip");
let edge = str_p(p, "edge").map(str::to_string);
diff --cc crates/project/src/effect.rs
index 25f20009a,be82ece95..968e5f92a
--- a/crates/project/src/effect.rs
+++ b/crates/project/src/effect.rs
@@@ -789,43 -779,115 +785,12 @@@ fn build_effects() -> Vec<EffectDef>
video(
"clip_name",
"Clip Name",
- VIDEO,
+ vfx::OBSOLETE,
vec![pt("position", "Position", f64::NAN, f64::NAN), fs("size", "Size", 15.0, (1.0, 100.0), (1.0, 50.0), "%", 1)],
),
- video("simple_text", "Simple Text", VIDEO, vec![]),
+ video("simple_text", "Simple Text", vfx::UTILITY, vec![]),
- // ---- video transitions ----
- vtrans("cross_dissolve", "Cross Dissolve", DISSOLVE, vec![]),
- vtrans("additive_dissolve", "Additive Dissolve", DISSOLVE, vec![]),
- vtrans("dip_to_black", "Dip to Black", DISSOLVE, vec![]),
- vtrans("dip_to_white", "Dip to White", DISSOLVE, vec![]),
- vtrans("film_dissolve", "Film Dissolve", DISSOLVE, vec![]),
- vtrans("morph_cut", "Morph Cut", DISSOLVE, vec![]),
- vtrans("non_additive_dissolve", "Non-Additive Dissolve", DISSOLVE, vec![]),
- vtrans("iris_box", "Iris Box", IRIS, vec![]),
- vtrans("iris_cross", "Iris Cross", IRIS, vec![]),
- vtrans("iris_diamond", "Iris Diamond", IRIS, vec![]),
- vtrans("iris_round", "Iris Round", IRIS, vec![]),
- vtrans("push", "Push", SLIDE, vec![ch("direction", "Direction", DIR_OPTS, 3)]),
- vtrans("slide", "Slide", SLIDE, vec![ch("direction", "Direction", DIR_OPTS, 3)]),
- vtrans("split", "Split", SLIDE, vec![]),
- vtrans("center_split", "Center Split", SLIDE, vec![]),
- vtrans("band_slide", "Band Slide", SLIDE, vec![]),
- vtrans("whip", "Whip", SLIDE, vec![ch("direction", "Direction", DIR_OPTS, 3)]),
- vtrans("wipe", "Wipe", WIPE, vec![ch("direction", "Direction", DIR_OPTS, 3)]),
- vtrans("barn_doors", "Barn Doors", WIPE, vec![]),
- vtrans("clock_wipe", "Clock Wipe", WIPE, vec![]),
- vtrans("gradient_wipe", "Gradient Wipe", WIPE, vec![f("softness", "Softness", 10.0, 0.0, 100.0, "")]),
- vtrans("inset", "Inset", WIPE, vec![]),
- vtrans("radial_wipe", "Radial Wipe", WIPE, vec![]),
- vtrans("venetian_blinds", "Venetian Blinds", WIPE, vec![]),
- vtrans("checker_wipe", "Checker Wipe", WIPE, vec![]),
- vtrans("cross_zoom", "Cross Zoom", ZOOM, vec![]),
- vtrans("page_peel", "Page Peel", PAGE_PEEL, vec![]),
- vtrans("page_turn", "Page Turn", PAGE_PEEL, vec![]),
- vtrans("cube_spin", "Cube Spin", MOTION3D, vec![]),
- vtrans("flip_over", "Flip Over", MOTION3D, vec![]),
// ---- audio effects ----
- audio("amplify", "Amplify", A_AMP, vec![fs("gain", "Gain", 0.0, (-96.0, 48.0), (-24.0, 24.0), "dB", 1)]),
- audio(
- "dynamics",
- "Dynamics Processing",
- A_AMP,
- vec![
- fs("threshold", "Threshold", -20.0, (-60.0, 0.0), (-60.0, 0.0), "dB", 1),
- fs("ratio", "Ratio", 4.0, (1.0, 30.0), (1.0, 30.0), ":1", 1),
- fs("attack", "Attack", 10.0, (0.1, 500.0), (0.1, 500.0), "ms", 1),
- fs("release", "Release", 100.0, (1.0, 5000.0), (1.0, 5000.0), "ms", 0),
- ],
- ),
- audio(
- "hard_limiter",
- "Hard Limiter",
- A_AMP,
- vec![
- fs("max", "Maximum Amplitude", -0.1, (-30.0, 0.0), (-30.0, 0.0), "dB", 1),
- fs("boost", "Input Boost", 0.0, (-30.0, 30.0), (-30.0, 30.0), "dB", 1),
- fs("lookahead", "Look-Ahead Time", 7.0, (0.0, 30.0), (0.0, 30.0), "ms", 1),
- fs("release", "Release Time", 100.0, (1.0, 1000.0), (1.0, 1000.0), "ms", 0),
- ],
- ),
- audio("multiband_compressor", "Multiband Compressor", A_AMP, vec![]),
- audio("channel_mixer_a", "Channel Mixer", A_AMP, vec![]),
- audio(
- "delay",
- "Delay",
- A_DELAY,
- vec![
- fs("delay", "Delay", 1.0, (0.0, 2.0), (0.0, 2.0), "s", 2),
- f("feedback", "Feedback", 0.0, 0.0, 100.0, "%"),
- f("mix", "Mix", 50.0, 0.0, 100.0, "%"),
- ],
- ),
- audio("analog_delay", "Analog Delay", A_DELAY, vec![]),
- audio(
- "parametric_eq",
- "Parametric Equalizer",
- A_FILTER,
- vec![
- fs("low_freq", "Low Frequency", 100.0, (20.0, 20000.0), (20.0, 1000.0), "Hz", 0),
- fs("low_gain", "Low Gain", 0.0, (-24.0, 24.0), (-24.0, 24.0), "dB", 1),
- fs("mid_freq", "Mid Frequency", 1000.0, (20.0, 20000.0), (200.0, 8000.0), "Hz", 0),
- fs("mid_gain", "Mid Gain", 0.0, (-24.0, 24.0), (-24.0, 24.0), "dB", 1),
- fs("mid_q", "Mid Q", 1.0, (0.1, 20.0), (0.1, 10.0), "", 2),
- fs("high_freq", "High Frequency", 8000.0, (20.0, 20000.0), (2000.0, 20000.0), "Hz", 0),
- fs("high_gain", "High Gain", 0.0, (-24.0, 24.0), (-24.0, 24.0), "dB", 1),
- ],
- ),
- audio("highpass", "Highpass", A_FILTER, vec![fs("cutoff", "Cutoff", 80.0, (20.0, 20000.0), (20.0, 2000.0), "Hz", 0)]),
- audio("lowpass", "Lowpass", A_FILTER, vec![fs("cutoff", "Cutoff", 8000.0, (20.0, 20000.0), (500.0, 20000.0), "Hz", 0)]),
- audio(
- "bandpass",
- "Bandpass",
- A_FILTER,
- vec![fs("center", "Center", 1000.0, (20.0, 20000.0), (20.0, 20000.0), "Hz", 0), fs("q", "Q", 1.0, (0.1, 20.0), (0.1, 20.0), "", 2)],
- ),
- audio("notch", "Notch Filter", A_FILTER, vec![]),
- audio("simple_eq", "Simple Parametric EQ", A_FILTER, vec![]),
- audio("graphic_eq", "Graphic Equalizer (10 Bands)", A_FILTER, vec![]),
- audio("denoise", "DeNoise", A_NOISE, vec![f("amount", "Amount", 40.0, 0.0, 100.0, "%")]),
- audio("dehummer", "DeHummer", A_NOISE, vec![ch("freq", "Frequency", &["50 Hz", "60 Hz"], 1), f("gain", "Gain", -40.0, -80.0, 0.0, "dB")]),
- audio("declicker", "Automatic Click Remover", A_NOISE, vec![]),
- audio(
- "dereverb",
- "DeReverb",
- A_NOISE,
- vec![f("amount", "Amount", 50.0, 0.0, 100.0, "%"), fs("rt60", "Decay Time (RT60)", 0.8, (0.1, 5.0), (0.1, 3.0), "s", 2)],
- ),
- audio(
- "deesser",
- "DeEsser",
- A_AMP,
- vec![
- fs("frequency", "Frequency", 6000.0, (2000.0, 12000.0), (2000.0, 12000.0), "Hz", 0),
- fs("threshold", "Threshold", -12.0, (-40.0, 0.0), (-40.0, 0.0), "dB", 1),
- fs("reduction", "Maximum Reduction", 8.0, (0.0, 24.0), (0.0, 24.0), "dB", 1),
- ],
- ),
- audio("speech_enhance", "Enhance Speech", A_NOISE, vec![f("mix", "Mix", 100.0, 0.0, 100.0, "%"), ch("tone", "Voice", &["Low Tone", "High Tone"], 0)]),
- audio("stereo_width", "Stereo Width", A_STEREO, vec![fs("width", "Width", 100.0, (0.0, 200.0), (0.0, 200.0), "%", 0)]),
- audio(
- "studio_reverb",
- "Studio Reverb",
- A_REVERB,
- vec![
- f("room", "Room Size", 50.0, 0.0, 100.0, "%"),
- f("decay", "Decay", 50.0, 0.0, 100.0, "%"),
- f("damping", "High Frequency Damping", 50.0, 0.0, 100.0, "%"),
- f("dry", "Dry", 90.0, 0.0, 100.0, "%"),
- f("wet", "Wet", 35.0, 0.0, 100.0, "%"),
- ],
- ),
- audio("convolution_reverb", "Convolution Reverb", A_REVERB, vec![]),
- audio("surround_reverb", "Surround Reverb", A_REVERB, vec![]),
- audio("loudness_radar", "Loudness Meter", A_SPECIAL, vec![]),
- audio("invert_a", "Invert", A_SPECIAL, vec![]),
- audio(
- "pitch_shifter",
- "Pitch Shifter",
- A_TIME,
- vec![fs("semitones", "Semi-tones", 0.0, (-12.0, 12.0), (-12.0, 12.0), "", 0), fs("cents", "Cents", 0.0, (-100.0, 100.0), (-100.0, 100.0), "", 0)],
- ),
+ // (defined in effect/audio.rs; appended below)
EffectDef {
id: "constant_power",
name: "Constant Power",
@@@ -860,9 -922,7 +825,10 @@@
yuv: false,
},
];
+ v.extend(audio::defs());
+ v.extend(vfx::defs());
+ vfx::extend_core(&mut v);
+ v.extend(crate::vtransition::video_transition_defs());
v.extend(crate::graphic::layer_defs());
// YUV badge for the colour/intrinsic set
for e in &mut v {
diff --cc docs/testing.md
index 2f347da26,3dc69961a..80755447f
--- a/docs/testing.md
+++ b/docs/testing.md
@@@ -103,12 -101,17 +103,21 @@@ Each codec README has the full fixture
with `crates/golden/goldens/<scene>.png` by `filmcraft_testkit::golden`:
**PSNR ≥ 45 dB, max abs ≤ 12, 99th-percentile per-pixel max channel difference ≤ 2** (8-bit
sRGB levels; `Tolerance::RENDER`). On failure the actual frame and a ×8 difference image go to
- `<workspace>/target/golden-failures/`. `scenes_are_distinct` guards against blank or duplicate
+ `<workspace>/target/golden-failures/`. Six `vfx_*` scenes cover the M5.11 effects (Corner Pin over Turbulent
+ Displace, Ultra Key, Wonder Glow + Glint, Spacer + Stroke + Long Shadow over Gradient, VR Rotate Sphere,
+ Channel Mix + Color Emboss + Rounded Crop); per-effect unit tests live in `crates/render/src/vfx/tests.rs`
+ (identity at neutral parameters, determinism, range, a known value each, temporal/track effects through
+ the compositor). `scenes_are_distinct` guards against blank or duplicate
scenes.
+ - **Video transitions** (`crates/render/src/transitions/tests.rs`) are checked for every transition
+ (84 modern, 21 Legacy, 7 hidden Obsolete): p = 0 is exactly the outgoing frame and p = 1 exactly
+ the incoming one, near both ends the output is close to that frame (continuity), the midpoint differs
+ from both, the output is finite and deterministic (also on 1×1 / odd sizes and NaN progress), every
+ parameter visibly changes the picture, and every direction differs. Golden *fingerprints* (4×4 mean
+ RGB grid at p = 0.25/0.5/0.75, ±4 levels) live in `src/transitions/goldens.txt`; re-bless with
+ `FILMCRAFT_BLESS=1 cargo test -p filmcraft-render golden_fingerprints` and review the diff.
+ `FILMCRAFT_TRANSITION_SHEETS=<dir> cargo test -p filmcraft-render contact_sheets -- --ignored`
+ writes one contact-sheet PNG per folder for eyeballing (never commit them).
- **Blessing:** `FILMCRAFT_BLESS=1 cargo test -p filmcraft-golden` rewrites the references (and
writes a `.attribution` sidecar for any new one; it prints the `ATTRIBUTION.md` row to add).
References are original work rendered by FilmCraft, must stay under 50 KB (enforced on bless),