The truly free, open-source, local-first, cross-platform CapCut replacement. Scriptable through a JSON-RPC API & MCP.
Rust ffmpegfree-video-editormodel-context-protocolnon-linear-editoroffline-firstopen-source-video-editorself-hostedvideo-editingvideo-editing-automationvideo-editing-softwarevideo-editing-toolsvideo-editorvoice-cloningyoutube-automationyoutube-shorts
updates
Jareer3a14a4575284
diff --git a/.github/workflows/ffmpeg.yml b/.github/workflows/ffmpeg.ymlindex 23df4e46..fa4142f0 100644--- a/.github/workflows/ffmpeg.yml+++ b/.github/workflows/ffmpeg.yml@@ -97,6 +97,9 @@ jobs:--enable-bsf=h264_mp4toannexb,hevc_mp4toannexb,aac_adtstoasc \--enable-protocol=file,pipe \--enable-filter=scale,tile,fps,format,null,copy,setpts,trim,transpose,crop,overlay \+ --enable-filter=fade,hue,colorchannelmixer,negate,unsharp,gblur,boxblur,colortemperature \+ --enable-filter=vibrance,eq,vignette,noise,lutrgb,pixelize,lenscorrection \+ --enable-filter=split,blend,hstack,hflip \--enable-filter=aresample,asetrate,atempo,aformat,anull,atrim,asetpts,adelay,amix,apad,afade,volume \--enable-filter=highpass,lowpass,equalizer,bass,treble,compand,deesser,aecho,alimiter,aphaser,flanger \--enable-filter=abuffer,abuffersink,buffer,buffersinkdiff --git a/README.md b/README.mdindex dcd8f2f8..2d2a8a12 100644--- a/README.md+++ b/README.md@@ -34,14 +34,10 @@ start cutting, no account, no extra downloads, no setup.## π Get started-Grab a build from [Releases](https://github.com/jub0t/WolfCut/releases), or-build it yourself:--```sh-cd desktop-npm install-npm run app-```+The alpha is out β grab the installer for your platform from+[Releases](https://github.com/jub0t/WolfCut/releases): macOS (Apple Silicon+`.dmg`) and Windows (`.msi` / `.exe`), FFmpeg included, nothing else to+install.## π Growthdiff --git a/desktop/src-tauri/src/export.rs b/desktop/src-tauri/src/export.rsindex c2ea5c36..71f4eb45 100644--- a/desktop/src-tauri/src/export.rs+++ b/desktop/src-tauri/src/export.rs@@ -74,6 +74,19 @@ pub struct ExportClip {/// requests from a UI that predates it.#[serde(default = "unity")]pub opacity: f64,+ /// FFmpeg *video* filter chain from the Effects tab, or empty. Applied at+ /// decode, after scaling - see `DecodeOptions::filter_chain`.+ #[serde(default)]+ pub video_filter_chain: String,+ /// The transition into this clip's cut, when the UI put one there. The+ /// clip before it on the same track is found here, by adjacency - the UI+ /// only says what it wants, never how to overlap decoders.+ #[serde(default)]+ pub transition: Option<TransitionSpec>,+ /// Video opacity ramp up from the clip's start, in seconds. Set by+ /// transition resolution below, never by the UI directly.+ #[serde(default)]+ pub video_fade_in: f64,/// The source's pixel size, when the UI knows it. What makes an/// aspect-correct decode possible - absent, the frame is filled edge to/// edge the way it always was.@@ -83,6 +96,16 @@ pub struct ExportClip {pub media_height: Option<u32>,}+/// A transition on the cut into a clip.+#[derive(Deserialize, Clone)]+#[serde(rename_all = "camelCase")]+pub struct TransitionSpec {+ /// "cross-fade", "fade-black" or "fade-white". Anything else is ignored.+ pub kind: String,+ /// Seconds the transition covers.+ pub duration: f64,+}+fn yes() -> bool {true}@@ -150,6 +173,131 @@ pub fn run(render(&request, Reporter { progress: &mut progress, cancel })}+/// Turns per-cut transition requests into things the renderer already knows+/// how to draw: overlapping clips, opacity ramps, and fade filters.+///+/// Track indices are doubled first, so an incoming cross-fade clip gets an+/// odd lane of its own directly above the pair it dissolves over - stacking+/// against every other track is preserved, and nothing else occupies odd+/// lanes. Cuts are collected before anything mutates, so resolving one+/// transition cannot unhook the adjacency test of the next.+fn resolve_transitions(clips: &mut [ExportClip], rate: FrameRate) {+ for clip in clips.iter_mut() {+ clip.track *= 2;+ }++ let fps = rate.fps().as_f64();+ let frame = 1.0 / fps;++ struct Cut {+ incoming: usize,+ outgoing: usize,+ kind: String,+ duration: f64,+ }+ let mut cuts: Vec<Cut> = Vec::new();+ for (incoming, clip) in clips.iter().enumerate() {+ let Some(transition) = &clip.transition else { continue };+ if clip.hidden || (clip.kind != "video" && clip.kind != "image") {+ continue;+ }+ // The outgoing clip is whatever ends where this one starts, on the+ // same lane. No match - the cut was edited apart - means the+ // transition is silently orphaned, exactly like the UI treats it.+ let outgoing = clips.iter().position(|other| {+ !other.hidden+ && (other.kind == "video" || other.kind == "image")+ && other.track == clip.track+ && (other.start + other.duration - clip.start).abs() < frame / 2.0+ });+ match outgoing {+ Some(outgoing) if outgoing != incoming => cuts.push(Cut {+ incoming,+ outgoing,+ kind: transition.kind.clone(),+ duration: transition.duration.max(0.0),+ }),+ _ => {}+ }+ }++ for cut in cuts {+ match cut.kind.as_str() {+ "cross-fade" => {+ let (a_track, a_duration) = {+ let a = &clips[cut.outgoing];+ (a.track, a.duration)+ };+ let b = &mut clips[cut.incoming];++ // The incoming clip extends backwards over the outgoing one,+ // showing the source it has *before* its in-point - the+ // handle, exactly what a dissolve consumes in any editor. No+ // handle, shorter dissolve: the duration clamps to what+ // actually exists rather than freezing or inventing frames.+ let mut d = cut.duration.min(a_duration).min(b.duration);+ if b.kind != "image" {+ d = d.min(b.source_start / b.speed.max(0.0625));+ }+ if d < frame {+ continue;+ }+ b.start -= d;+ b.duration += d;+ if b.kind != "image" {+ b.source_start -= d * b.speed;+ }+ b.video_fade_in = d;+ // Sound rides the picture: the pre-roll fades in rather than+ // arriving at full level a dissolve early.+ b.fade_in = b.fade_in.max(d);+ b.track = a_track + 1;+ }+ "fade-black" | "fade-white" => {+ // Half the duration on each side of the cut, as fade filters+ // at decode. Frame-based, because the decoder emits exactly+ // one frame per output frame - so the fade lands on the same+ // frames the timeline arithmetic says it covers.+ let colour = if cut.kind == "fade-white" { ":color=white" } else { "" };+ let half = cut.duration / 2.0;+ {+ let a = &mut clips[cut.outgoing];+ let frames = ((half.min(a.duration) * fps).round() as i64).max(1);+ let total = (a.duration * fps).round() as i64;+ append_filter(+ &mut a.video_filter_chain,+ &format!(+ "fade=t=out:start_frame={}:nb_frames={frames}{colour}",+ (total - frames).max(0)+ ),+ );+ }+ {+ let b = &mut clips[cut.incoming];+ let frames = ((half.min(b.duration) * fps).round() as i64).max(1);+ append_filter(+ &mut b.video_filter_chain,+ &format!("fade=t=in:start_frame=0:nb_frames={frames}{colour}"),+ );+ }+ }+ // A kind this build does not know renders as a plain cut rather+ // than failing the export - the same degrade a missing effect+ // filter must NOT get, because there the user styled the picture.+ _ => {}+ }+ }+}++/// Appends one filter to a chain, comma-separated. Effects the user stacked+/// come first; a transition fades the styled picture, not the raw one.+fn append_filter(chain: &mut String, filter: &str) {+ if !chain.is_empty() {+ chain.push(',');+ }+ chain.push_str(filter);+}+/// Renders `request` and returns the path written.pub fn render(request: &ExportRequest, mut reporter: Reporter<'_>) -> Result<String, String> {if request.clips.is_empty() {@@ -159,15 +307,19 @@ pub fn render(request: &ExportRequest, mut reporter: Reporter<'_>) -> Result<Strlet rate = FrameRate::new(Rational::new(request.rate_num, request.rate_den));let output = PathBuf::from(&request.output);+ // Transitions become overlaps, ramps and fade filters before anything+ // else reads the clip list, so the picture and sound paths below never+ // know transitions exist.+ let mut resolved = request.clips.clone();+ resolve_transitions(&mut resolved, rate);+// Stills composite exactly like footage; they only differ in how they are// decoded, which is handled where the decoder is opened.- let visible: Vec<&ExportClip> = request- .clips+ let visible: Vec<&ExportClip> = resolved.iter().filter(|clip| (clip.kind == "video" || clip.kind == "image") && !clip.hidden).collect();- let audible: Vec<&ExportClip> = request- .clips+ let audible: Vec<&ExportClip> = resolved.iter().filter(|clip| clip.kind == "audio" && !clip.muted).collect();@@ -176,8 +328,7 @@ pub fn render(request: &ExportRequest, mut reporter: Reporter<'_>) -> Result<Str// contributes to the mix as well as to the picture.let mut sound: Vec<&ExportClip> = audible;sound.extend(- request- .clips+ resolved.iter().filter(|clip| clip.kind == "video" && !clip.muted),);@@ -193,8 +344,7 @@ pub fn render(request: &ExportRequest, mut reporter: Reporter<'_>) -> Result<Str})});- let timeline_end = request- .clips+ let timeline_end = resolved.iter().map(|clip| clip.start + clip.duration).fold(0.0f64, f64::max);@@ -270,7 +420,7 @@ fn render_picture(destination: &Path,reporter: &mut Reporter<'_>,) -> Result<(), String> {- let (timeline, stills, decode_sizes) = build_timeline(request, rate, visible);+ let (timeline, stills, decode_sizes, filter_chains) = build_timeline(request, rate, visible);let mut encoder = FfmpegEncoder::create(destination,@@ -329,6 +479,13 @@ fn render_picture(.scaled_to(decode_width, decode_height).at_rate(decode_rate);+ // Effects and transition fades, as one FFmpeg chain. The+ // decoder guards the frame size after it, so an effect+ // that resizes cannot shear the pipe.+ if let Some(chain) = filter_chains.get(&layer.clip) {+ options = options.filtered(chain.clone());+ }+// A still is a one-frame stream. Without looping it would// contribute a single frame and then disappear.if stills.contains(&layer.clip) {@@ -403,10 +560,12 @@ fn build_timeline(Timeline,std::collections::HashSet<ClipId>,HashMap<ClipId, (u32, u32)>,+ HashMap<ClipId, String>,) {let mut timeline = Timeline::new(request.width, request.height, rate);let mut stills = std::collections::HashSet::new();let mut decode_sizes: HashMap<ClipId, (u32, u32)> = HashMap::new();+ let mut filter_chains: HashMap<ClipId, String> = HashMap::new();let lanes = visible.iter().map(|clip| clip.track).max().unwrap_or(0) + 1;let tracks: Vec<_> = (0..lanes)@@ -438,6 +597,9 @@ fn build_timeline(rotation: clip.rotation,};engine_clip.opacity = clip.opacity.clamp(0.0, 1.0) as f32;+ // Quantised like every other time: the ramp must land on the same+ // frame grid the overlap does, or the dissolve ends a frame early.+ engine_clip.video_fade_in = quantise(clip.video_fade_in, rate);if let Some(id) = timeline.add_clip(tracks[clip.track], engine_clip) {if clip.kind == "image" {@@ -446,10 +608,13 @@ fn build_timeline(if let Some(size) = fitted_size(request, clip) {decode_sizes.insert(id, size);}+ if !clip.video_filter_chain.is_empty() {+ filter_chains.insert(id, clip.video_filter_chain.clone());+ }}}- (timeline, stills, decode_sizes)+ (timeline, stills, decode_sizes, filter_chains)}/// The source's contain-fitted size inside the output frame, or `None` when@@ -470,3 +635,139 @@ fn fitted_size(request: &ExportRequest, clip: &ExportClip) -> Option<(u32, u32)>fn quantise(seconds: f64, rate: FrameRate) -> Rational {rate.time_of_frame((seconds * rate.fps().as_f64()).round().max(0.0) as i64)}++#[cfg(test)]+mod tests {+ use super::*;++ fn clip(kind: &str, track: usize, start: f64, duration: f64, source_start: f64) -> ExportClip {+ ExportClip {+ path: format!("{kind}.mp4"),+ kind: kind.to_owned(),+ start,+ duration,+ source_start,+ track,+ hidden: false,+ muted: false,+ volume: 1.0,+ fade_in: 0.0,+ fade_out: 0.0,+ filter_chain: String::new(),+ speed: 1.0,+ preserve_pitch: true,+ scale: 1.0,+ offset_x: 0.0,+ offset_y: 0.0,+ rotation: 0.0,+ opacity: 1.0,+ video_filter_chain: String::new(),+ transition: None,+ video_fade_in: 0.0,+ media_width: None,+ media_height: None,+ }+ }++ fn spec(kind: &str, duration: f64) -> Option<TransitionSpec> {+ Some(TransitionSpec { kind: kind.to_owned(), duration })+ }++ #[test]+ fn a_cross_fade_overlaps_the_incoming_clip_on_its_own_lane() {+ let mut clips = vec![clip("video", 0, 0.0, 4.0, 0.0), clip("video", 0, 4.0, 4.0, 2.0)];+ clips[1].transition = spec("cross-fade", 1.0);+ resolve_transitions(&mut clips, FrameRate::THIRTY);++ let b = &clips[1];+ assert_eq!(b.start, 3.0, "extends backwards over the cut");+ assert_eq!(b.duration, 5.0);+ assert_eq!(b.source_start, 1.0, "consumes the handle before the in-point");+ assert_eq!(b.video_fade_in, 1.0);+ assert_eq!(b.fade_in, 1.0, "sound rides the picture");+ assert_eq!(clips[0].track, 0, "outgoing stays on its doubled lane");+ assert_eq!(b.track, 1, "incoming sits directly above it");+ }++ #[test]+ fn a_cross_fade_clamps_to_the_available_handle() {+ let mut clips = vec![clip("video", 0, 0.0, 4.0, 0.0), clip("video", 0, 4.0, 4.0, 0.25)];+ clips[1].transition = spec("cross-fade", 2.0);+ resolve_transitions(&mut clips, FrameRate::THIRTY);++ // Only a quarter second of source exists before the in-point, so that+ // is the whole dissolve.+ assert_eq!(clips[1].video_fade_in, 0.25);+ assert_eq!(clips[1].source_start, 0.0);+ assert_eq!(clips[1].start, 3.75);+ }++ #[test]+ fn a_still_needs_no_handle_to_dissolve() {+ let mut clips = vec![clip("video", 0, 0.0, 4.0, 0.0), clip("image", 0, 4.0, 4.0, 0.0)];+ clips[1].transition = spec("cross-fade", 1.0);+ resolve_transitions(&mut clips, FrameRate::THIRTY);+ assert_eq!(clips[1].video_fade_in, 1.0);+ assert_eq!(clips[1].source_start, 0.0, "a still has no source clock to rewind");+ }++ #[test]+ fn a_fade_to_black_splits_across_the_cut_as_fade_filters() {+ let mut clips = vec![clip("video", 0, 0.0, 4.0, 0.0), clip("video", 0, 4.0, 4.0, 0.0)];+ clips[1].transition = spec("fade-black", 1.0);+ resolve_transitions(&mut clips, FrameRate::THIRTY);++ // Half a second each side at 30fps is 15 frames.+ assert_eq!(clips[0].video_filter_chain, "fade=t=out:start_frame=105:nb_frames=15");+ assert_eq!(clips[1].video_filter_chain, "fade=t=in:start_frame=0:nb_frames=15");+ assert_eq!(clips[1].start, 4.0, "nothing moves for an edge fade");+ }++ #[test]+ fn a_fade_to_white_names_its_colour() {+ let mut clips = vec![clip("video", 0, 0.0, 2.0, 0.0), clip("video", 0, 2.0, 2.0, 0.0)];+ clips[1].transition = spec("fade-white", 0.5);+ resolve_transitions(&mut clips, FrameRate::THIRTY);+ assert!(clips[0].video_filter_chain.ends_with(":color=white"));+ assert!(clips[1].video_filter_chain.contains("t=in"));+ }++ #[test]+ fn transition_fades_append_after_the_clips_own_effects() {+ let mut clips = vec![clip("video", 0, 0.0, 2.0, 0.0), clip("video", 0, 2.0, 2.0, 0.0)];+ clips[1].video_filter_chain = "hue=s=0".to_owned();+ clips[1].transition = spec("fade-black", 0.5);+ resolve_transitions(&mut clips, FrameRate::THIRTY);+ assert!(+ clips[1].video_filter_chain.starts_with("hue=s=0,fade=t=in"),+ "was: {}",+ clips[1].video_filter_chain+ );+ }++ #[test]+ fn a_transition_with_no_adjacent_clip_is_orphaned_not_fatal() {+ let mut clips = vec![clip("video", 0, 0.0, 2.0, 0.0), clip("video", 0, 5.0, 2.0, 0.0)];+ clips[1].transition = spec("cross-fade", 1.0);+ resolve_transitions(&mut clips, FrameRate::THIRTY);+ assert_eq!(clips[1].start, 5.0);+ assert_eq!(clips[1].video_fade_in, 0.0);+ }++ #[test]+ fn track_indices_are_doubled_for_everyone() {+ let mut clips = vec![clip("video", 0, 0.0, 2.0, 0.0), clip("audio", 3, 0.0, 2.0, 0.0)];+ resolve_transitions(&mut clips, FrameRate::THIRTY);+ assert_eq!(clips[0].track, 0);+ assert_eq!(clips[1].track, 6);+ }++ #[test]+ fn an_unknown_transition_kind_renders_as_a_plain_cut() {+ let mut clips = vec![clip("video", 0, 0.0, 2.0, 0.0), clip("video", 0, 2.0, 2.0, 0.0)];+ clips[1].transition = spec("wipe-left", 1.0);+ resolve_transitions(&mut clips, FrameRate::THIRTY);+ assert_eq!(clips[1].start, 2.0);+ assert!(clips[1].video_filter_chain.is_empty());+ }+}diff --git a/desktop/src-tauri/src/lib.rs b/desktop/src-tauri/src/lib.rsindex e4170f38..72b81190 100644--- a/desktop/src-tauri/src/lib.rs+++ b/desktop/src-tauri/src/lib.rs@@ -244,6 +244,102 @@ fn filmstrip(path: &str, count: u32, height: u32) -> Result<Vec<u8>, String> {Ok(output.stdout)}+/// A small poster frame for one project, for the launch screen's recents.+///+/// Grabbed from the earliest visible clip of the project's active timeline+/// and cached as `cache/preview.jpg` in the project folder; the cache is+/// fresh as long as it is newer than `relay.json`, so an edited project gets+/// a new poster on its next appearance and an untouched one costs a stat.+#[tauri::command]+async fn project_preview(path: String) -> Result<tauri::ipc::Response, String> {+ tauri::async_runtime::spawn_blocking(move || poster_frame(&path))+ .await+ .map_err(|error| format!("preview task failed: {error}"))?+ .map(tauri::ipc::Response::new)+}++fn poster_frame(project: &str) -> Result<Vec<u8>, String> {+ let root = std::path::Path::new(project);+ let manifest = root.join("relay.json");+ let cached = root.join("cache").join("preview.jpg");++ let fresh = match (std::fs::metadata(&cached), std::fs::metadata(&manifest)) {+ (Ok(cache), Ok(source)) => match (cache.modified(), source.modified()) {+ (Ok(cache), Ok(source)) => cache >= source,+ _ => false,+ },+ _ => false,+ };+ if fresh {+ if let Ok(bytes) = std::fs::read(&cached) {+ return Ok(bytes);+ }+ }++ let text = std::fs::read_to_string(&manifest)+ .map_err(|error| format!("could not read {}: {error}", manifest.display()))?;+ let document: serde_json::Value =+ serde_json::from_str(&text).map_err(|error| format!("not a project: {error}"))?;++ // The flat top-level clips are the active timeline - exactly the frame+ // the user last saw. The earliest clip with a picture is the poster.+ let clips = document.get("clips").and_then(|value| value.as_array());+ let media = document.get("media").and_then(|value| value.as_array());+ let (clips, media) = match (clips, media) {+ (Some(clips), Some(media)) => (clips, media),+ _ => return Err("the project has no timeline to preview".to_owned()),+ };++ let mut poster: Option<(f64, String, f64, bool)> = None;+ for clip in clips {+ let kind = clip.get("kind").and_then(|value| value.as_str()).unwrap_or("");+ if kind != "video" && kind != "image" {+ continue;+ }+ let start = clip.get("start").and_then(|value| value.as_f64()).unwrap_or(0.0);+ if poster.as_ref().is_some_and(|(best, ..)| *best <= start) {+ continue;+ }+ let media_id = clip.get("mediaId").and_then(|value| value.as_str()).unwrap_or("");+ let Some(path) = media.iter().find_map(|item| {+ (item.get("id").and_then(|value| value.as_str()) == Some(media_id))+ .then(|| item.get("path").and_then(|value| value.as_str()))+ .flatten()+ }) else {+ continue;+ };+ let source_start = clip.get("sourceStart").and_then(|value| value.as_f64()).unwrap_or(0.0);+ poster = Some((start, path.to_owned(), source_start, kind == "image"));+ }++ let Some((_, media_path, source_start, is_still)) = poster else {+ return Err("nothing on the timeline to preview".to_owned());+ };++ let mut command = std::process::Command::new(relay_media::ffmpeg());+ command.args(["-hide_banner", "-nostdin", "-loglevel", "error"]);+ // Seeking a still means seeking a one-frame stream to nowhere.+ if !is_still && source_start > 0.0 {+ command.args(["-ss", &format!("{source_start:.3}")]);+ }+ let output = command+ .args(["-i", &media_path])+ .args(["-frames:v", "1", "-vf", "scale=480:-2", "-q:v", "4", "-f", "mjpeg", "pipe:1"])+ .output()+ .map_err(|error| format!("could not run ffmpeg: {error}"))?;++ if !output.status.success() || output.stdout.is_empty() {+ return Err(format!("no poster frame for {media_path}"));+ }++ // Best effort: a failed cache write only means regenerating next launch.+ if let Some(parent) = cached.parent() {+ let _ = std::fs::create_dir_all(parent);+ let _ = std::fs::write(&cached, &output.stdout);+ }+ Ok(output.stdout)+}+/// The audible clip set, replaced wholesale whenever the timeline changes.////// Decoding, mixing and the playback clock all live in the engine - see@@ -468,6 +564,7 @@ pub fn run() {write_artwork,create_project,open_project,+ project_preview,save_project,load_project,recent_projects,diff --git a/desktop/src/App.tsx b/desktop/src/App.tsxindex 65e4a61b..05c9e0a8 100644--- a/desktop/src/App.tsx+++ b/desktop/src/App.tsx@@ -71,6 +71,11 @@ import {type TimelineMeta,} from "./lib/project";import { buildChain } from "./lib/filters";+import {+ buildEffectChain,+ findTransition,+} from "./lib/effects";+import { precedingClip } from "./lib/project";import { familyForPath, registerFont } from "./lib/text";import { fromDocument, toDocument } from "./lib/persist";import { useTheme, type Theme } from "./lib/theme";@@ -275,6 +280,79 @@ function Editor({});}, []);+ // ββ effects and transitions ββββββββββββββββββββββββββββββββββββββββββββββ++ /**+ * Applies one effect from the bin's Effects page to the selected clip.+ *+ * The card is clickable whatever is selected, so the misses have to explain+ * themselves: no selection, or a selection that has no picture, each get a+ * toast saying what to do instead of nothing happening.+ */+ const applyEffect = useCallback((effectId: string) => {+ const current = latest.current.project;+ const selected = selectedClipIds.length === 1 ? findClip(current, selectedClipIds[0]) : null;+ if (!selected || (selected.kind !== "video" && selected.kind !== "image")) {+ setToast({+ id: Date.now(),+ message: "Select a video or image clip on the timeline first",+ failed: true,+ });+ return;+ }+ setProject((project) =>+ updateClip(project, selected.id, {+ videoEffects: [...selected.videoEffects, { id: effectId, params: {} }],+ }),+ );+ setRightTab("effects");+ }, [selectedClipIds]);++ /**+ * Puts a transition on the selected clip's cut.+ *+ * A transition needs a cut: a clip ending exactly where the selected one+ * starts. Without one there is nothing to dissolve across, and saying so+ * beats silently attaching a transition that renders as nothing.+ */+ const applyTransition = useCallback(+ (transitionId: string) => {+ const definition = findTransition(transitionId);+ if (!definition?.implemented) return;++ const current = latest.current.project;+ const selected = selectedClipIds.length === 1 ? findClip(current, selectedClipIds[0]) : null;+ if (!selected || (selected.kind !== "video" && selected.kind !== "image")) {+ setToast({+ id: Date.now(),+ message: "Select the incoming clip - the one after the cut - first",+ failed: true,+ });+ return;+ }+ if (!precedingClip(current, selected.id)) {+ setToast({+ id: Date.now(),+ message: "No clip ends where this one starts - transitions need a cut",+ failed: true,+ });+ return;+ }+ setProject((project) =>+ updateClip(project, selected.id, {+ transitionIn: { id: transitionId, duration: definition.defaultDuration },+ }),+ );+ setRightTab("effects");+ setToast({+ id: Date.now(),+ message: `${definition.label} added to the cut`,+ failed: false,+ });+ },+ [selectedClipIds],+ );+// ββ timelines ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ// The timeline awaiting delete confirmation, if any. Deleting throws away// every clip on it and there is no undo, hence the prompt.@@ -476,15 +554,19 @@ function Editor({/*** The audio/video tools dropdown in the timeline tray.*- * The same operations the clip context menu offers, but discoverable: a- * right-click menu only teaches people who already right-click. Items are- * disabled rather than hidden, so the tool's existence does not depend on- * what happens to be selected.+ * Shown only while a clip that can carry sound is selected - a title has no+ * audio to detach or transcribe, and offering the menu anyway would be a+ * drawer of permanently grey items. Within an eligible selection, items are+ * still disabled rather than hidden, so what the tool *could* do stays+ * visible.*/const clipTools = useMemo(() => {const clip = selectedClipIds.length === 1 ? findClip(project, selectedClipIds[0]) : null;const media = clip ? findMedia(project, clip.mediaId) : null;+ // No sound-capable clip, no menu: the panel hides the whole dropdown.+ if (!clip || (clip.kind !== "video" && clip.kind !== "audio")) return [];+const hasSound = Boolean(clip && (clip.kind === "video" || clip.kind === "audio") && media?.hasAudio,);@@ -968,6 +1050,14 @@ function Editor({offsetY: clip.offsetY,rotation: clip.rotation,opacity: clip.opacity,+ videoFilterChain: buildEffectChain(clip.videoEffects) ?? "",+ // The transition rides along only while its cut still exists;+ // the host would orphan it anyway, but not sending it keeps the+ // request honest about what will render.+ transition:+ clip.transitionIn && precedingClip(project, clip.id)+ ? { kind: clip.transitionIn.id, duration: clip.transitionIn.duration }+ : null,mediaWidth: media.width,mediaHeight: media.height,},@@ -976,6 +1066,65 @@ function Editor({[project],);+ /**+ * A cross-fade window the playhead currently sits inside: the incoming+ * clip's pre-roll, faded in over the outgoing picture. This is the same+ * overlap the export builds - the ghost plays the handle before the+ * incoming clip's in-point, ramping from zero to solid at the cut.+ */+ const previewGhost = useMemo(() => {+ for (const clip of project.clips) {+ const transition = clip.transitionIn;+ if (!transition || transition.id !== "cross-fade") continue;+ if (clip.kind !== "video" && clip.kind !== "image") continue;+ if (!precedingClip(project, clip.id)) continue;++ // The dissolve clamps to the source handle, like the export does.+ const handle = clip.kind === "image" ? Infinity : clip.sourceStart / Math.max(0.0625, clip.speed);+ const d = Math.min(transition.duration, handle);+ const cut = clip.start;+ if (d <= 0 || playhead < cut - d || playhead >= cut) continue;++ const media = findMedia(project, clip.mediaId);+ if (!media) continue;+ return {+ clipId: clip.id,+ path: media.path,+ time: Math.max(0, clip.sourceStart - (cut - playhead) * clip.speed),+ speed: clip.speed,+ opacity: 1 - (cut - playhead) / d,+ };+ }+ return null;+ }, [project, playhead]);++ /**+ * The fade-to-colour wash over the monitor while the playhead crosses a+ * fade-black/white transition. Mirrors the exporter's shape exactly: half+ * the duration out on the old clip, half in on the new one, meeting fully+ * opaque at the cut.+ */+ const previewVeil = useMemo(() => {+ for (const clip of project.clips) {+ const transition = clip.transitionIn;+ if (!transition) continue;+ if (transition.id !== "fade-black" && transition.id !== "fade-white") continue;+ if (!precedingClip(project, clip.id)) continue;++ const half = transition.duration / 2;+ const cut = clip.start;+ if (playhead < cut - half || playhead > cut + half) continue;++ const opacity =+ playhead <= cut ? (playhead - (cut - half)) / half : (cut + half - playhead) / half;+ return {+ color: transition.id === "fade-white" ? "#ffffff" : "#000000",+ opacity: Math.min(1, Math.max(0, opacity)),+ };+ }+ return null;+ }, [project, playhead]);+// Titles for the exporter. They have no file to hand over - the dialog// rasterises them into full-frame PNGs at export time - so all it needs is// the style and where the clip sits. Hidden tracks drop out here, the same@@ -1161,6 +1310,8 @@ function Editor({onDismissError={() => setError(null)}onBeginDrag={beginMediaDrag}onAddToTimeline={addToTimeline}+ onApplyEffect={applyEffect}+ onApplyTransition={applyTransition}/></div>@@ -1191,6 +1342,9 @@ function Editor({: null}opacity={previewClip?.opacity ?? 1}+ effects={previewClip?.videoEffects ?? null}+ ghost={previewGhost}+ veil={previewVeil}mediaSize={previewMedia && previewMedia.width && previewMedia.height? { width: previewMedia.width, height: previewMedia.height }diff --git a/desktop/src/components/EffectsPanel.tsx b/desktop/src/components/EffectsPanel.tsxnew file mode 100644index 00000000..1e7872b3--- /dev/null+++ b/desktop/src/components/EffectsPanel.tsx@@ -0,0 +1,205 @@+import {+ EFFECTS,+ findEffect,+ findTransition,+ resolveEffectParams,+ type AppliedEffect,+ type ClipTransition,+} from "../lib/effects";+import type { Clip } from "../lib/project";+import { HelpTip, Slider } from "./controls";+import { Icon, IconButton } from "./Icon";+import { Empty } from "./Panel";++/**+ * The Effects tab: the video sibling of the Filters tab.+ *+ * Effects are a list on the clip, applied in order, each with its own+ * parameters, bypass and remove - the exact shape FiltersPanel gives audio,+ * because the two are the same idea pointed at different senses. The browsing+ * library lives in the bin's Effects page; this panel manages what is already+ * on the clip, plus the transition on its cut.+ */+export function EffectsPanel({+ clip,+ hasPreceding,+ onChangeEffects,+ onChangeTransition,+}: {+ clip: Clip | null;+ /** Whether a clip ends where this one starts - what a transition needs. */+ hasPreceding: boolean;+ onChangeEffects: (effects: AppliedEffect[]) => void;+ onChangeTransition: (transition: ClipTransition | undefined) => void;+}) {+ if (!clip || (clip.kind !== "video" && clip.kind !== "image")) {+ return (+ <Empty icon={<Icon name="sparkles" size={26} strokeWidth={1.5} />}>+ Select a video or image clip to add effects.+ </Empty>+ );+ }++ const applied = clip.videoEffects;+ const transition = clip.transitionIn;+ const transitionDefinition = transition ? findTransition(transition.id) : null;++ const add = (id: string) => onChangeEffects([...applied, { id, params: {} }]);+ const remove = (index: number) => onChangeEffects(applied.filter((_, at) => at !== index));+ const patch = (index: number, change: Partial<AppliedEffect>) =>+ onChangeEffects(applied.map((effect, at) => (at === index ? { ...effect, ...change } : effect)));+ const setParam = (index: number, key: string, value: number) =>+ patch(index, { params: { ...applied[index].params, [key]: value } });+ const move = (index: number, by: number) => {+ const target = index + by;+ if (target < 0 || target >= applied.length) return;+ const next = [...applied];+ [next[index], next[target]] = [next[target], next[index]];+ onChangeEffects(next);+ };++ return (+ <div className="px-3 py-3">+ {transition && transitionDefinition && (+ <section className="mb-5">+ <h3 className="mb-2 flex items-center gap-1.5 text-[11px] font-semibold uppercase tracking-wider text-tertiary">+ Transition+ <HelpTip text="The transition on the cut into this clip. It needs the clip before it to stay touching - moved apart, it renders as a plain cut." />+ </h3>+ <div className="rounded-lg bg-sunken p-2.5">+ <div className="mb-2 flex items-center gap-1">+ <span className="min-w-0 flex-1 truncate text-xs text-primary">+ {transitionDefinition.label}+ </span>+ <IconButton+ icon="close"+ label={`Remove ${transitionDefinition.label}`}+ size={7}+ tone="danger"+ onClick={() => onChangeTransition(undefined)}+ />+ </div>+ {!hasPreceding && (+ <p className="mb-2 text-[11px] leading-snug text-danger">+ No clip ends where this one starts, so this transition currently renders as a+ plain cut.+ </p>+ )}+ <Slider+ label="Duration"+ value={transition.duration}+ min={0.2}+ max={3}+ step={0.1}+ format={(value) => `${value.toFixed(1)}s`}+ onReset={() =>+ onChangeTransition({ ...transition, duration: transitionDefinition.defaultDuration })+ }+ onChange={(value) => onChangeTransition({ ...transition, duration: value })}+ />+ </div>+ </section>+ )}++ {applied.length > 0 && (+ <section className="mb-5">+ <h3 className="mb-2 flex items-center gap-1.5 text-[11px] font-semibold uppercase tracking-wider text-tertiary">+ Applied+ <HelpTip text="Effects run top to bottom. The eye bypasses one without losing its settings - flick it to compare." />+ </h3>++ <ul className="flex flex-col gap-2">+ {applied.map((entry, index) => {+ const definition = findEffect(entry.id);+ if (!definition) return null;+ const values = resolveEffectParams(definition, entry.params);+ const active = entry.enabled !== false;++ return (+ <li key={`${entry.id}-${index}`} className="rounded-lg bg-sunken p-2.5">+ <div className="mb-2 flex items-center gap-1">+ <span+ className={`min-w-0 flex-1 truncate text-xs ${+ active ? "text-primary" : "text-tertiary line-through"+ }`}+ >+ {definition.label}+ </span>+ <IconButton+ icon={active ? "eye" : "eyeOff"}+ label={active ? `Bypass ${definition.label}` : `Enable ${definition.label}`}+ size={7}+ onClick={() => patch(index, { enabled: !active })}+ />+ <IconButton+ icon="chevronUp"+ label="Move earlier in the chain"+ size={7}+ disabled={index === 0}+ onClick={() => move(index, -1)}+ />+ <IconButton+ icon="chevronDown"+ label="Move later in the chain"+ size={7}+ disabled={index === applied.length - 1}+ onClick={() => move(index, 1)}+ />+ <IconButton+ icon="close"+ label={`Remove ${definition.label}`}+ size={7}+ tone="danger"+ onClick={() => remove(index)}+ />+ </div>++ {/* Dimmed but still editable while bypassed, so a setting+ can be dialled in before the effect is switched on. */}+ <div className={active ? "" : "opacity-50"}>+ {definition.params.map((param) => (+ <Slider+ key={param.key}+ label={param.label}+ value={values[param.key]}+ min={param.min}+ max={param.max}+ step={param.step}+ format={param.format}+ onReset={() => setParam(index, param.key, param.default)}+ onChange={(value) => setParam(index, param.key, value)}+ />+ ))}+ {definition.params.length === 0 && (+ <p className="text-[11px] text-tertiary">Nothing to adjust.</p>+ )}+ </div>+ </li>+ );+ })}+ </ul>+ </section>+ )}++ <h3 className="mb-2 text-[11px] font-semibold uppercase tracking-wider text-tertiary">+ Add an effect+ </h3>+ <ul className="flex flex-col gap-0.5">+ {EFFECTS.map((effect) => (+ <li key={effect.id}>+ <button+ type="button"+ onClick={() => add(effect.id)}+ title={effect.blurb}+ className="flex w-full cursor-pointer items-center gap-2 rounded-lg px-2 py-1.5+ text-left transition-colors hover:bg-hover"+ >+ <Icon name="plus" size={12} className="shrink-0 text-tertiary" />+ <span className="min-w-0 flex-1 truncate text-xs text-primary">{effect.label}</span>+ </button>+ </li>+ ))}+ </ul>+ </div>+ );+}diff --git a/desktop/src/components/ExportDialog.tsx b/desktop/src/components/ExportDialog.tsxindex dae14c2d..d63ac229 100644--- a/desktop/src/components/ExportDialog.tsx+++ b/desktop/src/components/ExportDialog.tsx@@ -67,6 +67,8 @@ function overlayClip(title: ExportTitle, path: string): ExportClip {rotation: 0,// Solid: a title's own transparency is baked into its rasterised PNG.opacity: 1,+ videoFilterChain: "",+ transition: null,mediaWidth: null,mediaHeight: null,};diff --git a/desktop/src/components/Icon.tsx b/desktop/src/components/Icon.tsxindex d5a52b6a..c1d9f30d 100644--- a/desktop/src/components/Icon.tsx+++ b/desktop/src/components/Icon.tsx@@ -350,8 +350,9 @@ export function IconButton({? "text-success hover:bg-hover": "text-primary hover:bg-hover";- const on =- tone === "go" ? "bg-success text-on-accent" : "bg-tool-active-bg text-tool-active";+ // Active is the one lime everywhere - including the transport's play+ // button, which used to fill green and read as a different system.+ const on = "bg-tool-active-bg text-tool-active";return (<buttondiff --git a/desktop/src/components/MediaBin.tsx b/desktop/src/components/MediaBin.tsxindex 39a1d915..dc3548bc 100644--- a/desktop/src/components/MediaBin.tsx+++ b/desktop/src/components/MediaBin.tsx@@ -70,6 +70,8 @@ export function MediaBin({onDismissError,onBeginDrag,onAddToTimeline,+ onApplyEffect,+ onApplyTransition,assets,dropping,}: {@@ -92,6 +94,10 @@ export function MediaBin({/** Called once the pointer has moved far enough to count as a drag. */onBeginDrag: (item: MediaItem, clientX: number, clientY: number) => void;onAddToTimeline: (mediaId: string) => void;+ /** Applies an effect to the selected clip; the app validates and explains. */+ onApplyEffect: (effectId: string) => void;+ /** Puts a transition on the selected clip's cut; the app validates. */+ onApplyTransition: (transitionId: string) => void;}) {const [tab, setTab] = useState<LibraryTab>("media");const [effectCategory, setEffectCategory] = useState<EffectCategory>("basic");@@ -181,8 +187,10 @@ export function MediaBin({/>)}{tab === "text" && <TextPage onAddText={onAddText} />}- {tab === "transitions" && <TransitionsPage category={transitionCategory} />}- {tab === "effects" && <EffectsPage category={effectCategory} />}+ {tab === "transitions" && (+ <TransitionsPage category={transitionCategory} onApply={onApplyTransition} />+ )}+ {tab === "effects" && <EffectsPage category={effectCategory} onApply={onApplyEffect} />}</div></div></div>@@ -510,46 +518,73 @@ function TextPage({ onAddText }: { onAddText: () => void }) {// ββ the transitions and effects pages ββββββββββββββββββββββββββββββββββββββββ/**- * A catalogue card that cannot be used yet.- *- * The "Soon" badge is the honest version of a disabled drag: the catalogue is- * browsable so the library's shape is settled, but nothing pretends to work- * before the engine can render it.+ * A catalogue card. Clickable when the thing it offers actually works;+ * otherwise the "Soon" badge stays - the honest version of a disabled drag,+ * kept for the motion transitions the engine cannot animate yet.*/function CatalogueCard({label,blurb,+ onApply,children,}: {label: string;blurb: string;+ /** Absent means not implemented yet - the card browses but does nothing. */+ onApply?: () => void;children: ReactNode;}) {return (- <li title={`${label}\n${blurb}\nNot available yet`} className="select-none">+ <li+ title={`${label}\n${blurb}\n${onApply ? "Click to apply to the selected clip" : "Not available yet"}`}+ onClick={onApply}+ className={`group select-none ${onApply ? "cursor-pointer" : ""}`}+ ><div- className="relative flex aspect-video items-center justify-center overflow-hidden- rounded-lg bg-sunken ring-1 ring-hairline"+ className={`relative flex aspect-video items-center justify-center overflow-hidden+ rounded-lg bg-sunken ring-1 ring-hairline ${+ onApply ? "transition-shadow group-hover:ring-hairline-strong" : ""+ }`}>{children}- <span- className="absolute bottom-1 right-1 rounded bg-black/55 px-1 py-px font-technical- text-[10px] text-white"- >- Soon- </span>+ {onApply ? (+ <span+ className="invisible absolute bottom-1 right-1 flex h-5 w-5 items-center+ justify-center rounded bg-black/55 text-white group-hover:visible"+ >+ <Icon name="plus" size={11} />+ </span>+ ) : (+ <span+ className="absolute bottom-1 right-1 rounded bg-black/55 px-1 py-px font-technical+ text-[10px] text-white"+ >+ Soon+ </span>+ )}</div><span className="mt-1 block truncate text-[11px] leading-tight text-secondary">{label}</span></li>);}-function TransitionsPage({ category }: { category: TransitionCategory }) {+function TransitionsPage({+ category,+ onApply,+}: {+ category: TransitionCategory;+ onApply: (transitionId: string) => void;+}) {const visible = TRANSITIONS.filter((transition) => transition.category === category);return (<ul className={`${CARD_GRID} pt-2`}>{visible.map((transition) => (- <CatalogueCard key={transition.id} label={transition.label} blurb={transition.blurb}>+ <CatalogueCard+ key={transition.id}+ label={transition.label}+ blurb={transition.blurb}+ onApply={transition.implemented ? () => onApply(transition.id) : undefined}+ ><Icon name="transition" size={22} strokeWidth={1.5} className="text-tertiary" /></CatalogueCard>))}@@ -557,12 +592,23 @@ function TransitionsPage({ category }: { category: TransitionCategory }) {);}-function EffectsPage({ category }: { category: EffectCategory }) {+function EffectsPage({+ category,+ onApply,+}: {+ category: EffectCategory;+ onApply: (effectId: string) => void;+}) {const visible = EFFECTS.filter((effect) => effect.category === category);return (<ul className={`${CARD_GRID} pt-2`}>{visible.map((effect) => (- <CatalogueCard key={effect.id} label={effect.label} blurb={effect.blurb}>+ <CatalogueCard+ key={effect.id}+ label={effect.label}+ blurb={effect.blurb}+ onApply={() => onApply(effect.id)}+ ><span className="absolute inset-0" style={{ background: effect.swatch }} aria-hidden /><Icon name="sparkles" size={20} strokeWidth={1.5} className="relative text-white/85" /></CatalogueCard>diff --git a/desktop/src/components/Menu.tsx b/desktop/src/components/Menu.tsxindex 586650d9..244e6846 100644--- a/desktop/src/components/Menu.tsx+++ b/desktop/src/components/Menu.tsx@@ -7,6 +7,12 @@ export interface MenuOption {label: string;onSelect: () => void;icon?: IconName;+ /**+ * An arbitrary element in the icon slot, for rows whose glyph is drawn+ * rather than named - the frame-size menu's aspect shapes. Wins over+ * `icon` and `checked` when set.+ */+ leading?: ReactNode;/** Right-aligned hint, e.g. a keyboard shortcut. */hint?: string;disabled?: boolean;@@ -100,7 +106,11 @@ export function Menu({disabled:cursor-not-allowed disabled:opacity-30 disabled:hover:bg-transparent${option.danger ? "text-danger" : ""}`}>- {option.checked !== undefined ? (+ {option.leading ? (+ <span className="flex w-4 shrink-0 items-center justify-center">+ {option.leading}+ </span>+ ) : option.checked !== undefined ? (<Iconname="check"size={14}diff --git a/desktop/src/components/Preview.tsx b/desktop/src/components/Preview.tsxindex e3eb72eb..d28e087e 100644--- a/desktop/src/components/Preview.tsx+++ b/desktop/src/components/Preview.tsx@@ -8,6 +8,7 @@ import {} from "react";import { convertFileSrc } from "@tauri-apps/api/core";+import { buildPreviewLook, type AppliedEffect, type CanvasOp } from "../lib/effects";import { timecode } from "../lib/time";import { MAX_SCALE, MIN_SCALE } from "../lib/project";import { textCss, type TextStyle } from "../lib/text";@@ -170,7 +171,7 @@ function softSnap(*/export function Preview({source,- overlays,+ overlays: titleOverlays,playing,playhead,duration,@@ -178,6 +179,9 @@ export function Preview({frame,transform,opacity,+ effects,+ ghost,+ veil,mediaSize,selectedClipId,onSelectClip,@@ -201,6 +205,14 @@ export function Preview({transform: PreviewTransform | null;/** The displayed clip's blend strength, 1 being solid. */opacity: number;+ /** The displayed clip's video effects, drawn live. Null for none. */+ effects: AppliedEffect[] | null;+ /** A cross-fade in progress: the incoming clip's pre-roll, faded in over+ * the picture. Null outside a dissolve window. */+ ghost: { clipId: string; path: string; time: number; speed: number; opacity: number } | null;+ /** A fade-to-colour transition passing over the playhead: a coloured wash+ * whose opacity the app computes per frame. Null when no fade is live. */+ veil: { color: string; opacity: number } | null;/** The source's pixel size, when the probe reported one. */mediaSize: { width: number; height: number } | null;/** The single selected clip, if there is one - its box shows handles. */@@ -219,6 +231,7 @@ export function Preview({onSeek: (seconds: number) => void;}) {const video = useRef<HTMLVideoElement>(null);+ const still = useRef<HTMLImageElement>(null);const loadedClip = useRef<string | null>(null);// The picture's true pixel size, measured off the element once it has@@ -279,15 +292,37 @@ export function Preview({// The same placement the exporter applies, as CSS. Order matters and matches// the compositor: scale about the picture's centre, rotate about it, then// translate. (CSS applies the list right to left.)+ // Everything the clip's effects need to draw live: the CSS/SVG filter+ // string, overlay layers, canvas geometry passes, and shake jitter -+ // assembled in applied order, scaled to preview pixels.+ const pixelScale = frameRect ? frameRect.width / frame.width : 1;+ const look = useMemo(+ () => buildPreviewLook(effects ?? undefined, pixelScale),+ [effects, pixelScale],+ );++ // Deterministic shake, evaluated from the playhead clock - the exact+ // `sin(t*f)` expression the export's jitter crop runs, so pausing anywhere+ // shows the same displaced frame the file will have.+ const jitterX = look.jitter+ ? -look.jitter.amount * pixelScale * Math.sin(playhead * look.jitter.speed)+ : 0;+ const jitterY = look.jitter+ ? -look.jitter.amount * pixelScale * Math.cos(playhead * look.jitter.speed * 1.3)+ : 0;+const mediaCss =transform && frameRect? {- transform: `translate(${transform.offsetX * frameRect.width}px, ${- transform.offsetY * frameRect.height+ transform: `translate(${transform.offsetX * frameRect.width + jitterX}px, ${+ transform.offsetY * frameRect.height + jitterY}px) rotate(${transform.rotation}deg) scale(${transform.scale})`,// The same blend the compositor applies on export. On the wrapper// with the transform, so the whole picture fades as one surface.opacity: Math.min(1, Math.max(0, opacity)),+ // The live effect filters. On the wrapper, so the canvas pass+ // underneath inherits them too.+ filter: look.filter ?? undefined,}: undefined;@@ -384,6 +419,23 @@ export function Preview({media element itself: WKWebView keeps `<video>` in its owncompositing layer, and animating transforms directly on itis unreliable where a plain div never is. */}+ {/* The SVG filters the effect chain references via url(#id).+ Zero-sized and inert; only the defs matter. */}+ {look.svgFilters.length > 0 && (+ <svg width="0" height="0" className="absolute" aria-hidden>+ <defs+ dangerouslySetInnerHTML={{+ __html: look.svgFilters+ .map(+ (entry) =>+ `<filter id="${entry.id}" color-interpolation-filters="sRGB">${entry.content}</filter>`,+ )+ .join(""),+ }}+ />+ </svg>+ )}+<div className="absolute inset-0" style={mediaCss}><videoref={video}@@ -398,6 +450,7 @@ export function Preview({className={`absolute inset-0 h-full w-full object-contain ${source && !source.isStill ? "block" : "hidden"}`}+ style={look.canvas.length > 0 ? { visibility: "hidden" } : undefined}/>{source?.isStill && (<img@@ -405,6 +458,7 @@ export function Preview({// actually swaps the picture rather than reusing the// decoded one.key={source.clipId}+ ref={still}src={convertFileSrc(source.path)}alt=""draggable={false}@@ -415,10 +469,51 @@ export function Preview({})}className="absolute inset-0 h-full w-full object-contain"+ style={look.canvas.length > 0 ? { visibility: "hidden" } : undefined}+ />+ )}++ {/* Geometry effects - pixelate, mirror, fisheye - redraw the+ media on a canvas the wrapper's filters still apply to.+ The media element stays live underneath, just invisible:+ it is the decoder this canvas samples. */}+ {look.canvas.length > 0 && source && (+ <EffectCanvas+ ops={look.canvas}+ pixelScale={pixelScale}+ source={() => (source.isStill ? still.current : video.current)}/>)}</div>+ {/* Effect overlay layers: vignette's gradient, grain's animated+ noise. Over the picture, under the incoming dissolve. */}+ {look.overlays.map((overlay, index) => (+ <div+ key={index}+ className={`pointer-events-none absolute ${+ overlay.grain ? "-inset-[12%] grain-layer" : "inset-0"+ }`}+ style={overlay.style as React.CSSProperties}+ />+ ))}++ {/* A cross-fade in progress: the incoming clip's pre-roll,+ ramping in over everything above - the dissolve itself. */}+ {ghost && ghost.opacity > 0 && (+ <GhostVideo key={ghost.clipId} ghost={ghost} playing={playing} />+ )}++ {/* A fade-to-black/white transition washing over the cut. Above+ the picture, below titles - titles ride through a fade the+ same way the exporter composites them, on top. */}+ {veil && veil.opacity > 0 && (+ <div+ className="pointer-events-none absolute inset-0"+ style={{ backgroundColor: veil.color, opacity: Math.min(1, veil.opacity) }}+ />+ )}+{/* Alignment guides, only alive mid-drag. Dashed and faint onpurpose: a hint that something lined up, not a grid. */}{guides.x !== null && (@@ -459,7 +554,7 @@ export function Preview({fall through to the footage behind it. The layer clips like theframe does.*/}- {frameRect && overlays.length > 0 && (+ {frameRect && titleOverlays.length > 0 && (<divclassName="absolute overflow-hidden"style={{@@ -469,7 +564,7 @@ export function Preview({height: frameRect.height,}}>- {overlays.map((overlay) => (+ {titleOverlays.map((overlay) => (<TextOverlayBoxkey={overlay.clipId}overlay={overlay}@@ -483,7 +578,7 @@ export function Preview({</div>)}- {!source && overlays.length === 0 && (+ {!source && titleOverlays.length === 0 && (// No surface of its own: an empty monitor *is* black, and drawing// a bordered card on top of it invents an edge that means nothing.// Just the words, sitting on the stage.@@ -586,6 +681,218 @@ export function Preview({);}+/**+ * The canvas pass for geometry effects the CSS filter pipeline cannot do.+ *+ * Redraws the media element into a canvas every animation frame, applying+ * pixelate, mirror and fisheye in effect order. The canvas sits inside the+ * filtered wrapper, so colour and blur effects stack on top of the geometry+ * the same way the export's single FFmpeg chain runs them - approximate in+ * order, identical in look.+ */+function EffectCanvas({+ ops,+ pixelScale,+ source,+}: {+ ops: CanvasOp[];+ /** Preview pixels per export pixel, so block sizes match the file. */+ pixelScale: number;+ source: () => HTMLVideoElement | HTMLImageElement | null;+}) {+ const canvasRef = useRef<HTMLCanvasElement>(null);+ const state = useRef({ ops, pixelScale, source });+ state.current = { ops, pixelScale, source };++ useEffect(() => {+ const work = document.createElement("canvas");+ const scratch = document.createElement("canvas");+ let frame = 0;++ const tick = () => {+ frame = requestAnimationFrame(tick);+ const canvas = canvasRef.current;+ const media = state.current.source();+ const context = canvas?.getContext("2d");+ if (!canvas || !media || !context) return;++ const width = canvas.clientWidth;+ const height = canvas.clientHeight;+ if (width === 0 || height === 0) return;+ const ratio = window.devicePixelRatio || 1;+ if (canvas.width !== Math.round(width * ratio) || canvas.height !== Math.round(height * ratio)) {+ canvas.width = Math.max(1, Math.round(width * ratio));+ canvas.height = Math.max(1, Math.round(height * ratio));+ }++ const naturalWidth =+ media instanceof HTMLVideoElement ? media.videoWidth : media.naturalWidth;+ const naturalHeight =+ media instanceof HTMLVideoElement ? media.videoHeight : media.naturalHeight;+ if (!naturalWidth || !naturalHeight) return;++ // The same contain-fit the hidden element's object-contain performs.+ const fit = Math.min(width / naturalWidth, height / naturalHeight);+ const drawWidth = naturalWidth * fit;+ const drawHeight = naturalHeight * fit;++ work.width = Math.max(1, Math.round(drawWidth * ratio));+ work.height = Math.max(1, Math.round(drawHeight * ratio));+ const workContext = work.getContext("2d");+ if (!workContext) return;+ workContext.imageSmoothingQuality = "high";+ workContext.drawImage(media, 0, 0, work.width, work.height);++ for (const op of state.current.ops) {+ applyCanvasOp(work, workContext, scratch, op, state.current.pixelScale * ratio);+ }++ context.setTransform(ratio, 0, 0, ratio, 0, 0);+ context.clearRect(0, 0, width, height);+ context.drawImage(work, (width - drawWidth) / 2, (height - drawHeight) / 2, drawWidth, drawHeight);+ };++ frame = requestAnimationFrame(tick);+ return () => cancelAnimationFrame(frame);+ }, []);++ return <canvas ref={canvasRef} className="absolute inset-0 h-full w-full" />;+}++/** Applies one geometry op to `work` in place, using `scratch` as the copy. */+function applyCanvasOp(+ work: HTMLCanvasElement,+ context: CanvasRenderingContext2D,+ scratch: HTMLCanvasElement,+ op: CanvasOp,+ pixelScale: number,+): void {+ const { width, height } = work;+ const scratchContext = scratch.getContext("2d");+ if (!scratchContext) return;++ if (op.kind === "pixelate") {+ // Downscale then nearest-neighbour upscale - the definition of pixelate.+ const block = Math.max(2, op.size * pixelScale);+ const smallWidth = Math.max(1, Math.round(width / block));+ const smallHeight = Math.max(1, Math.round(height / block));+ scratch.width = smallWidth;+ scratch.height = smallHeight;+ scratchContext.imageSmoothingQuality = "high";+ scratchContext.drawImage(work, 0, 0, smallWidth, smallHeight);+ context.imageSmoothingEnabled = false;+ context.clearRect(0, 0, width, height);+ context.drawImage(scratch, 0, 0, width, height);+ context.imageSmoothingEnabled = true;+ return;+ }++ if (op.kind === "mirror") {+ scratch.width = width;+ scratch.height = height;+ scratchContext.drawImage(work, 0, 0);+ const half = Math.floor(width / 2);+ context.clearRect(0, 0, width, height);+ context.drawImage(scratch, 0, 0, half, height, 0, 0, half, height);+ context.save();+ context.translate(width, 0);+ context.scale(-1, 1);+ context.drawImage(scratch, 0, 0, half, height, 0, 0, half, height);+ context.restore();+ return;+ }++ // Fisheye: a two-pass one-dimensional barrel remap in strips. Not a true+ // lens equation, but the centre magnifies and the edges compress the same+ // way, at a cost of ~100 strip draws instead of a per-pixel loop.+ const k = op.strength * 0.45;+ const strips = 48;+ const remap = (normalised: number) => normalised * (1 - k * (1 - normalised * normalised));++ scratch.width = width;+ scratch.height = height;+ scratchContext.drawImage(work, 0, 0);+ context.clearRect(0, 0, width, height);+ for (let index = 0; index < strips; index += 1) {+ const x0 = (index / strips) * 2 - 1;+ const x1 = ((index + 1) / strips) * 2 - 1;+ const sx0 = ((remap(x0) + 1) / 2) * width;+ const sx1 = ((remap(x1) + 1) / 2) * width;+ context.drawImage(+ scratch,+ sx0, 0, Math.max(1, sx1 - sx0), height,+ (index / strips) * width, 0, width / strips + 1, height,+ );+ }+ scratchContext.clearRect(0, 0, width, height);+ scratchContext.drawImage(work, 0, 0);+ context.clearRect(0, 0, width, height);+ for (let index = 0; index < strips; index += 1) {+ const y0 = (index / strips) * 2 - 1;+ const y1 = ((index + 1) / strips) * 2 - 1;+ const sy0 = ((remap(y0) + 1) / 2) * height;+ const sy1 = ((remap(y1) + 1) / 2) * height;+ context.drawImage(+ scratch,+ 0, sy0, width, Math.max(1, sy1 - sy0),+ 0, (index / strips) * height, width, height / strips + 1,+ );+ }+}++/**+ * The incoming clip of a cross-fade, playing its pre-roll over the picture.+ *+ * A second, short-lived video element with the same corrective sync the main+ * one uses. It exists only inside the dissolve window; the `key` on its mount+ * point retires it the moment the transition's clip changes.+ */+function GhostVideo({+ ghost,+ playing,+}: {+ ghost: { clipId: string; path: string; time: number; speed: number; opacity: number };+ playing: boolean;+}) {+ const element = useRef<HTMLVideoElement>(null);++ useEffect(() => {+ const media = element.current;+ if (!media) return;+ media.src = convertFileSrc(ghost.path);+ media.load();+ // Mount effect only: the sync effect below lands the position.+ // eslint-disable-next-line react-hooks/exhaustive-deps+ }, [ghost.path]);++ useEffect(() => {+ const media = element.current;+ if (!media) return;+ const rate = Math.min(16, Math.max(0.0625, ghost.speed));+ if (media.playbackRate !== rate) media.playbackRate = rate;+ const tolerance = playing ? 0.3 : 0.03;+ if (media.readyState > 0 && Math.abs(media.currentTime - ghost.time) > tolerance) {+ try {+ media.currentTime = Math.max(0, ghost.time);+ } catch {+ // Still opening; the next update lands it.+ }+ }+ if (playing && media.paused) void media.play().catch(() => undefined);+ if (!playing && !media.paused) media.pause();+ }, [ghost, playing]);++ return (+ <video+ ref={element}+ muted+ playsInline+ className="pointer-events-none absolute inset-0 h-full w-full object-contain"+ style={{ opacity: Math.min(1, Math.max(0, ghost.opacity)) }}+ />+ );+}+/*** Direct manipulation of the displayed clip's picture.*diff --git a/desktop/src/components/RightPanel.tsx b/desktop/src/components/RightPanel.tsxindex 131fe4fd..c6dc3c2e 100644--- a/desktop/src/components/RightPanel.tsx+++ b/desktop/src/components/RightPanel.tsx@@ -1,12 +1,14 @@-import type { Clip, MediaItem, Project } from "../lib/project";+import type { AppliedEffect, ClipTransition } from "../lib/effects";import type { ClipFilter } from "../lib/filters";+import { precedingClip, type Clip, type MediaItem, type Project } from "../lib/project";import { AdjustPanel } from "./AdjustPanel";+import { EffectsPanel } from "./EffectsPanel";import { FiltersPanel } from "./FiltersPanel";import { Inspector } from "./Inspector";import { Panel } from "./Panel";import { TextPanel } from "./TextPanel";-export type RightTab = "details" | "adjust" | "filters" | "text";+export type RightTab = "details" | "adjust" | "filters" | "effects" | "text";/*** The tab strip follows the selection.@@ -23,6 +25,13 @@ const DETAILS_TABS: { id: RightTab; label: string }[] = [{ id: "details", label:const CLIP_TABS: { id: RightTab; label: string }[] = [{ id: "adjust", label: "Adjust" },{ id: "filters", label: "Filters" },+ { id: "effects", label: "Effects" },+];++// A still has picture but no sound, so it gets Effects but not Filters.+const IMAGE_TABS: { id: RightTab; label: string }[] = [+ { id: "adjust", label: "Adjust" },+ { id: "effects", label: "Effects" },];const TEXT_TABS: { id: RightTab; label: string }[] = [{ id: "text", label: "Text" }];@@ -67,7 +76,13 @@ export function RightPanel({onRemoveFont: (family: string) => void;}) {const isText = clip?.kind === "text";- const tabs = clip ? (isText ? TEXT_TABS : CLIP_TABS) : DETAILS_TABS;+ const tabs = clip+ ? isText+ ? TEXT_TABS+ : clip.kind === "image"+ ? IMAGE_TABS+ : CLIP_TABS+ : DETAILS_TABS;// A selection change can leave the strip showing a tab that is no longer// offered, so the active tab falls back to the first one that exists.@@ -125,6 +140,16 @@ export function RightPanel({onChange={(filters: ClipFilter[]) => onChangeClip({ filters })}/>)}+ {active === "effects" && (+ <EffectsPanel+ clip={clip}+ hasPreceding={clip ? precedingClip(project, clip.id) !== null : false}+ onChangeEffects={(videoEffects: AppliedEffect[]) => onChangeClip({ videoEffects })}+ onChangeTransition={(transitionIn: ClipTransition | undefined) =>+ onChangeClip({ transitionIn })+ }+ />+ )}</Panel>);}diff --git a/desktop/src/components/StartScreen.tsx b/desktop/src/components/StartScreen.tsxindex fee77c69..c12b3261 100644--- a/desktop/src/components/StartScreen.tsx+++ b/desktop/src/components/StartScreen.tsx@@ -7,6 +7,7 @@ import {createProject,forgetProject,openProject,+ projectPreview,recentProjects,type ProjectInfo,} from "../lib/engine";@@ -139,7 +140,20 @@ export function StartScreen({ onCreate }: { onCreate: (session: ProjectSession)return (<div className="thin-scroll h-full overflow-y-auto bg-base">- <div className="mx-auto flex min-h-full w-full max-w-xl flex-col justify-center px-8 py-16">+ {/*+ Two columns once there is history: the setup form on the left, the+ projects being returned to on the right - the two reasons anyone is on+ this screen, side by side instead of one buried under the other. With+ no history the form sits alone, centred, exactly as before.+ */}+ <div+ className={`mx-auto flex min-h-full w-full flex-col justify-center px-8 py-16 ${+ recents.length > 0+ ? "max-w-5xl lg:grid lg:grid-cols-[minmax(0,1fr)_minmax(0,22rem)] lg:items-start lg:gap-16"+ : "max-w-xl"+ }`}+ >+ <div className="min-w-0"><header className="mb-10"><h1 className="font-display text-[34px] font-semibold leading-tight tracking-[-0.03em] text-primary">New project@@ -227,36 +241,44 @@ export function StartScreen({ onCreate }: { onCreate: (session: ProjectSession)The timeline is not saved to disk yet.</p></div>+ </div>{/* No empty state: a "Recent" heading over nothing is worse than no- heading at all, so the section simply is not there until it has+ heading at all, so the column simply is not there until it hassomething to show. */}{recents.length > 0 && (- <section className="mt-14 border-t border-hairline pt-7">- <h2 className="mb-2 text-[13px] font-semibold text-secondary">Recent</h2>- <ul className="-mx-3">+ <section className="mt-14 border-t border-hairline pt-7 lg:mt-0 lg:border-t-0 lg:pt-0">+ <h2 className="mb-3 text-[13px] font-semibold text-secondary">Recent</h2>+ <ul className="flex flex-col gap-1.5">{recents.map((project) => (- <li key={project.path} className="group flex items-center gap-3 rounded-lg px-3- transition-colors hover:bg-hover">+ <li+ key={project.path}+ className="group flex items-center gap-3 rounded-xl p-2 transition-colors+ hover:bg-hover"+ ><buttontype="button"title={project.path}disabled={busy}onClick={() => void reopen(project)}- className="min-w-0 flex-1 cursor-pointer py-2.5 text-left+ className="flex min-w-0 flex-1 cursor-pointer items-center gap-3 text-leftdisabled:cursor-not-allowed">- <span className="block truncate text-[14px] text-primary">{project.name}</span>- <span className="block truncate font-technical text-[11px] text-tertiary">- {project.width} x {project.height} Β·{" "}- {(project.rateNum / project.rateDen).toFixed(2)} fps+ <ProjectThumb project={project} />+ <span className="min-w-0 flex-1">+ <span className="block truncate text-[14px] text-primary">+ {project.name}+ </span>+ <span className="block truncate font-technical text-[11px] text-tertiary">+ {project.width} x {project.height} Β·{" "}+ {(project.rateNum / project.rateDen).toFixed(2)} fps+ </span>+ <span className="block text-[11px] text-tertiary">+ {relativeTime(project.openedAt)}+ </span></span></button>- <span className="shrink-0 text-[11px] text-tertiary">- {relativeTime(project.openedAt)}- </span>-<buttontype="button"aria-label={`Remove ${project.name} from recents`}@@ -278,6 +300,47 @@ export function StartScreen({ onCreate }: { onCreate: (session: ProjectSession));}+/**+ * A project's poster frame: a frame from the earliest clip of its timeline,+ * generated and cached by the host. A project with nothing visual on it - or+ * whose media has moved - falls back to a quiet film icon rather than an+ * error; the launch screen is not the place to complain about footage.+ */+function ProjectThumb({ project }: { project: ProjectInfo }) {+ const [poster, setPoster] = useState<string | null>(null);++ useEffect(() => {+ let url: string | null = null;+ let cancelled = false;+ void projectPreview(project.path)+ .then((bytes) => {+ if (cancelled) return;+ url = URL.createObjectURL(new Blob([bytes], { type: "image/jpeg" }));+ setPoster(url);+ })+ .catch(() => undefined);+ return () => {+ cancelled = true;+ if (url) URL.revokeObjectURL(url);+ };+ }, [project.path]);++ return (+ <span+ className="relative block aspect-video w-24 shrink-0 overflow-hidden rounded-lg bg-sunken+ ring-1 ring-hairline"+ >+ {poster ? (+ <img src={poster} alt="" draggable={false} className="h-full w-full object-cover" />+ ) : (+ <span className="absolute inset-0 flex items-center justify-center text-tertiary">+ <Icon name="film" size={16} strokeWidth={1.5} />+ </span>+ )}+ </span>+ );+}+/** The decimal rate is derived, never stored - the fraction is the truth. */function toSession(project: ProjectInfo): ProjectSession {return {diff --git a/desktop/src/components/TimelinePanel.tsx b/desktop/src/components/TimelinePanel.tsxindex f8c54598..791d52f2 100644--- a/desktop/src/components/TimelinePanel.tsx+++ b/desktop/src/components/TimelinePanel.tsx@@ -716,8 +716,8 @@ export function TimelinePanel({as changing documents, not changing tools.*/}<div- className="thin-scroll flex h-8 shrink-0 items-center gap-1 overflow-x-auto- border-b border-hairline px-1.5"+ className="thin-scroll flex h-8 shrink-0 items-end gap-0.5 overflow-x-auto+ overflow-y-hidden border-b border-hairline bg-sunken px-1.5 pt-1">{project.timelines.map((timeline) => (<TimelineTab@@ -730,7 +730,9 @@ export function TimelinePanel({onRequestRemove={onRequestRemoveTimeline}/>))}- <IconButton icon="plus" label="New timeline" size={7} onClick={onAddTimeline} />+ <span className="self-center">+ <IconButton icon="plus" label="New timeline" size={7} onClick={onAddTimeline} />+ </span></div><Bar>@@ -779,22 +781,30 @@ export function TimelinePanel({active={snap}onClick={() => onSnapChange(!snap)}/>- <Divider />- <Menu- groups={clipTools}- trigger={(open) => (- <span- title="Audio & video tools"- className={`flex h-9 items-center gap-0.5 rounded-lg px-1.5 transition-colors- duration-150 ${- open ? "bg-tool-active-bg text-tool-active" : "text-primary hover:bg-hover"- }`}- >- <Icon name="waveform" size={16} />- <Icon name="chevronDown" size={11} />- </span>- )}- />+ {/* Only while a sound-capable clip is selected: a title has nothing+ to detach or transcribe, and a menu of grey rows teaches nothing. */}+ {clipTools.length > 0 && (+ <>+ <Divider />+ <Menu+ groups={clipTools}+ trigger={(open) => (+ <span+ title="Audio & video tools"+ className={`flex h-9 items-center gap-0.5 rounded-lg px-1.5 transition-colors+ duration-150 ${+ open+ ? "bg-tool-active-bg text-tool-active"+ : "text-primary hover:bg-hover"+ }`}+ >+ <Icon name="waveform" size={16} />+ <Icon name="chevronDown" size={11} />+ </span>+ )}+ />+ </>+ )}<Divider /><IconButton icon="plus" label="Add track" onClick={onAddTrack} />@@ -923,10 +933,14 @@ function TimelineTab({title={active ? timeline.name : `Switch to ${timeline.name}`}onClick={() => onSelect(timeline.id)}onDoubleClick={() => setRenaming(true)}- className={`group flex max-w-44 shrink-0 cursor-pointer items-center gap-1 rounded-md- px-2 py-0.5 text-xs transition-colors ${+ // Browser-tab shape: rounded top only, and the active tab overlaps the+ // strip's bottom border by a pixel with the panel's own background, so+ // it reads as one surface with the tray below rather than a pill+ // floating above it.+ className={`group -mb-px flex max-w-44 shrink-0 cursor-pointer items-center gap-1+ rounded-t-md px-2.5 py-1 text-xs transition-colors ${active- ? "bg-active text-primary"+ ? "border border-b-0 border-hairline bg-panel text-primary": "text-secondary hover:bg-hover hover:text-primary"}`}>@@ -1318,14 +1332,50 @@ function drawClip(context.fillStyle = palette.header;context.fillRect(x, y, drawWidth, CLIP_HEADER);+ // An "fx" chip in the header when effects are live on the clip, so a styled+ // clip is tellable from a plain one without opening a panel.+ const liveEffects = clip.videoEffects.some((effect) => effect.enabled !== false);+ const chipWidth = liveEffects && drawWidth > 60 ? 20 : 0;+if (drawWidth > 30) {context.fillStyle = COLORS.clipText;context.font = LABEL_FONT;context.textBaseline = "middle";- const label = ellipsize(context, clip.name, drawWidth - 14);+ const label = ellipsize(context, clip.name, drawWidth - 14 - chipWidth);if (label) context.fillText(label, x + 7, y + CLIP_HEADER / 2 + 0.5);}+ if (chipWidth > 0) {+ context.fillStyle = "rgba(0,0,0,0.35)";+ context.beginPath();+ context.roundRect(x + drawWidth - chipWidth + 2, y + 2.5, chipWidth - 6, CLIP_HEADER - 5, 3);+ context.fill();+ context.fillStyle = COLORS.clipText;+ context.font = '9px "Cabinet Grotesk", system-ui, sans-serif';+ context.fillText("fx", x + drawWidth - chipWidth + 6, y + CLIP_HEADER / 2 + 0.5);+ }++ // A transition on the cut into this clip: a small wedge pair at the left+ // edge, the mark every editor uses for "these two dissolve".+ if (clip.transitionIn && drawWidth > 16) {+ const size = Math.min(9, bodyHeight / 2);+ const midY = bodyY + bodyHeight / 2;+ context.fillStyle = "rgba(255,255,255,0.8)";+ context.beginPath();+ context.moveTo(x + 1, midY - size);+ context.lineTo(x + 1 + size, midY);+ context.lineTo(x + 1, midY + size);+ context.closePath();+ context.fill();+ context.fillStyle = "rgba(255,255,255,0.45)";+ context.beginPath();+ context.moveTo(x + 1 + size, midY - size);+ context.lineTo(x + 1, midY);+ context.lineTo(x + 1 + size, midY + size);+ context.closePath();+ context.fill();+ }+context.restore();context.beginPath();diff --git a/desktop/src/components/controls.tsx b/desktop/src/components/controls.tsxindex 8dc17147..9d9d45c5 100644--- a/desktop/src/components/controls.tsx+++ b/desktop/src/components/controls.tsx@@ -81,6 +81,8 @@ export function Slider({// Where the last pointer event landed, so a shift-drag can be relative to// the previous position rather than jumping to the pointer.const lastX = useRef(0);+ // What the number field holds while it is being edited. Null means it shows+ // the value; the project is not touched until the entry commits.const [typing, setTyping] = useState<string | null>(null);const clampStep = (raw: number) => {@@ -126,69 +128,80 @@ export function Slider({>{label}</span>- {typing === null ? (- <button- type="button"- title="Click to type a value"- onClick={() => setTyping(String(Number(value.toFixed(4))))}- className="cursor-text rounded px-1 font-technical text-[11px] text-primary- transition-colors hover:bg-hover"- >- {format(value)}- </button>- ) : (- <input- autoFocus- value={typing}- onChange={(event) => setTyping(event.target.value)}- onFocus={(event) => event.target.select()}- onBlur={commitTyped}- onKeyDown={(event: ReactKeyboardEvent<HTMLInputElement>) => {- if (event.key === "Enter") commitTyped();- if (event.key === "Escape") setTyping(null);- }}- className="w-16 rounded border border-accent bg-sunken px-1 text-right- font-technical text-[11px] text-primary outline-none"- />- )}+ <span className="font-technical text-[11px] text-tertiary">{format(value)}</span></div>- <div- ref={track}- role="slider"- aria-label={label}- aria-valuenow={value}- aria-valuemin={min}- aria-valuemax={max}- tabIndex={0}- onKeyDown={(event) => {- // Shift jumps by ten steps - the keyboard's coarse mode, mirroring- // how shift is the pointer's fine mode: both mean "the other rate".- const by = event.shiftKey ? step * 10 : step;- if (event.key === "ArrowLeft") onChange(clampStep(value - by));- if (event.key === "ArrowRight") onChange(clampStep(value + by));- }}- onPointerDown={(event) => {- event.currentTarget.setPointerCapture(event.pointerId);- lastX.current = event.clientX;- // A shift-click means "adjust from here", not "jump here".- if (!event.shiftKey) commit(event);- }}- onPointerMove={(event) => {- if (event.currentTarget.hasPointerCapture(event.pointerId)) commit(event);- }}- className="relative h-6 cursor-ew-resize touch-none select-none overflow-hidden- rounded-md bg-sunken"- >- <div- className="absolute inset-y-0 left-0 bg-accent-soft"- style={{ width: `${fill * 100}%` }}- />- {/* The knob subtracts its own width as it travels, so it stays inside- the track at both ends instead of hanging over the edge. */}+ <div className="flex items-stretch gap-1.5"><div- className="absolute top-0 h-full w-1 rounded bg-accent"- style={{ left: `calc(${fill * 100}% - ${fill * 4}px)` }}+ ref={track}+ role="slider"+ aria-label={label}+ aria-valuenow={value}+ aria-valuemin={min}+ aria-valuemax={max}+ tabIndex={0}+ onKeyDown={(event) => {+ // Shift jumps by ten steps - the keyboard's coarse mode, mirroring+ // how shift is the pointer's fine mode: both mean "the other rate".+ const by = event.shiftKey ? step * 10 : step;+ if (event.key === "ArrowLeft") onChange(clampStep(value - by));+ if (event.key === "ArrowRight") onChange(clampStep(value + by));+ }}+ onPointerDown={(event) => {+ event.currentTarget.setPointerCapture(event.pointerId);+ lastX.current = event.clientX;+ // A shift-click means "adjust from here", not "jump here".+ if (!event.shiftKey) commit(event);+ }}+ onPointerMove={(event) => {+ if (event.currentTarget.hasPointerCapture(event.pointerId)) commit(event);+ }}+ className="relative h-6 min-w-0 flex-1 cursor-ew-resize touch-none select-none+ overflow-hidden rounded-md bg-sunken"+ >+ <div+ className="absolute inset-y-0 left-0 bg-accent-soft"+ style={{ width: `${fill * 100}%` }}+ />+ {/* The knob subtracts its own width as it travels, so it stays inside+ the track at both ends instead of hanging over the edge. */}+ <div+ className="absolute top-0 h-full w-1 rounded bg-accent"+ style={{ left: `calc(${fill * 100}% - ${fill * 4}px)` }}+ />+ </div>++ {/*+ The number field: the slider's exact twin in height, always present,+ for dialling in a value the track is too coarse for. A text input+ rather than type="number" because the spinner buttons are the part+ nobody wants - arrow keys step instead, and typing commits on Enter+ or blur, reverting on Escape.+ */}+ <input+ value={typing ?? String(Number(value.toFixed(4)))}+ inputMode="decimal"+ spellCheck={false}+ aria-label={`${label} value`}+ onChange={(event) => setTyping(event.target.value)}+ onFocus={(event) => event.target.select()}+ onBlur={commitTyped}+ onKeyDown={(event: ReactKeyboardEvent<HTMLInputElement>) => {+ if (event.key === "Enter") commitTyped();+ if (event.key === "Escape") {+ setTyping(null);+ event.currentTarget.blur();+ }+ if (event.key === "ArrowUp" || event.key === "ArrowDown") {+ event.preventDefault();+ const by = (event.shiftKey ? step * 10 : step) * (event.key === "ArrowUp" ? 1 : -1);+ setTyping(null);+ onChange(clampStep(value + by));+ }+ }}+ className="h-6 w-14 shrink-0 rounded-md border border-hairline bg-sunken px-1.5+ text-right font-technical text-[11px] text-primary outline-none+ transition-colors focus:border-accent"/></div></div>diff --git a/desktop/src/lib/effects.ts b/desktop/src/lib/effects.tsindex 14e1f7de..29d5cd9a 100644--- a/desktop/src/lib/effects.ts+++ b/desktop/src/lib/effects.ts@@ -1,20 +1,141 @@/*** The video effect and transition catalogues.*- * Browse-only for now: the engine cannot yet render a video effect or a- * transition, so nothing in here produces an FFmpeg fragment. What this file- * fixes today is the *shape* of the library - stable ids, categories, and the- * one place the panel reads from - so that when the engine work lands, each- * entry grows a `chain` builder the way `lib/filters.ts` entries have one, and- * the browsing UI does not change at all.+ * Every effect carries two renderings of one idea:*- * Ids are forever: they will be written into project files once effects can be- * applied, so renaming one later would orphan clips. Pick them like you mean- * them.+ * - `chain` builds the FFmpeg video filter fragment the *export* runs - the+ * same design as `lib/filters.ts` for audio, and the ground truth for+ * pixels.+ * - `preview` says how the *monitor* shows it live: a CSS filter where CSS is+ * faithful, an SVG filter where it needs a matrix or a convolution, an+ * overlay layer, a canvas redraw for geometry, or a deterministic jitter.+ * Every effect previews in real time; the export is only ever a higher+ * quality version of what was already on screen.+ *+ * Ids are forever: they are written into project files, so renaming one later+ * would orphan clips. Pick them like you mean them.+ */++import type { FilterParam } from "./filters";++/**+ * How one effect draws itself in the monitor.+ *+ * `scale` on the builders is preview pixels per export pixel, so a 10px blur+ * looks the same on a small monitor as in the file.+ */+export type EffectPreview =+ | { kind: "css"; filter: (params: Record<string, number>, scale: number) => string }+ | {+ /** The inner content of an SVG `<filter>`, referenced via `url(#id)`. */+ kind: "svg";+ build: (params: Record<string, number>, scale: number) => string;+ }+ | {+ /** A full-frame layer composited over the picture. */+ kind: "overlay";+ style: (params: Record<string, number>) => Record<string, string | number>;+ /** Marks the animated grain layer, which carries its own CSS class. */+ grain?: boolean;+ }+ | { kind: "pixelate" }+ | { kind: "mirror" }+ | { kind: "fisheye" }+ | { kind: "jitter" };++/** One geometry redraw the preview's canvas pass performs, in order. */+export type CanvasOp =+ | { kind: "pixelate"; size: number }+ | { kind: "mirror" }+ | { kind: "fisheye"; strength: number };++/** Everything the monitor needs to draw a clip's effects live. */+export interface PreviewLook {+ /** The CSS `filter` property: functions and `url(#id)` refs, in order. */+ filter: string | null;+ /** SVG `<filter>` elements to mount, matching the `url()` refs above. */+ svgFilters: { id: string; content: string }[];+ /** Layers composited over the picture, in effect order. */+ overlays: { style: Record<string, string | number>; grain?: boolean }[];+ /** Geometry redraws the canvas pass performs, in order. */+ canvas: CanvasOp[];+ /** Position jitter, evaluated from the playhead clock. Null for none. */+ jitter: { amount: number; speed: number } | null;+}++/**+ * The colour cast of a black-body temperature, as an SVG colour matrix.+ *+ * Tanner Helland's approximation, normalised so the strongest channel stays+ * at unity - a tint, not a brightness change - which is also roughly what+ * FFmpeg's `colortemperature` does.*/+function temperatureMatrix(kelvinIn: number): string {+ const t = Math.min(400, Math.max(10, kelvinIn / 100));+ let r: number;+ let g: number;+ let b: number;+ if (t <= 66) {+ r = 255;+ g = 99.4708 * Math.log(t) - 161.1196;+ b = t <= 19 ? 0 : 138.5177 * Math.log(t - 10) - 305.0448;+ } else {+ r = 329.6987 * Math.pow(t - 60, -0.1332047);+ g = 288.1222 * Math.pow(t - 60, -0.0755148);+ b = 255;+ }+ const clamp = (value: number) => Math.min(255, Math.max(0, value)) / 255;+ const peak = Math.max(clamp(r), clamp(g), clamp(b), 1e-6);+ const [nr, ng, nb] = [clamp(r) / peak, clamp(g) / peak, clamp(b) / peak];+ return (+ `<feColorMatrix type="matrix" values="` ++ `${nr.toFixed(4)} 0 0 0 0 0 ${ng.toFixed(4)} 0 0 0 0 0 ${nb.toFixed(4)} 0 0 0 0 0 1 0"/>`+ );+}++/**+ * A 128px monochrome noise tile as a data URI, generated once. The grain+ * overlay tiles and jiggles it; regenerating per frame would be film-accurate+ * and battery-hostile.+ */+let grainTile: string | null = null;+function grainDataUri(): string {+ if (grainTile !== null) return grainTile;+ if (typeof document === "undefined") return (grainTile = "");+ const canvas = document.createElement("canvas");+ canvas.width = 128;+ canvas.height = 128;+ const context = canvas.getContext("2d");+ if (!context) return (grainTile = "");+ const image = context.createImageData(128, 128);+ for (let at = 0; at < image.data.length; at += 4) {+ const value = Math.floor(Math.random() * 256);+ image.data[at] = value;+ image.data[at + 1] = value;+ image.data[at + 2] = value;+ image.data[at + 3] = 255;+ }+ context.putImageData(image, 0, 0);+ return (grainTile = canvas.toDataURL());+}export type EffectCategory = "basic" | "blur" | "color" | "stylize" | "distort";+/** An effect applied to a clip, with whatever parameters were set. */+export interface AppliedEffect {+ id: string;+ params: Record<string, number>;+ /** False bypasses without losing settings. Absent means enabled. */+ enabled?: boolean;+}++/** A transition on the cut into a clip. */+export interface ClipTransition {+ id: string;+ /** Seconds the transition covers. */+ duration: number;+}+export interface EffectDefinition {id: string;label: string;@@ -23,6 +144,11 @@ export interface EffectDefinition {blurb: string;/** CSS background for the preview tile, until real thumbnails exist. */swatch: string;+ params: FilterParam[];+ /** Builds the FFmpeg video filter fragment for these parameter values. */+ chain: (params: Record<string, number>) => string;+ /** How the monitor draws it live. Every effect has one - no export-only. */+ preview: EffectPreview;}/** The categories under the "Video Effects" dropdown, in display order. */@@ -34,6 +160,11 @@ export const EFFECT_CATEGORIES: { id: EffectCategory; label: string }[] = [{ id: "distort", label: "Distort" },];+const percent = (value: number) => `${Math.round(value)}%`;+const pixels = (value: number) => `${Math.round(value)} px`;+const times = (value: number) => `${value.toFixed(2)}x`;+const kelvin = (value: number) => `${Math.round(value)} K`;+export const EFFECTS: EffectDefinition[] = [// ββ basic ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ{@@ -42,6 +173,9 @@ export const EFFECTS: EffectDefinition[] = [category: "basic",blurb: "Drops all colour, keeps the tones.",swatch: "linear-gradient(135deg, #e8e8e8 0%, #6b6b6b 55%, #1c1c1c 100%)",+ params: [],+ chain: () => "hue=s=0",+ preview: { kind: "css", filter: () => "grayscale(1)" },},{id: "sepia",@@ -49,6 +183,11 @@ export const EFFECTS: EffectDefinition[] = [category: "basic",blurb: "Aged warm brown, like an old photograph.",swatch: "linear-gradient(135deg, #e9d3ae 0%, #a9773f 60%, #513a1c 100%)",+ params: [],+ // The standard sepia matrix, the same one the CSS filter defines.+ chain: () =>+ "colorchannelmixer=.393:.769:.189:0:.349:.686:.168:0:.272:.534:.131",+ preview: { kind: "css", filter: () => "sepia(1)" },},{id: "invert",@@ -56,6 +195,9 @@ export const EFFECTS: EffectDefinition[] = [category: "basic",blurb: "Flips every colour to its negative.",swatch: "linear-gradient(135deg, #00d0ff 0%, #7a00c8 55%, #ffe600 100%)",+ params: [],+ chain: () => "negate",+ preview: { kind: "css", filter: () => "invert(1)" },},{id: "sharpen",@@ -63,6 +205,19 @@ export const EFFECTS: EffectDefinition[] = [category: "basic",blurb: "Crisps up edges and fine detail.",swatch: "linear-gradient(135deg, #cfd8dc 0%, #607d8b 55%, #263238 100%)",+ params: [+ { key: "amount", label: "Amount", min: 0.2, max: 3, step: 0.1, default: 1, format: times },+ ],+ chain: ({ amount = 1 }) => `unsharp=5:5:${amount.toFixed(2)}:5:5:0`,+ preview: {+ kind: "svg",+ // An unsharp kernel: edges subtract, the centre compensates, sum one.+ build: ({ amount = 1 }) => {+ const a = (amount * 0.55).toFixed(3);+ const c = (1 + amount * 0.55 * 4).toFixed(3);+ return `<feConvolveMatrix order="3" divisor="1" preserveAlpha="true" kernelMatrix="0 -${a} 0 -${a} ${c} -${a} 0 -${a} 0"/>`;+ },+ },},// ββ blur βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ{@@ -71,6 +226,11 @@ export const EFFECTS: EffectDefinition[] = [category: "blur",blurb: "Soft, even blur across the whole frame.",swatch: "linear-gradient(135deg, #b3c7f9 0%, #7f9cf5 55%, #4c6ef5 100%)",+ params: [+ { key: "radius", label: "Radius", min: 1, max: 50, step: 1, default: 10, format: pixels },+ ],+ chain: ({ radius = 10 }) => `gblur=sigma=${radius.toFixed(1)}`,+ preview: { kind: "css", filter: ({ radius = 10 }, scale) => `blur(${(radius * scale).toFixed(2)}px)` },},{id: "box-blur",@@ -78,13 +238,30 @@ export const EFFECTS: EffectDefinition[] = [category: "blur",blurb: "Fast, slightly harsher blur.",swatch: "linear-gradient(135deg, #a5d8ff 0%, #4dabf7 55%, #1971c2 100%)",+ params: [+ { key: "radius", label: "Radius", min: 1, max: 30, step: 1, default: 6, format: pixels },+ ],+ chain: ({ radius = 6 }) => `boxblur=${Math.round(radius)}:1`,+ preview: { kind: "css", filter: ({ radius = 6 }, scale) => `blur(${(radius * 0.7 * scale).toFixed(2)}px)` },},{id: "motion-blur",label: "Motion Blur",category: "blur",- blurb: "Directional streaking, as if the camera swept.",+ blurb: "Horizontal streaking, as if the camera swept.",swatch: "linear-gradient(90deg, #91a7ff 0%, #5c7cfa 45%, #91a7ff 100%)",+ params: [+ { key: "length", label: "Length", min: 2, max: 60, step: 1, default: 18, format: pixels },+ ],+ // Gaussian in one axis only is the streak; the tiny vertical sigma keeps+ // the filter happy without visibly blurring that axis.+ chain: ({ length = 18 }) => `gblur=sigma=${length.toFixed(1)}:sigmaV=0.1`,+ preview: {+ kind: "svg",+ // The same one-axis gaussian, which SVG spells as two deviations.+ build: ({ length = 18 }, scale) =>+ `<feGaussianBlur stdDeviation="${(length * scale).toFixed(2)} 0.01"/>`,+ },},// ββ color ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ{@@ -93,6 +270,20 @@ export const EFFECTS: EffectDefinition[] = [category: "color",blurb: "Pushes the frame toward orange and gold.",swatch: "linear-gradient(135deg, #ffd8a8 0%, #ff922b 55%, #d9480f 100%)",+ params: [+ {+ key: "temperature",+ label: "Temperature",+ min: 3000,+ max: 6000,+ step: 100,+ default: 4600,+ format: kelvin,+ },+ ],+ chain: ({ temperature = 4600 }) =>+ `colortemperature=temperature=${Math.round(temperature)}`,+ preview: { kind: "svg", build: ({ temperature = 4600 }) => temperatureMatrix(temperature) },},{id: "cool",@@ -100,6 +291,20 @@ export const EFFECTS: EffectDefinition[] = [category: "color",blurb: "Pushes the frame toward blue and teal.",swatch: "linear-gradient(135deg, #99e9f2 0%, #22b8cf 55%, #0b7285 100%)",+ params: [+ {+ key: "temperature",+ label: "Temperature",+ min: 7000,+ max: 11000,+ step: 100,+ default: 8500,+ format: kelvin,+ },+ ],+ chain: ({ temperature = 8500 }) =>+ `colortemperature=temperature=${Math.round(temperature)}`,+ preview: { kind: "svg", build: ({ temperature = 8500 }) => temperatureMatrix(temperature) },},{id: "vibrance",@@ -107,6 +312,11 @@ export const EFFECTS: EffectDefinition[] = [category: "color",blurb: "Richer colour without blowing out skin tones.",swatch: "linear-gradient(135deg, #ff6b6b 0%, #fcc419 40%, #51cf66 70%, #339af0 100%)",+ params: [+ { key: "intensity", label: "Intensity", min: 0.1, max: 2, step: 0.05, default: 0.7, format: times },+ ],+ chain: ({ intensity = 0.7 }) => `vibrance=intensity=${intensity.toFixed(2)}`,+ preview: { kind: "css", filter: ({ intensity = 0.7 }) => `saturate(${(1 + intensity * 0.45).toFixed(2)})` },},{id: "contrast-pop",@@ -114,6 +324,11 @@ export const EFFECTS: EffectDefinition[] = [category: "color",blurb: "Deeper blacks, brighter whites.",swatch: "linear-gradient(135deg, #f8f9fa 0%, #868e96 45%, #212529 100%)",+ params: [+ { key: "contrast", label: "Contrast", min: 1, max: 2, step: 0.05, default: 1.25, format: times },+ ],+ chain: ({ contrast = 1.25 }) => `eq=contrast=${contrast.toFixed(2)}`,+ preview: { kind: "css", filter: ({ contrast = 1.25 }) => `contrast(${contrast.toFixed(2)})` },},// ββ stylize ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ{@@ -122,6 +337,21 @@ export const EFFECTS: EffectDefinition[] = [category: "stylize",blurb: "Darkens the corners to pull the eye inward.",swatch: "radial-gradient(circle at 50% 50%, #ced4da 0%, #495057 60%, #16191c 100%)",+ params: [+ { key: "strength", label: "Strength", min: 10, max: 100, step: 1, default: 50, format: percent },+ ],+ // 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.+ chain: ({ strength = 50 }) =>+ `vignette=angle=${(0.25 + (strength / 100) * 1.05).toFixed(3)}`,+ preview: {+ kind: "overlay",+ style: ({ strength = 50 }) => ({+ background: `radial-gradient(ellipse at center, transparent ${Math.round(+ 72 - strength * 0.45,+ )}%, rgba(0,0,0,${(0.35 + strength * 0.006).toFixed(3)}) 100%)`,+ }),+ },},{id: "film-grain",@@ -129,6 +359,21 @@ export const EFFECTS: EffectDefinition[] = [category: "stylize",blurb: "Fine analogue noise over the picture.",swatch: "linear-gradient(135deg, #dee2e6 0%, #adb5bd 50%, #495057 100%)",+ params: [+ { key: "amount", label: "Amount", min: 2, max: 40, step: 1, default: 12, format: percent },+ ],+ // Temporal (t) so the grain dances like film instead of sitting still.+ chain: ({ amount = 12 }) => `noise=alls=${Math.round(amount)}:allf=t+u`,+ preview: {+ kind: "overlay",+ grain: true,+ style: ({ amount = 12 }) => ({+ backgroundImage: `url(${grainDataUri()})`,+ backgroundRepeat: "repeat",+ mixBlendMode: "overlay",+ opacity: Math.min(1, amount / 40),+ }),+ },},{id: "glow",@@ -136,6 +381,25 @@ export const EFFECTS: EffectDefinition[] = [category: "stylize",blurb: "Blooms the highlights softly.",swatch: "radial-gradient(circle at 50% 40%, #fff9db 0%, #ffe066 45%, #e8590c 100%)",+ params: [+ { key: "amount", label: "Amount", min: 10, max: 100, step: 1, default: 45, format: percent },+ ],+ // Screen-blend a blurred copy over itself - the classic bloom.+ chain: ({ amount = 45 }) =>+ `split[glowa][glowb];[glowb]gblur=sigma=18[glowg];` ++ `[glowa][glowg]blend=all_mode=screen:all_opacity=${(amount / 100).toFixed(2)}`,+ preview: {+ kind: "svg",+ // The same bloom: blur a copy, weight it, screen it over the source.+ build: ({ amount = 45 }, scale) => {+ const weight = (amount / 100).toFixed(3);+ return (+ `<feGaussianBlur in="SourceGraphic" stdDeviation="${(18 * scale).toFixed(2)}" result="wolfglow-blur"/>` ++ `<feColorMatrix in="wolfglow-blur" type="matrix" values="${weight} 0 0 0 0 0 ${weight} 0 0 0 0 0 ${weight} 0 0 0 0 0 1 0" result="wolfglow-dim"/>` ++ `<feBlend in="SourceGraphic" in2="wolfglow-dim" mode="screen"/>`+ );+ },+ },},{id: "posterize",@@ -144,6 +408,32 @@ export const EFFECTS: EffectDefinition[] = [blurb: "Flattens colour into bold bands.",swatch:"linear-gradient(135deg, #e64980 0%, #e64980 33%, #7950f2 33%, #7950f2 66%, #1098ad 66%, #1098ad 100%)",+ params: [+ { key: "levels", label: "Levels", min: 2, max: 8, step: 1, default: 4, format: (v) => String(Math.round(v)) },+ ],+ chain: ({ levels = 4 }) => {+ const size = Math.round(256 / Math.max(2, Math.round(levels)));+ const band = `trunc(val/${size})*${size}`;+ return `lutrgb=r=${band}:g=${band}:b=${band}`;+ },+ preview: {+ kind: "svg",+ // Discrete transfer with the same band values the lut produces.+ build: ({ levels = 4 }) => {+ const count = Math.max(2, Math.round(levels));+ const size = Math.round(256 / count);+ const table = Array.from({ length: count }, (_, index) =>+ ((index * size) / 255).toFixed(4),+ ).join(" ");+ return (+ `<feComponentTransfer>` ++ `<feFuncR type="discrete" tableValues="${table}"/>` ++ `<feFuncG type="discrete" tableValues="${table}"/>` ++ `<feFuncB type="discrete" tableValues="${table}"/>` ++ `</feComponentTransfer>`+ );+ },+ },},// ββ distort ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ{@@ -153,13 +443,22 @@ export const EFFECTS: EffectDefinition[] = [blurb: "Chunks the frame into visible blocks.",swatch:"repeating-linear-gradient(0deg, #74c0fc 0 6px, #4dabf7 6px 12px), repeating-linear-gradient(90deg, #74c0fc80 0 6px, #4dabf780 6px 12px)",+ params: [+ { key: "size", label: "Block size", min: 2, max: 64, step: 1, default: 16, format: pixels },+ ],+ chain: ({ size = 16 }) =>+ `pixelize=width=${Math.round(size)}:height=${Math.round(size)}`,+ preview: { kind: "pixelate" },},{id: "mirror",label: "Mirror",category: "distort",- blurb: "Reflects one half of the frame onto the other.",+ blurb: "Reflects the left half of the frame onto the right.",swatch: "linear-gradient(90deg, #63e6be 0%, #0ca678 50%, #63e6be 100%)",+ params: [],+ chain: () => "crop=iw/2:ih:0:0,split[mirl][mirr];[mirr]hflip[mirf];[mirl][mirf]hstack",+ preview: { kind: "mirror" },},{id: "fisheye",@@ -167,6 +466,15 @@ export const EFFECTS: EffectDefinition[] = [category: "distort",blurb: "Bulges the centre like a wide lens.",swatch: "radial-gradient(circle at 50% 50%, #d0bfff 0%, #9775fa 55%, #5f3dc4 100%)",+ params: [+ { key: "strength", label: "Strength", min: 5, max: 100, step: 1, default: 50, format: percent },+ ],+ // Negative correction coefficients produce barrel distortion - the bulge.+ chain: ({ strength = 50 }) => {+ const k = strength / 100;+ return `lenscorrection=k1=${(-0.55 * k).toFixed(3)}:k2=${(-0.2 * k).toFixed(3)}:i=bilinear`;+ },+ preview: { kind: "fisheye" },},{id: "shake",@@ -174,9 +482,121 @@ export const EFFECTS: EffectDefinition[] = [category: "distort",blurb: "Handheld-style camera judder.",swatch: "linear-gradient(105deg, #ffc9c9 0%, #ff8787 40%, #fa5252 60%, #ffc9c9 100%)",+ params: [+ { key: "amount", label: "Amount", min: 2, max: 40, step: 1, default: 12, format: pixels },+ { key: "speed", label: "Speed", min: 2, max: 30, step: 1, default: 13, format: times },+ ],+ // A jittering crop window; the decoder's guard scale stretches the+ // slightly smaller window back to full size afterwards.+ chain: ({ amount = 12, speed = 13 }) => {+ const a = Math.round(amount);+ const f = Math.round(speed);+ return (+ `crop=iw-${2 * a}:ih-${2 * a}` ++ `:${a}+${a}*sin(t*${f}):${a}+${a}*cos(t*${Math.round(f * 1.3)})`+ );+ },+ preview: { kind: "jitter" },},];+export function findEffect(id: string): EffectDefinition | null {+ return EFFECTS.find((effect) => effect.id === id) ?? null;+}++/** Fills in any parameter the clip did not set. */+export function resolveEffectParams(+ definition: EffectDefinition,+ params: Record<string, number>,+): Record<string, number> {+ const resolved: Record<string, number> = {};+ for (const param of definition.params) {+ resolved[param.key] = params[param.key] ?? param.default;+ }+ return resolved;+}++/**+ * The complete FFmpeg video filter string for a clip, or null if it has none.+ * Effects apply in the order they were added, exactly like audio filters.+ */+export function buildEffectChain(effects: readonly AppliedEffect[] | undefined): string | null {+ if (!effects) return null;+ const fragments = effects.flatMap((applied) => {+ if (applied.enabled === false) return [];+ const definition = findEffect(applied.id);+ if (!definition) return [];+ return [definition.chain(resolveEffectParams(definition, applied.params))];+ });+ return fragments.length > 0 ? fragments.join(",") : null;+}++/**+ * Everything the monitor needs to draw a clip's effects live, assembled from+ * each effect's `preview` in applied order.+ *+ * `scale` is preview pixels per export pixel. CSS/SVG filters keep their+ * relative order inside the one `filter` property (CSS applies the list in+ * sequence); overlays, canvas geometry and jitter compose on top in their own+ * layers - close enough that the export only ever reads as a sharper version+ * of the monitor, never a different picture.+ */+export function buildPreviewLook(+ effects: readonly AppliedEffect[] | undefined,+ scale: number,+): PreviewLook {+ const look: PreviewLook = {+ filter: null,+ svgFilters: [],+ overlays: [],+ canvas: [],+ jitter: null,+ };+ if (!effects || effects.length === 0) return look;++ const filterParts: string[] = [];+ effects.forEach((applied, index) => {+ if (applied.enabled === false) return;+ const definition = findEffect(applied.id);+ if (!definition) return;+ const params = resolveEffectParams(definition, applied.params);+ const preview = definition.preview;++ switch (preview.kind) {+ case "css":+ filterParts.push(preview.filter(params, scale));+ break;+ case "svg": {+ const id = `wolffx-${index}-${definition.id}`;+ look.svgFilters.push({ id, content: preview.build(params, scale) });+ filterParts.push(`url(#${id})`);+ break;+ }+ case "overlay":+ look.overlays.push({ style: preview.style(params), grain: preview.grain });+ break;+ case "pixelate":+ look.canvas.push({ kind: "pixelate", size: Math.max(2, params.size ?? 16) });+ break;+ case "mirror":+ look.canvas.push({ kind: "mirror" });+ break;+ case "fisheye":+ look.canvas.push({ kind: "fisheye", strength: (params.strength ?? 50) / 100 });+ break;+ case "jitter":+ // Several shakes do not add up to a bigger shake; the strongest wins.+ if (!look.jitter || (params.amount ?? 12) > look.jitter.amount) {+ look.jitter = { amount: params.amount ?? 12, speed: params.speed ?? 13 };+ }+ break;+ }+ });++ look.filter = filterParts.length > 0 ? filterParts.join(" ") : null;+ return look;+}+export type TransitionCategory = "basic" | "motion";export interface TransitionDefinition {@@ -185,6 +605,14 @@ export interface TransitionDefinition {category: TransitionCategory;/** One line on what it does, shown in the card tooltip. */blurb: string;+ /**+ * False while the engine cannot render it - the card stays browsable with+ * a "Soon" badge, exactly as the whole catalogue once was. The motion+ * transitions wait on animated transforms in the engine.+ */+ implemented: boolean;+ /** Seconds a freshly applied transition covers. */+ defaultDuration: number;}/** The categories under the "Transitions" dropdown, in display order. */@@ -199,41 +627,59 @@ export const TRANSITIONS: TransitionDefinition[] = [label: "Cross Fade",category: "basic",blurb: "The outgoing clip dissolves into the incoming one.",+ implemented: true,+ defaultDuration: 1,},{id: "fade-black",label: "Fade to Black",category: "basic",blurb: "Out through black, then in from black.",+ implemented: true,+ defaultDuration: 1,},{id: "fade-white",label: "Fade to White",category: "basic",blurb: "Out through white, then in from white.",+ implemented: true,+ defaultDuration: 1,},{id: "wipe-left",label: "Wipe Left",category: "motion",blurb: "The incoming clip sweeps in from the right edge.",+ implemented: false,+ defaultDuration: 0.8,},{id: "wipe-right",label: "Wipe Right",category: "motion",blurb: "The incoming clip sweeps in from the left edge.",+ implemented: false,+ defaultDuration: 0.8,},{id: "push",label: "Push",category: "motion",blurb: "The incoming clip shoves the outgoing one off screen.",+ implemented: false,+ defaultDuration: 0.8,},{id: "zoom",label: "Zoom",category: "motion",blurb: "Punches in on the cut, then settles.",+ implemented: false,+ defaultDuration: 0.8,},];++export function findTransition(id: string): TransitionDefinition | null {+ return TRANSITIONS.find((transition) => transition.id === id) ?? null;+}diff --git a/desktop/src/lib/engine.ts b/desktop/src/lib/engine.tsindex 32f60214..8fd2d91b 100644--- a/desktop/src/lib/engine.ts+++ b/desktop/src/lib/engine.ts@@ -115,6 +115,15 @@ export async function forgetProject(path: string): Promise<void> {return invoke<void>("forget_project", { path });}+/**+ * A poster frame for one project, as JPEG bytes - the launch screen's+ * thumbnail. Cached in the project folder by the host; throws when the+ * project has nothing visual to show, which the caller treats as "no art".+ */+export async function projectPreview(path: string): Promise<ArrayBuffer> {+ return invoke<ArrayBuffer>("project_preview", { path });+}+/** One clip, flattened for the exporter. */export interface ExportClip {path: string;@@ -145,6 +154,11 @@ export interface ExportClip {rotation: number;/** Blend strength over the layers beneath, 1 being solid. */opacity: number;+ /** FFmpeg video filter chain from the Effects tab, or empty for none. */+ videoFilterChain: string;+ /** The transition on the cut into this clip, or null. The host resolves the+ * pair by adjacency and does all the overlap arithmetic. */+ transition: { kind: string; duration: number } | null;/** The source's pixel size, when known - what makes an aspect-correct fit possible. */mediaWidth: number | null;mediaHeight: number | null;diff --git a/desktop/src/lib/persist.ts b/desktop/src/lib/persist.tsindex 72b03e58..e44f6435 100644--- a/desktop/src/lib/persist.ts+++ b/desktop/src/lib/persist.ts@@ -209,6 +209,34 @@ export function fromDocument(raw: unknown): Project | null {];}): [],+ videoEffects: Array.isArray(clip.videoEffects)+ ? clip.videoEffects.flatMap((effect) => {+ if (typeof effect !== "object" || effect === null) return [];+ const applied = effect as Record<string, unknown>;+ if (typeof applied.id !== "string") return [];+ return [+ {+ id: applied.id,+ params:+ typeof applied.params === "object" && applied.params !== null+ ? (applied.params as Record<string, number>)+ : {},+ enabled: flag(applied.enabled, true),+ },+ ];+ })+ : [],+ transitionIn: (() => {+ if (typeof clip.transitionIn !== "object" || clip.transitionIn === null) {+ return undefined;+ }+ const transition = clip.transitionIn as Record<string, unknown>;+ if (typeof transition.id !== "string") return undefined;+ return {+ id: transition.id,+ duration: Math.max(0.1, number(transition.duration, 1)),+ };+ })(),...(isText ? { text: readTextStyle(clip.text) } : {}),},];diff --git a/desktop/src/lib/project.ts b/desktop/src/lib/project.tsindex 0a023623..c00c7a0c 100644--- a/desktop/src/lib/project.ts+++ b/desktop/src/lib/project.ts@@ -20,6 +20,7 @@* acceptable once it is. See docs/decisions/0004.*/+import type { AppliedEffect, ClipTransition } from "./effects";import type { MediaSummary } from "./engine";import type { ClipFilter } from "./filters";import { defaultTextStyle, type CustomFont, type TextStyle } from "./text";@@ -157,6 +158,22 @@ export interface Clip {*/filters: ClipFilter[];+ /**+ * Video effects, applied in order. The visual sibling of `filters`: one+ * FFmpeg chain built in `lib/effects.ts`, run by the exporter at decode.+ */+ videoEffects: AppliedEffect[];++ /**+ * The transition on the cut *into* this clip, if any.+ *+ * On the incoming clip rather than in a separate table because a transition+ * has no life of its own: it exists exactly as long as this clip starts+ * where another one ends. Moving the clips apart orphans it, and an+ * orphaned transition renders as a plain cut rather than an error.+ */+ transitionIn?: ClipTransition;+/*** True when this video clip's embedded audio is left out of preview and* export - the state "Detach audio" puts it in. Meaningless on other kinds.@@ -560,6 +577,7 @@ export function addClip(speed: 1,preservePitch: true,filters: [],+ videoEffects: [],};return { project: { ...project, clips: [...project.clips, clip] }, clipId: clip.id };@@ -610,6 +628,7 @@ export function addTextClip(speed: 1,preservePitch: true,filters: [],+ videoEffects: [],text,};@@ -800,6 +819,9 @@ export function detachAudio(project: Project, clipId: string): Project {trackId,kind: "audio",filters: [...clip.filters],+ // Sound has no picture: effects and transitions stay with the video clip.+ videoEffects: [],+ transitionIn: undefined,detachedFrom: clip.id,muted: undefined,};@@ -855,7 +877,12 @@ export function splitClip(project: Project, clipId: string, time: number): Projereturn project;}- const head: Clip = { ...clip, duration: offset, filters: [...clip.filters] };+ const head: Clip = {+ ...clip,+ duration: offset,+ filters: [...clip.filters],+ videoEffects: [...clip.videoEffects],+ };const tail: Clip = {...clip,id: nextId("c"),@@ -865,6 +892,11 @@ export function splitClip(project: Project, clipId: string, time: number): Proje// 2x clip the cut is twice as far into the file as it is into the clip.sourceStart: clip.sourceStart + offset * clip.speed,filters: [...clip.filters],+ videoEffects: [...clip.videoEffects],+ // The transition belongs to the cut at the original clip's start, which+ // the head keeps. The split point is continuous material - a transition+ // there would dissolve a frame into its own neighbour.+ transitionIn: undefined,};return {@@ -940,6 +972,29 @@ export function clipsOnTrack(project: Project, trackId: string): Clip[] {*/const JOIN_EPSILON = 1e-6;+/**+ * The clip that ends exactly where this one starts, on the same track - the+ * outgoing half of a cut. This is what a transition needs to exist: no+ * preceding clip, no cut, nothing to transition across.+ *+ * A whole-frame tolerance rather than JOIN_EPSILON, because clips placed by+ * dragging land wherever the pointer was; edges that *look* joined on the+ * timeline should accept a transition.+ */+export function precedingClip(project: Project, clipId: string): Clip | null {+ const clip = findClip(project, clipId);+ if (!clip) return null;+ return (+ project.clips.find(+ (other) =>+ other.id !== clip.id &&+ other.trackId === clip.trackId &&+ other.kind !== "audio" &&+ Math.abs(other.start + other.duration - clip.start) < 1 / 60,+ ) ?? null+ );+}+/*** Why these clips cannot be merged, or `null` if they can.*diff --git a/desktop/src/styles.css b/desktop/src/styles.cssindex 5af3bf8b..e0eeebbc 100644--- a/desktop/src/styles.css+++ b/desktop/src/styles.css@@ -310,3 +310,21 @@outline-offset: 1px;}}++/*+ * The film-grain preview layer: a static noise tile jumped between positions+ * in coarse steps, which reads as new grain per step the way film does. The+ * layer is oversized by its parent so the jumps never expose an edge.+ */+@keyframes wolfcut-grain {+ 0% { transform: translate(0, 0); }+ 20% { transform: translate(-4%, 3%); }+ 40% { transform: translate(3%, -5%); }+ 60% { transform: translate(-5%, -2%); }+ 80% { transform: translate(5%, 4%); }+ 100% { transform: translate(-2%, 5%); }+}++.grain-layer {+ animation: wolfcut-grain 0.5s steps(5, jump-none) infinite;+}diff --git a/engine/crates/relay-core/src/timeline.rs b/engine/crates/relay-core/src/timeline.rsindex 69ec76c9..7ba6594e 100644--- a/engine/crates/relay-core/src/timeline.rs+++ b/engine/crates/relay-core/src/timeline.rs@@ -68,6 +68,16 @@ pub struct Clip {pub speed: Rational,/// Blend factor in `0.0..=1.0`, applied over whatever is beneath.pub opacity: f32,+ /// Ramp the picture's opacity from zero over this many seconds from the+ /// clip's start. Zero means no ramp.+ ///+ /// This is what a cross-dissolve is made of: the incoming clip overlaps+ /// the outgoing one and ramps in on top. It multiplies `opacity`, so a+ /// half-transparent clip fades up to half, not to solid.+ pub video_fade_in: Rational,+ /// Ramp the opacity back to zero over this many seconds into the clip's+ /// end. Zero means no ramp.+ pub video_fade_out: Rational,/// How the picture sits in the frame. Identity is fitted and centred.pub transform: Transform,}@@ -117,10 +127,32 @@ impl Clip {duration,speed: Rational::ONE,opacity: 1.0,+ video_fade_in: Rational::ZERO,+ video_fade_out: Rational::ZERO,transform: Transform::IDENTITY,}}+ /// The opacity ramp factor at `time`, in `0.0..=1.0`.+ ///+ /// One at any instant outside the fade windows, and always one for a clip+ /// with no fades - the common case costs two comparisons. This lives on+ /// the clip, next to `source_time_at`, because it is the same kind of+ /// fact: the one definition every renderer has to agree with.+ pub fn video_fade_factor(&self, time: Rational) -> f32 {+ let mut factor = 1.0f32;+ let local = time - self.start;++ if !self.video_fade_in.is_zero() && local < self.video_fade_in {+ factor *= (local / self.video_fade_in).as_f64().clamp(0.0, 1.0) as f32;+ }+ let remaining = self.duration - local;+ if !self.video_fade_out.is_zero() && remaining < self.video_fade_out {+ factor *= (remaining / self.video_fade_out).as_f64().clamp(0.0, 1.0) as f32;+ }+ factor+ }+/// The span of timeline this clip occupies.pub fn range(&self) -> TimeRange {TimeRange::new(self.start, self.duration)@@ -375,6 +407,30 @@ mod tests {assert_eq!(clip.source_time_at(seconds(3)), Some(seconds(11)));}+ #[test]+ fn video_fades_ramp_and_hold() {+ let (mut timeline, _, id) = fixture(); // covers timeline [2, 5)+ {+ let clip = timeline.clip_mut(id).expect("clip exists");+ clip.video_fade_in = Rational::ONE;+ clip.video_fade_out = Rational::ONE;+ }+ let clip = timeline.clip(id).expect("clip exists");++ assert_eq!(clip.video_fade_factor(seconds(2)), 0.0, "starts at zero");+ assert_eq!(clip.video_fade_factor(Rational::new(5, 2)), 0.5, "halfway up");+ assert_eq!(clip.video_fade_factor(seconds(3)), 1.0, "holds at one between fades");+ assert_eq!(clip.video_fade_factor(Rational::new(9, 2)), 0.5, "halfway down");+ }++ #[test]+ fn no_fade_means_no_attenuation() {+ let (timeline, _, id) = fixture();+ let clip = timeline.clip(id).expect("clip exists");+ assert_eq!(clip.video_fade_factor(seconds(2)), 1.0);+ assert_eq!(clip.video_fade_factor(seconds(4)), 1.0);+ }+#[test]fn finds_the_clip_under_the_playhead() {let (timeline, track, clip) = fixture();diff --git a/engine/crates/relay-media/src/decode.rs b/engine/crates/relay-media/src/decode.rsindex 12f9ad45..bc419c13 100644--- a/engine/crates/relay-media/src/decode.rs+++ b/engine/crates/relay-media/src/decode.rs@@ -74,6 +74,15 @@ pub struct DecodeOptions {/// footage of arbitrary length, and the caller stops pulling when the clip/// ends.pub looping: bool,+ /// Extra FFmpeg video filters, applied after any scaling. Empty for none.+ ///+ /// This is how video effects reach the pixels: the same "one FFmpeg+ /// string" design the audio filters use, so there is no second effect+ /// implementation to drift from. The decoder appends a final scale back+ /// to the requested size, because raw video has no framing - a chain that+ /// changed the frame size would not fail, it would silently shear every+ /// frame after the first.+ pub filter_chain: Option<String>,}impl DecodeOptions {@@ -106,6 +115,31 @@ impl DecodeOptions {self.looping = true;self}++ /// Applies `chain` after scaling. See [`DecodeOptions::filter_chain`].+ pub fn filtered(mut self, chain: impl Into<String>) -> Self {+ let chain = chain.into();+ self.filter_chain = (!chain.is_empty()).then_some(chain);+ self+ }+}++/// The `-vf` argument for these options, or `None` when nothing filters.+///+/// Scale-to-fit first, then the effect chain at output resolution (cheaper+/// than filtering the source size, and parameters mean the same thing at+/// every export size), then the guard scale that pins the frame size the pipe+/// was promised.+fn video_filter(options: &DecodeOptions, width: u32, height: u32) -> Option<String> {+ let mut parts: Vec<String> = Vec::new();+ if options.size.is_some() {+ parts.push(format!("scale={width}:{height}"));+ }+ if let Some(chain) = &options.filter_chain {+ parts.push(chain.clone());+ parts.push(format!("scale={width}:{height}"));+ }+ (!parts.is_empty()).then(|| parts.join(","))}/// Decodes a file by piping raw RGBA out of an `ffmpeg` child process.@@ -161,8 +195,8 @@ impl FfmpegDecoder {if let Some(limit) = options.max_frames {command.args(["-frames:v", &limit.to_string()]);}- if options.size.is_some() {- command.args(["-vf", &format!("scale={width}:{height}")]);+ if let Some(filters) = video_filter(options, width, height) {+ command.args(["-vf", &filters]);}if let Some(rate) = options.frame_rate {command.args(["-r", &fraction(rate)]);@@ -307,6 +341,25 @@ mod tests {assert_eq!(options.size, Some((640, 360)));}+ #[test]+ fn a_filter_chain_is_fenced_by_the_guard_scale() {+ let options = DecodeOptions::default().scaled_to(640, 360).filtered("hue=s=0");+ assert_eq!(+ video_filter(&options, 640, 360).as_deref(),+ Some("scale=640:360,hue=s=0,scale=640:360"),+ );+ }++ #[test]+ fn no_size_and_no_chain_means_no_vf_at_all() {+ assert_eq!(video_filter(&DecodeOptions::default(), 1920, 1080), None);+ }++ #[test]+ fn an_empty_chain_is_no_chain() {+ assert!(DecodeOptions::default().filtered("").filter_chain.is_none());+ }+#[test]fn a_missing_ffmpeg_is_a_spawn_error_not_a_panic() {// Nothing to assert about the happy path without a fixture file, butdiff --git a/engine/crates/relay-render/src/plan.rs b/engine/crates/relay-render/src/plan.rsindex 1ba86e2d..f6d4e103 100644--- a/engine/crates/relay-render/src/plan.rs+++ b/engine/crates/relay-render/src/plan.rs@@ -79,7 +79,9 @@ pub fn plan_frame(timeline: &Timeline, time: Rational) -> FramePlan {media: clip.media.path.clone(),source_time,speed: clip.speed,- opacity: clip.opacity.clamp(0.0, 1.0),+ // The fade ramp multiplies in here, so the compositor only ever+ // sees a per-frame opacity - it has no idea fades exist.+ opacity: (clip.opacity * clip.video_fade_factor(time)).clamp(0.0, 1.0),transform: clip.transform,});}@@ -168,6 +170,19 @@ mod tests {assert!(plan_frame(&timeline, seconds(1)).is_empty());}+ #[test]+ fn a_video_fade_ramps_the_planned_opacity() {+ let mut timeline = Timeline::new(640, 360, FrameRate::THIRTY);+ let track = timeline.add_track(Track::new("V1", TrackKind::Video));+ let mut clip = Clip::new(MediaRef::new("a.mp4"), seconds(0), seconds(4));+ clip.video_fade_in = Rational::from_int(2);+ timeline.add_clip(track, clip).expect("track exists");++ assert_eq!(plan_frame(&timeline, seconds(0)).layers[0].opacity, 0.0);+ assert_eq!(plan_frame(&timeline, seconds(1)).layers[0].opacity, 0.5);+ assert_eq!(plan_frame(&timeline, seconds(3)).layers[0].opacity, 1.0);+ }+#[test]fn clamps_a_nonsense_opacity() {let mut timeline = Timeline::new(640, 360, FrameRate::THIRTY);