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
style: cargo fmt
Jareer3121107dac16
diff --git a/src/crates/concat-effects/src/catalogue.rs b/src/crates/concat-effects/src/catalogue.rsindex 66912484..983d05d5 100644--- a/src/crates/concat-effects/src/catalogue.rs+++ b/src/crates/concat-effects/src/catalogue.rs@@ -588,10 +588,12 @@ impl Package {Value::Float(value) => value,Value::Text(_) => return None,};- Some(match self.manifest.params.iter().find(|param| param.key == knob) {- Some(param) => value.clamp(param.min, param.max),- None => value,- })+ Some(+ match self.manifest.params.iter().find(|param| param.key == knob) {+ Some(param) => value.clamp(param.min, param.max),+ None => value,+ },+ )};let mut params = BTreeMap::new();let mut keys = BTreeMap::new();@@ -1044,10 +1046,16 @@ impl Catalogue {names.extend(package.manifest.effect.aliases.iter().cloned());for name in &names {if self.by_id.contains_key(name) {- return Err(refuse(format!("`{name}` is already taken by another package")));+ return Err(refuse(format!(+ "`{name}` is already taken by another package"+ )));}if let Some(other) = self.packages.iter().find(|other| {- other.manifest.replaces.iter().any(|replaced| replaced.names(name))+ other+ .manifest+ .replaces+ .iter()+ .any(|replaced| replaced.names(name))}) {return Err(refuse(format!("`{name}` is a retired package `{}` stands in for",@@ -1057,7 +1065,11 @@ impl Catalogue {}for replaced in &package.manifest.replaces {let bare = replaced.id.strip_prefix("concat.").unwrap_or(&replaced.id);- if let Some(&index) = self.by_id.get(&replaced.id).or_else(|| self.by_id.get(bare)) {+ if let Some(&index) = self+ .by_id+ .get(&replaced.id)+ .or_else(|| self.by_id.get(bare))+ {return Err(refuse(format!("it replaces `{}`, which is installed as `{}`",replaced.id,@@ -1065,9 +1077,11 @@ impl Catalogue {)));}if let Some(other) = self.packages.iter().find(|other| {- other.manifest.replaces.iter().any(|theirs| {- theirs.names(&replaced.id) || replaced.names(&theirs.id)- })+ other+ .manifest+ .replaces+ .iter()+ .any(|theirs| theirs.names(&replaced.id) || replaced.names(&theirs.id))}) {return Err(refuse(format!("`{}` already stands in for `{}`",@@ -1333,7 +1347,10 @@ mod tests {.add(stand_in(id, replaces).expect("loads")).expect_err(replaces).to_string();- assert!(error.contains(replaces) || error.contains("stands in"), "{error}");+ assert!(+ error.contains(replaces) || error.contains("stands in"),+ "{error}"+ );}let error = catalogue.add(stand_in("concat.box-blur", "nothing.at-all").expect("loads"))@@ -1362,15 +1379,34 @@ mod tests {link.keys.insert("level".into(),vec![- ParamKey { at: 0.0, value: 0.0, ease: KeyEase::LINEAR },- ParamKey { at: 0.5, value: 50.0, ease: KeyEase::LINEAR },- ParamKey { at: 1.0, value: 500.0, ease: KeyEase::LINEAR },+ ParamKey {+ at: 0.0,+ value: 0.0,+ ease: KeyEase::LINEAR,+ },+ ParamKey {+ at: 0.5,+ value: 50.0,+ ease: KeyEase::LINEAR,+ },+ ParamKey {+ at: 1.0,+ value: 500.0,+ ease: KeyEase::LINEAR,+ },],);let upgraded = package.replacing(&link).expect("replaces it");assert_eq!(upgraded.params["stops"], 0.5);- let run: Vec<(f64, f64)> = upgraded.keys["stops"].iter().map(|k| (k.at, k.value)).collect();- assert_eq!(run, vec![(0.0, 0.0), (0.5, 1.0), (1.0, 2.0)], "held to the new most");+ let run: Vec<(f64, f64)> = upgraded.keys["stops"]+ .iter()+ .map(|k| (k.at, k.value))+ .collect();+ assert_eq!(+ run,+ vec![(0.0, 0.0), (0.5, 1.0), (1.0, 2.0)],+ "held to the new most"+ );}/// A chain reads the frame and its own table and no other file.diff --git a/src/crates/concat-export/src/lib.rs b/src/crates/concat-export/src/lib.rsindex 69cccba9..b5bdd8bf 100644--- a/src/crates/concat-export/src/lib.rs+++ b/src/crates/concat-export/src/lib.rs@@ -612,15 +612,7 @@ fn resolve_transitions(clips: &mut Vec<ExportClip>, rate: FrameRate) -> Vec<Tran// which settles from a little large to its own size."zoom" => {rides(clips, cut.outgoing, incoming, "scale")- && ride(- &mut clips[incoming],- "scale",- 1.25,- 1.0,- d,- true,- EASE_OUT,- )+ && ride(&mut clips[incoming], "scale", 1.25, 1.0, d, true, EASE_OUT)&& ride(&mut clips[cut.outgoing],"scale",@@ -2523,7 +2515,10 @@ mod tests {assert_eq!((b.start, b.duration, b.source_start), (4.0, 4.0, 0.0));assert_eq!(b.video_fade_in, 0.0);let hold = &clips[2];- assert_eq!((hold.start, hold.duration, hold.source_start), (3.0, 1.0, 0.0));+ assert_eq!(+ (hold.start, hold.duration, hold.source_start),+ (3.0, 1.0, 0.0)+ );assert_eq!(hold.video_fade_in, 1.0);}@@ -2574,10 +2569,20 @@ mod tests {let hold = &clips[2];assert_eq!(keys_on(hold, "offsetX"), vec![(0.0, 1.0), (1.0, 0.0)]);- assert!(keys_on(hold, "scale").is_empty(), "the ride stays on the clip");+ assert!(+ keys_on(hold, "scale").is_empty(),+ "the ride stays on the clip"+ );assert_eq!(hold.scale, 2.0, "held where the ride starts");- assert_eq!(keys_on(&clips[0], "offsetX"), vec![(0.75, 0.0), (1.0, -1.0)]);- assert_eq!(keys_on(&clips[1], "scale").len(), 2, "the user's keys are untouched");+ assert_eq!(+ keys_on(&clips[0], "offsetX"),+ vec![(0.75, 0.0), (1.0, -1.0)]+ );+ assert_eq!(+ keys_on(&clips[1], "scale").len(),+ 2,+ "the user's keys are untouched"+ );assert!(keys_on(&clips[1], "offsetX").is_empty());}diff --git a/src/crates/concat-host/src/dirs.rs b/src/crates/concat-host/src/dirs.rsindex e0d620d8..575855d6 100644--- a/src/crates/concat-host/src/dirs.rs+++ b/src/crates/concat-host/src/dirs.rs@@ -95,13 +95,13 @@ impl AppDirs {/// The folders under `data`, each named where it is made: models, caches/// and logs. What is not listed is the settings', and stays in `config`.const DATA_FOLDERS: [&str; 7] = [- "cutout-models", // concat-vision, models.rs- "whisper-models", // concat-speech, transcribe.rs- "tts-models", // concat-speech, tts.rs- "cards", // concat, studio.rs- "titles", // titles.rs- "updates", // updates.rs- "logs", // logs.rs+ "cutout-models", // concat-vision, models.rs+ "whisper-models", // concat-speech, transcribe.rs+ "tts-models", // concat-speech, tts.rs+ "cards", // concat, studio.rs+ "titles", // titles.rs+ "updates", // updates.rs+ "logs", // logs.rs];/// Moves what an older build kept under `from` - Windows kept models anddiff --git a/src/crates/concat-host/src/titles.rs b/src/crates/concat-host/src/titles.rsindex 0cfb183f..a719083b 100644--- a/src/crates/concat-host/src/titles.rs+++ b/src/crates/concat-host/src/titles.rs@@ -667,7 +667,6 @@ mod tests {let _ = std::fs::remove_dir_all(dirs.data.parent().unwrap());}-/// A shape clip rejoins the flattened list as a still at its clip's/// stretch - that is how a square becomes a rectangle - with the/// figure's box reported and no words to reveal.diff --git a/src/crates/concat-media/src/encode.rs b/src/crates/concat-media/src/encode.rsindex d5c471a3..b57e0acc 100644--- a/src/crates/concat-media/src/encode.rs+++ b/src/crates/concat-media/src/encode.rs@@ -454,7 +454,13 @@ fn takes_ten_bits(encoder_name: &str) -> bool {/// bitrate alone: the export sheet's rule for its size estimate - 16 Mb/s/// for H.264 at 1080p30 and CRF 16, halving about every five steps -/// scaled by the pixels, the rate and the codec's size factor.-fn implied_kbps(codec: VideoCodec, crf: u8, width: u32, height: u32, rate: ffmpeg::Rational) -> u32 {+fn implied_kbps(+ codec: VideoCodec,+ crf: u8,+ width: u32,+ height: u32,+ rate: ffmpeg::Rational,+) -> u32 {let fps = f64::from(rate.numerator()) / f64::from(rate.denominator().max(1));let pixels = f64::from(width) * f64::from(height) / (1920.0 * 1080.0);let mbps = 16.0@@ -1531,11 +1537,23 @@ mod tests {#[test]fn a_bitrate_steered_encoder_gets_what_the_crf_comes_to() {let thirty = ffmpeg::Rational::new(30, 1);- assert_eq!(implied_kbps(VideoCodec::H264, 16, 1920, 1080, thirty), 16_000);- assert_eq!(implied_kbps(VideoCodec::H264, 26, 1920, 1080, thirty), 4_000);- assert_eq!(implied_kbps(VideoCodec::Hevc, 16, 1920, 1080, thirty), 9_600);+ assert_eq!(+ implied_kbps(VideoCodec::H264, 16, 1920, 1080, thirty),+ 16_000+ );+ assert_eq!(+ implied_kbps(VideoCodec::H264, 26, 1920, 1080, thirty),+ 4_000+ );+ assert_eq!(+ implied_kbps(VideoCodec::Hevc, 16, 1920, 1080, thirty),+ 9_600+ );let sixty = ffmpeg::Rational::new(60, 1);- assert_eq!(implied_kbps(VideoCodec::H264, 16, 3840, 2160, sixty), 128_000);+ assert_eq!(+ implied_kbps(VideoCodec::H264, 16, 3840, 2160, sixty),+ 128_000+ );// A thumbnail-sized file still gets a rate a chip will take.assert_eq!(implied_kbps(VideoCodec::H264, 26, 64, 64, thirty), 500);}@@ -1546,8 +1564,14 @@ mod tests {fn each_encoder_family_takes_its_own_pictures() {assert_eq!(Family::of("libx264").pixel_format(false), Pixel::YUV420P);assert_eq!(Family::of("libx265").pixel_format(true), Pixel::YUV420P10LE);- assert_eq!(Family::of("hevc_videotoolbox").pixel_format(true), Pixel::P010LE);- assert_eq!(Family::of("h264_mediacodec").pixel_format(false), Pixel::NV12);+ assert_eq!(+ Family::of("hevc_videotoolbox").pixel_format(true),+ Pixel::P010LE+ );+ assert_eq!(+ Family::of("h264_mediacodec").pixel_format(false),+ Pixel::NV12+ );assert!(Family::of("h264_mediacodec").steered_by_bitrate());assert!(!Family::of("libx264").steered_by_bitrate());assert!(takes_ten_bits("libx265") && takes_ten_bits("hevc_videotoolbox"));diff --git a/src/crates/concat-media/src/samples.rs b/src/crates/concat-media/src/samples.rsindex 30c9ba2a..44af16ba 100644--- a/src/crates/concat-media/src/samples.rs+++ b/src/crates/concat-media/src/samples.rs@@ -460,9 +460,16 @@ mod tests {);}let loud = |range: std::ops::Range<usize>| {- samples[range].iter().map(|s| s.abs()).fold(0.0_f32, f32::max)+ samples[range]+ .iter()+ .map(|s| s.abs())+ .fold(0.0_f32, f32::max)};- assert!(samples.len() >= 7_600, "a second of sound, got {}", samples.len());+ assert!(+ samples.len() >= 7_600,+ "a second of sound, got {}",+ samples.len()+ );assert!(loud(0..3_800) < 0.01, "silence before the tone");assert!(loud(4_200..7_600) > 0.08, "the tone after half a second");}diff --git a/src/crates/concat-project/src/commands/clips.rs b/src/crates/concat-project/src/commands/clips.rsindex 71a07639..73c29b7a 100644--- a/src/crates/concat-project/src/commands/clips.rs+++ b/src/crates/concat-project/src/commands/clips.rs@@ -158,7 +158,8 @@ pub(super) fn apply(} else {name};- let mut clip = Clip::blank(id.clone(), track_id, ClipKind::Shape, name, start, duration);+ let mut clip =+ Clip::blank(id.clone(), track_id, ClipKind::Shape, name, start, duration);clip.shape = Some(style);timeline.clips.push(Arc::new(clip));Ok(Outcome {diff --git a/src/crates/concat-project/src/commands/mod.rs b/src/crates/concat-project/src/commands/mod.rsindex 8b5564dd..f0146d16 100644--- a/src/crates/concat-project/src/commands/mod.rs+++ b/src/crates/concat-project/src/commands/mod.rs@@ -14,8 +14,8 @@ use serde::{Deserialize, Serialize};use crate::model::{AppliedFilter, AudioTrack, Clip, ClipKind, ColorRange, ColorSpace, Crop, CustomFont, Cutout,- CutoutMode, KeyEase, KeyProperty, MediaItem, MediaKind, MediaOrigin, Project, SpeedPoint,- ShapeStyle, Stroke, TextStyle, Timeline, Track, Transition, VideoSettings,+ CutoutMode, KeyEase, KeyProperty, MediaItem, MediaKind, MediaOrigin, Project, ShapeStyle,+ SpeedPoint, Stroke, TextStyle, Timeline, Track, Transition, VideoSettings,};mod audio;diff --git a/src/crates/concat-project/src/lib.rs b/src/crates/concat-project/src/lib.rsindex a9794771..15ca1ef3 100644--- a/src/crates/concat-project/src/lib.rs+++ b/src/crates/concat-project/src/lib.rs@@ -3789,7 +3789,6 @@ mod tests {assert_eq!(missing.len(), 0);}-#[test]fn shape_clips_survive_without_media_and_carry_their_figure() {use crate::model::{ClipKind, ShapeKind, ShapeStyle};@@ -3846,6 +3845,9 @@ mod tests {let clip = editor.project().active().clip(&wild).expect("exists");let shape = clip.shape.as_ref().expect("figure");assert_eq!((shape.size, shape.stroke_width), (2.0, 0.0));- assert_eq!(clip.name, "square", "an empty name falls back to the figure's");+ assert_eq!(+ clip.name, "square",+ "an empty name falls back to the figure's"+ );}}diff --git a/src/crates/concat-render/src/gpu.rs b/src/crates/concat-render/src/gpu.rsindex 14b4035a..a536314b 100644--- a/src/crates/concat-render/src/gpu.rs+++ b/src/crates/concat-render/src/gpu.rs@@ -768,7 +768,11 @@ impl WgpuCompositor {backends,..wgpu::InstanceDescriptor::new_without_display_handle()});- let choices: &[bool] = if software_only { &[true] } else { &[false, true] };+ let choices: &[bool] = if software_only {+ &[true]+ } else {+ &[false, true]+ };choices.iter().copied().find_map(|software| {let adapter =pollster::block_on(instance.request_adapter(&wgpu::RequestAdapterOptions {@@ -783,7 +787,9 @@ impl WgpuCompositor {// The reason, when it dies, in the log: see the window's device.let name = adapter.get_info().name;device.set_device_lost_callback(move |reason, message| {- log::error!("the compositor's GPU device on {name} was lost ({reason:?}): {message}");+ log::error!(+ "the compositor's GPU device on {name} was lost ({reason:?}): {message}"+ );});Some(Self::with_device(device, queue))})diff --git a/src/crates/concat-text/src/lib.rs b/src/crates/concat-text/src/lib.rsindex 75f52dd6..b052d29a 100644--- a/src/crates/concat-text/src/lib.rs+++ b/src/crates/concat-text/src/lib.rs@@ -436,7 +436,8 @@ impl Fonts {let mut last = 0;for (at, ch) in text.char_indices() {let covers = cache.covers.get(&ch).map_or(&[][..], Vec::as_slice);- let lends = |ids: &[fontdb::ID], index: usize| index != 0 && covers.contains(&ids[index]);+ let lends =+ |ids: &[fontdb::ID], index: usize| index != 0 && covers.contains(&ids[index]);let index = if joins(ch) && at > 0 {// A mark, a joiner, a skin tone: with what it modifies.last@@ -717,7 +718,10 @@ impl Setter<'_> {x: pen + position.x_offset as f32 * scale,y: -(position.y_offset as f32 * scale),};- face.outline_glyph(ttf_parser::GlyphId(info.glyph_id as u16), &mut outliner);+ face.outline_glyph(+ ttf_parser::GlyphId(info.glyph_id as u16),+ &mut outliner,+ );}let advance = position.x_advance as f32 * scale;spans.push((piece.start + info.cluster as usize, pen, pen + advance));@@ -1284,7 +1288,9 @@ fn paint_shape(style: &ShapeStyle, width: u32, height: u32) -> Result<(Pixmap, Blet mut path = PathBuilder::new();let closed = match style.figure {Figure::Square => {- path.push_rect(Rect::from_ltrb(left, top, right, bottom).ok_or(Error::Canvas(width, height))?);+ path.push_rect(+ Rect::from_ltrb(left, top, right, bottom).ok_or(Error::Canvas(width, height))?,+ );true}Figure::Circle => {@@ -1364,7 +1370,9 @@ fn paint_shape(style: &ShapeStyle, width: u32, height: u32) -> Result<(Pixmap, BNone,);}- if rule > 0.0 && let Some(edge) = edge {+ if rule > 0.0+ && let Some(edge) = edge+ {canvas.stroke_path(&path,&stroke(edge),@@ -1373,7 +1381,9 @@ fn paint_shape(style: &ShapeStyle, width: u32, height: u32) -> Result<(Pixmap, BNone,);}- } else if rule > 0.0 && let Some(ink) = edge.or(fill) {+ } else if rule > 0.0+ && let Some(ink) = edge.or(fill)+ {// A line or an arrow is all stroke, in the outline's colour when// one is set, else the fill's.canvas.stroke_path(@@ -1387,7 +1397,11 @@ fn paint_shape(style: &ShapeStyle, width: u32, height: u32) -> Result<(Pixmap, B// The box the monitor outlines: the figure, plus the outline that// straddles its edge.- let grown = if closed && rule > 0.0 && edge.is_some() { rule } else { 0.0 };+ let grown = if closed && rule > 0.0 && edge.is_some() {+ rule+ } else {+ 0.0+ };let block = ((w + grown).ceil().max(1.0) as u32,(h + grown).ceil().max(1.0) as u32,@@ -1928,7 +1942,6 @@ mod tests {assert!(plated.block_height > one.block_height);}-/// A shape is painted centred, at the size the style says, and a rule/// is all stroke in the fill's colour when no outline colour is given.#[test]diff --git a/src/crates/concat/src/studio.rs b/src/crates/concat/src/studio.rsindex 355e9be0..dc2d3807 100644--- a/src/crates/concat/src/studio.rs+++ b/src/crates/concat/src/studio.rs@@ -2083,9 +2083,9 @@ impl Studio {// A title is its name strip alone; a layer has no// picture at all; a shape's name says what it is.// None needs a body's height.- model::ClipKind::Text- | model::ClipKind::Layer- | model::ClipKind::Shape => LANE_SMALL,+ model::ClipKind::Text | model::ClipKind::Layer | model::ClipKind::Shape => {+ LANE_SMALL+ }}).fold(0.0_f32, f32::max);if tallest > 0.0 { tallest } else { LANE_MEDIUM }@@ -3219,7 +3219,13 @@ impl Studio {let created = if plan.kind == ClipKind::Text {self.add_title(None, start, f64::from(plan.duration), &plan.media)} else if plan.kind == ClipKind::Shape {- self.add_shape(None, start, f64::from(plan.duration), &plan.media, &plan.label)+ self.add_shape(+ None,+ start,+ f64::from(plan.duration),+ &plan.media,+ &plan.label,+ )} else if plan.kind == ClipKind::Filter {self.apply(Command::AddLayerClip {track_id: None,@@ -4733,9 +4739,7 @@ impl Studio {let (w, h) = match shape.kind {model::ShapeKind::Square | model::ShapeKind::Circle => (side, side),model::ShapeKind::Triangle => (side, side * 0.866),- model::ShapeKind::Parallelogram | model::ShapeKind::Trapezoid => {- (side, side * 0.6)- }+ model::ShapeKind::Parallelogram | model::ShapeKind::Trapezoid => (side, side * 0.6),model::ShapeKind::Line => (side, shape.stroke_width * height),model::ShapeKind::Arrow => (side, (shape.stroke_width * 4.0).max(0.18) * side),};@@ -6685,7 +6689,10 @@ impl Studio {.map(|session| upgraded_effects(session.upgraded())).unwrap_or_default();if !upgraded.is_empty() {- self.notify(&tf("studio.upgradedEffects", &[&upgraded.join(", ")]), false);+ self.notify(+ &tf("studio.upgradedEffects", &[&upgraded.join(", ")]),+ false,+ );}// Log missing media to file for debugging