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
Filmstrips on the lanes, space to play, and a context menu that acts
Jareer568bd6ec966d
diff --git a/engine/crates/concat/src/host.rs b/engine/crates/concat/src/host.rsindex 90e50912..f9922c6e 100644--- a/engine/crates/concat/src/host.rs+++ b/engine/crates/concat/src/host.rs@@ -173,8 +173,19 @@ pub struct MediaArt {pub thumbnail: Option<concat_core::frame::Frame>,/// The waveform, for anything with sound.pub peaks: Option<Arc<concat_media::Peaks>>,+ /// Frames sampled evenly across the footage, side by side in one+ /// picture, and how many there are. A still is a strip of one.+ pub strip: Option<(concat_core::frame::Frame, u32)>,}+/// Frames in a filmstrip, and the strip's height in logical pixels.+///+/// Twenty-four across a file is enough that a clip a few seconds long+/// shows different pictures along its length; the height is the tallest+/// lane's body, so the lanes never upscale it.+const STRIP_FRAMES: u32 = 24;+const STRIP_HEIGHT: u32 = 64;+/// Decodes the art for one media item. `project` is where the peaks cache/// lives.pub fn media_art(@@ -196,9 +207,17 @@ pub fn media_art(let peaks = (kind == MediaKind::Audio || has_audio).then(|| media::peaks(&path, Some(&project)).ok().map(Arc::new)).flatten();+ let strip = match kind {+ MediaKind::Video => media::filmstrip(&path, STRIP_FRAMES, STRIP_HEIGHT)+ .ok()+ .map(|frame| (frame, STRIP_FRAMES)),+ MediaKind::Image => thumbnail.clone().map(|frame| (frame, 1)),+ MediaKind::Audio => None,+ };MediaArt {id,thumbnail,peaks,+ strip,}}diff --git a/engine/crates/concat/src/main.rs b/engine/crates/concat/src/main.rsindex dde1bf2f..fbf8117b 100644--- a/engine/crates/concat/src/main.rs+++ b/engine/crates/concat/src/main.rs@@ -660,7 +660,10 @@ fn main() -> Result<(), slint::PlatformError> {state.menu_target = Some(id.to_string());}));editor.on_menu_selected(on_window!(|state, action: SharedString| {- let Some(id) = state.menu_target.clone() else {+ // The clip the menu was opened on; failing that, the one clip that+ // is selected, which is what the menu was showing anyway.+ let target = state.menu_target.clone().or_else(|| state.sole_selection());+ let Some(id) = target else {return;};let Some(clip) = state.clip(&id).cloned() else {diff --git a/engine/crates/concat/src/studio.rs b/engine/crates/concat/src/studio.rsindex e2973175..72cf4374 100644--- a/engine/crates/concat/src/studio.rs+++ b/engine/crates/concat/src/studio.rs@@ -70,6 +70,18 @@ const LANE_SMALL: f32 = 40.0;/// enough that trimming it is a nudge rather than a fight.const LAYER_DURATION: f32 = 3.0;+/// One media item's filmstrip, as the lanes tile it.+pub struct Strip {+ /// Every sampled frame side by side.+ pub image: slint::Image,+ /// How many frames the picture holds.+ pub frames: i32,+ /// One frame's width in the picture's pixels.+ pub frame_width: i32,+ /// The picture's height in its own pixels.+ pub height: i32,+}+/// Steps per second the drawn waveform is quantised to. See `Studio::wave`:/// it is what keeps a trim from synthesising a new envelope on every pointer/// event, and the grid is fine enough that no step of it is visible.@@ -362,6 +374,9 @@ pub struct Studio {/// Decoded art by media id, and the ids a worker is decoding for.pub peaks: HashMap<String, Arc<Peaks>>,pub thumbs: HashMap<String, slint::Image>,+ /// Filmstrips by media id: the picture, how many frames are in it, one+ /// frame's width and the strip's height, in the picture's own pixels.+ pub strips: HashMap<String, Strip>,art_pending: HashSet<String>,/// Envelopes, keyed by the things they are computed from. A move/// changes none of them, and a publish happens on every frame of one.@@ -487,6 +502,7 @@ impl Studio {media_filter: MediaFilter::All,peaks: HashMap::new(),thumbs: HashMap::new(),+ strips: HashMap::new(),art_pending: HashSet::new(),waves: RefCell::new(HashMap::new()),lane_view: HashMap::new(),@@ -1088,8 +1104,8 @@ impl Studio {.filter(|item| !item.placeholder && !item.path.is_empty()).filter(|item| !self.art_pending.contains(&item.id)).filter(|item| {- let needs_thumb =- item.kind != model::MediaKind::Audio && !self.thumbs.contains_key(&item.id);+ let needs_thumb = item.kind != model::MediaKind::Audio+ && (!self.thumbs.contains_key(&item.id) || !self.strips.contains_key(&item.id));let needs_peaks = (item.kind == model::MediaKind::Audio || item.has_audio)&& !self.peaks.contains_key(&item.id);needs_thumb || needs_peaks@@ -1114,6 +1130,15 @@ impl Studio {if let Some(frame) = art.thumbnail {studio.thumbs.insert(art.id.clone(), image_of(&frame));}+ if let Some((frame, frames)) = art.strip {+ let strip = Strip {+ image: image_of(&frame),+ frames: frames as i32,+ frame_width: (frame.width() / frames.max(1)) as i32,+ height: frame.height() as i32,+ };+ studio.strips.insert(art.id.clone(), strip);+ }if let Some(peaks) = art.peaks {studio.peaks.insert(art.id.clone(), peaks);let prefix = format!("{}|", art.id);@@ -1127,6 +1152,42 @@ impl Studio {}}+ /// The clip's filmstrip, with the window of the strip its cut covers:+ /// where in the footage it starts and how much of the footage it spans,+ /// both as fractions, so the lane can pick the frame under each tile+ /// without knowing about speed or source time.+ fn strip_of(&self, clip: &Clip) -> StripData {+ if !matches!(clip.kind, model::ClipKind::Video | model::ClipKind::Image) {+ return StripData::default();+ }+ let Some(strip) = self.strips.get(&clip.media_id) else {+ return StripData::default();+ };+ let footage = self+ .project()+ .media+ .iter()+ .find(|item| item.id == clip.media_id)+ .and_then(|item| item.duration)+ .filter(|seconds| *seconds > 0.0);+ let (start, span) = match footage {+ Some(seconds) => (+ (clip.source_start / seconds).clamp(0.0, 1.0),+ (clip.duration * clip.speed / seconds).clamp(0.0, 1.0),+ ),+ // A still, or footage of unknown length: one frame, all of it.+ None => (0.0, 1.0),+ };+ StripData {+ image: strip.image.clone(),+ frames: strip.frames,+ frame_width: strip.frame_width,+ height: strip.height,+ start: start as f32,+ span: span as f32,+ }+ }+/// The memoised envelope for one clip, quantised to a thirtieth of a/// second so a trim revisits a handful of entries rather than minting/// one per pointer event.@@ -1264,7 +1325,7 @@ impl Studio {}/// The selected clip's id, when exactly one is selected.- fn sole_selection(&self) -> Option<String> {+ pub fn sole_selection(&self) -> Option<String> {(self.selection.len() == 1).then(|| self.selection[0].clone())}@@ -2562,6 +2623,7 @@ impl Studio {} else {SharedString::new()},+ strip: self.strip_of(clip),}).collect(),);diff --git a/engine/crates/concat/ui/app.slint b/engine/crates/concat/ui/app.slintindex 31e3c009..d03f92b7 100644--- a/engine/crates/concat/ui/app.slint+++ b/engine/crates/concat/ui/app.slint@@ -205,6 +205,17 @@ export component App inherits Window {activated => { root.app-menu-selected("save"); }}+ // Space plays and pauses, the way it does in every editor. It lands+ // here only when nothing else took it: a field being typed into+ // consumes its own spaces before the key can walk up to this scope.+ key-pressed(event) => {+ if event.text == Key.Space && !root.on-start {+ Editor.play-toggled();+ return accept;+ }+ return reject;+ }+VerticalLayout {width: 100%;height: 100%;diff --git a/engine/crates/concat/ui/primitives/context-menu.slint b/engine/crates/concat/ui/primitives/context-menu.slintindex 52d2524f..db31ba5f 100644--- a/engine/crates/concat/ui/primitives/context-menu.slint+++ b/engine/crates/concat/ui/primitives/context-menu.slint@@ -202,8 +202,10 @@ export component ContextMenu inherits Rectangle {enabled: item.enabled;mouse-cursor: pointer;clicked => {- surface.close();+ // Report first, then close: the row's data is+ // certain while the row still exists.root.selected(item.id);+ surface.close();}}}diff --git a/engine/crates/concat/ui/timeline/lanes.slint b/engine/crates/concat/ui/timeline/lanes.slintindex 6a374962..34a4c3c3 100644--- a/engine/crates/concat/ui/timeline/lanes.slint+++ b/engine/crates/concat/ui/timeline/lanes.slint@@ -148,14 +148,48 @@ component Clip inherits Rectangle {overflow: elide;}- // The filmstrip slot: the clip's frames tile here once the window- // supplies them. Until then a picture clip shows its kind's mark the+ // The filmstrip. Tiles are the strip's frames at the body's height,+ // and each tile shows the frame under its own midpoint: the clip+ // covers `span` of the footage from `start`, so a tile a fraction f+ // along the clip wants the frame at start + span * f. Every tile is+ // one Image with a source clip, so a zoom changes how many tiles+ // there are and which frame each picks, never the picture itself.+ if root.item.strip.frames > 0 && root.width > 8px: Rectangle {+ x: 0;+ y: 0;+ width: parent.width;+ height: parent.height;+ clip: true;++ property <length> tile-w: Math.max(4px,+ parent.height * root.item.strip.frame-width / Math.max(1, root.item.strip.height));+ property <int> tiles: Math.min(400, Math.ceil(parent.width / self.tile-w));++ for i in self.tiles: Image {+ x: i * parent.tile-w;+ y: 0;+ width: parent.tile-w;+ height: parent.height;+ source: root.item.strip.image;+ image-fit: fill;+ source-clip-x: Math.clamp(+ Math.floor(root.item.strip.frames * (root.item.strip.start+ + root.item.strip.span * ((i + 0.5) * parent.tile-w / parent.width))),+ 0, root.item.strip.frames - 1) * root.item.strip.frame-width;+ source-clip-y: 0;+ source-clip-width: root.item.strip.frame-width;+ source-clip-height: root.item.strip.height;+ }+ }++ // Before the frames arrive, a picture clip shows its kind's mark the// way a bin card does — faint and large, so it reads as a placeholder// and not as a badge. A filter layer takes the same treatment for the// opposite reason: there is no picture to draw, and there never will// be one.- if (root.item.kind == ClipKind.video || root.item.kind == ClipKind.image- || root.item.kind == ClipKind.filter) && root.width > 40px: Icon {+ if (((root.item.kind == ClipKind.video || root.item.kind == ClipKind.image)+ && root.item.strip.frames == 0) || root.item.kind == ClipKind.filter)+ && root.width > 40px: Icon {x: (parent.width - self.width) / 2;y: (parent.height - self.height) / 2;glyph: root.badge;@@ -312,10 +346,14 @@ component Clip inherits Rectangle {pointer-event(event) => {// The right button opens the menu and does nothing else — it must// not also start a move, or the menu would appear over a clip that- // had already jumped.- if (event.kind == PointerEventKind.down- && event.button == PointerEventButton.right) {- root.context-requested();+ // had already jumped. On the release, not the press: a press+ // holds the pointer for this area until the button comes up, and+ // a menu that opens under a held button is a menu whose first+ // click goes to the wrong element.+ if (event.button == PointerEventButton.right) {+ if (event.kind == PointerEventKind.up) {+ root.context-requested();+ }return;}if (event.kind == PointerEventKind.downdiff --git a/engine/crates/concat/ui/timeline/model.slint b/engine/crates/concat/ui/timeline/model.slintindex 3e22c86e..8ba1cf34 100644--- a/engine/crates/concat/ui/timeline/model.slint+++ b/engine/crates/concat/ui/timeline/model.slint@@ -64,6 +64,22 @@ export struct TrackData {locked: bool,}+/// A media item's filmstrip and the window of it one clip shows.+///+/// The strip is one picture holding `frames` frames side by side, each+/// `frame-width` wide and `height` tall in the picture's own pixels. `start`+/// and `span` are fractions of the footage: where the clip's cut begins and+/// how much it covers, so the lane can pick the frame under any tile with+/// one multiplication and never needs to know about speed or source time.+export struct StripData {+ image: image,+ frames: int,+ frame-width: int,+ height: int,+ start: float,+ span: float,+}+/// One placed clip, already reduced to what drawing it needs.////// Positions are in *seconds*, not pixels. Zoom and pan are then a property@@ -97,8 +113,12 @@ export struct ClipData {/// that draws it is `fit: fill`, which stretches the box onto whatever/// width the clip currently has. Built once in Rust, where the peaks are.wave: string,+ /// The frames a picture clip tiles along its body; `frames` is 0 when+ /// there are none yet.+ strip: StripData,}+/// What a drag from the library will leave on the timeline if it is released/// where the pointer is now.///