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
perf(monitor): publish only the picture for a frame during playback
marcinx98xee28f253a3ce
diff --git a/src/crates/concat/src/host.rs b/src/crates/concat/src/host.rsindex f23b0978..a81309ae 100644--- a/src/crates/concat/src/host.rs+++ b/src/crates/concat/src/host.rs@@ -223,6 +223,26 @@ pub fn spawn_in_project<T: Send + 'static>(spawn_detached(move || deliver(Some(epoch), work(), then));}+/// [`spawn_in_project`] for the monitor's frames. While playback runs a+/// frame arrives every few dozen milliseconds and changes nothing but the+/// picture, so only the picture is published then; the transport's own+/// tick publishes the lanes. Otherwise it is a full publish as usual.+pub fn spawn_frame<T: Send + 'static>(+ work: impl FnOnce() -> T + Send + 'static,+ then: impl FnOnce(&mut Studio, &App, &Models, T) + Send + 'static,+) {+ let epoch = project_epoch();+ spawn_detached(move || {+ deliver_then(Some(epoch), work(), then, |studio, app, models| {+ if studio.playing {+ studio.publish_frame(app, models);+ } else {+ studio.publish(app, models);+ }+ });+ });+}+/// Hands a worker's result to the event-loop thread: `then` with the state/// and the window, and a full publish after it. A result made in a project/// epoch that has passed is dropped here.@@ -230,6 +250,16 @@ fn deliver<T: Send + 'static>(epoch: Option<u64>,result: T,then: impl FnOnce(&mut Studio, &App, &Models, T) + Send + 'static,+) {+ deliver_then(epoch, result, then, Studio::publish);+}++/// [`deliver`] with the publish after `then` chosen by the caller.+fn deliver_then<T: Send + 'static>(+ epoch: Option<u64>,+ result: T,+ then: impl FnOnce(&mut Studio, &App, &Models, T) + Send + 'static,+ publish: impl FnOnce(&Studio, &App, &Models) + Send + 'static,) {let _ = slint::invoke_from_event_loop(move || {Shell::with(|shell, app| {@@ -240,7 +270,7 @@ fn deliver<T: Send + 'static>(let mut studio = shell.studio.borrow_mut();then(&mut studio, &app, &shell.models, result);}- shell.studio.borrow().publish(&app, &shell.models);+ publish(&shell.studio.borrow(), &app, &shell.models);});});}diff --git a/src/crates/concat/src/panes/monitor.rs b/src/crates/concat/src/panes/monitor.rsindex eb921630..4787d97a 100644--- a/src/crates/concat/src/panes/monitor.rs+++ b/src/crates/concat/src/panes/monitor.rs@@ -22,7 +22,7 @@ use std::sync::Arc;use concat_host::preview::{FrameSpec, scopes};use concat_project::model::Project;-use crate::host::{on_ui, spawn_detached, spawn_in_project};+use crate::host::{on_ui, spawn_detached, spawn_frame};use crate::i18n::tf;use crate::panes::Msg;use crate::studio::Studio;@@ -315,7 +315,7 @@ impl MonitorPane {self.busy = true;self.wanted = false;self.asked = Some(std::time::Instant::now());- spawn_in_project(+ spawn_frame(move || {// On the window's device the frame stays a texture; without// one it comes back as pixels and is uploaded here.diff --git a/src/crates/concat/src/studio.rs b/src/crates/concat/src/studio.rsindex e7ae2987..6c4ab7eb 100644--- a/src/crates/concat/src/studio.rs+++ b/src/crates/concat/src/studio.rs@@ -7388,6 +7388,24 @@ impl Studio {}}+ /// The monitor's picture and the scope counted from it, alone: what a+ /// frame arriving during playback changes.+ pub fn publish_frame(&self, app: &App, models: &Models) {+ app.global::<Editor>()+ .set_preview_frame(self.monitor.image.clone());+ let scopes = app.global::<Scopes>();+ scopes.set_kind(self.monitor.scope_kind as i32);+ match &self.monitor.scope {+ Some((picture, marks, hdr)) => {+ scopes.set_picture(picture.clone());+ sync(&models.scope_marks, marks.clone());+ scopes.set_hdr(*hdr);+ scopes.set_ready(true);+ }+ None => scopes.set_ready(false),+ }+ }+/// The timeline and the readouts that follow it: what runs on every/// event of a scrub, a drag, a trim or a knob.pub fn publish_lanes(&self, app: &App, models: &Models) {@@ -7510,18 +7528,7 @@ impl Studio {editor.set_preview_duration(self.duration());editor.set_playhead_free(!self.prefs.playhead_stops_at_end);editor.set_playing(self.playing);- editor.set_preview_frame(self.monitor.image.clone());- let scopes = app.global::<Scopes>();- scopes.set_kind(self.monitor.scope_kind as i32);- match &self.monitor.scope {- Some((picture, marks, hdr)) => {- scopes.set_picture(picture.clone());- sync(&models.scope_marks, marks.clone());- scopes.set_hdr(*hdr);- scopes.set_ready(true);- }- None => scopes.set_ready(false),- }+ self.publish_frame(app, models);sync(&models.stage, self.stage_items());sync(&models.guides, self.stage_guides.clone());let (path, width, erase) = self.stroke_overlay();