Skip to content

The truly free, open-source, local-first, cross-platform CapCut replacement. Scriptable through a JSON-RPC API & MCP.

feat(inspector): Enhance has a page of its own, and Enhance and background removal switch from their headers

Jareer8b3afff2ce98
diff --git a/src/crates/concat-project/src/commands/clips.rs b/src/crates/concat-project/src/commands/clips.rs
index 73c29b7a..9decd2ba 100644
--- a/src/crates/concat-project/src/commands/clips.rs
+++ b/src/crates/concat-project/src/commands/clips.rs
@@ -358,6 +358,7 @@ pub(super) fn apply(
clip_id,
item,
source_start,
+ enhanced,
} => {
if project.active().clip(&clip_id).is_none() {
return Ok(Outcome::default());
@@ -396,9 +397,26 @@ pub(super) fn apply(
return Ok(Outcome::default());
};
let clip = timeline.clip_at_mut(index);
+ let link = if enhanced {
+ // The original is the one Enhance started from, kept through
+ // a second run on a clip already showing a copy.
+ let original = clip
+ .enhanced
+ .as_ref()
+ .map(|link| link.original.clone())
+ .unwrap_or_else(|| clip.media_id.clone());
+ Some(Enhanced {
+ original,
+ copy: media_id.clone(),
+ on: true,
+ })
+ } else {
+ None
+ };
// Bitwise so no assignment is short-circuited away.
let applied = assign(&mut clip.media_id, media_id.clone())
- | source_start.is_some_and(|start| assign(&mut clip.source_start, start.max(0.0)));
+ | source_start.is_some_and(|start| assign(&mut clip.source_start, start.max(0.0)))
+ | assign(&mut clip.enhanced, link);
if !applied {
return Ok(Outcome::default());
}
@@ -408,6 +426,28 @@ pub(super) fn apply(
})
}
+ Command::SetClipEnhanced { clip_id, on } => {
+ let timeline = project.active_mut();
+ let Some(index) = timeline.clips.iter().position(|clip| clip.id == clip_id) else {
+ return Ok(Outcome::default());
+ };
+ let Some(link) = timeline.clips[index].enhanced.clone() else {
+ return Ok(Outcome::default());
+ };
+ let clip = timeline.clip_at_mut(index);
+ let media = if on {
+ link.copy.clone()
+ } else {
+ link.original.clone()
+ };
+ let applied = assign(&mut clip.media_id, media)
+ | assign(&mut clip.enhanced, Some(Enhanced { on, ..link }));
+ Ok(Outcome {
+ created_id: None,
+ applied,
+ })
+ }
+
Command::FreezeFrame {
clip_id,
time,
diff --git a/src/crates/concat-project/src/commands/mod.rs b/src/crates/concat-project/src/commands/mod.rs
index 6dfcbc30..ea91e32d 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, ShapeStyle,
- SpeedPoint, Stroke, TextStyle, Timeline, Track, Transition, VideoSettings,
+ CutoutMode, Enhanced, KeyEase, KeyProperty, MediaItem, MediaKind, MediaOrigin, Project,
+ ShapeStyle, SpeedPoint, Stroke, TextStyle, Timeline, Track, Transition, VideoSettings,
};
mod audio;
@@ -518,6 +518,20 @@ pub enum Command {
/// keeps the clip's.
#[serde(default)]
source_start: Option<f64>,
+ /// The copy is the clip's Enhance: the clip keeps the media it
+ /// showed before as the original, so Enhance can be switched off
+ /// (see [`Command::SetClipEnhanced`]). Any other copy - a reversed
+ /// one - ends the clip's Enhance, which was of the media now gone.
+ #[serde(default, skip_serializing_if = "std::ops::Not::not")]
+ enhanced: bool,
+ },
+ /// Shows a clip's enhanced copy, or its original again. A no-op for a
+ /// clip Enhance has not made a copy for.
+ SetClipEnhanced {
+ /// The clip.
+ clip_id: String,
+ /// The copy when true, the original when false.
+ on: bool,
},
/// A freeze frame at `time`: splits `clip_id`, inserts a still of
/// `duration` on the same track, and ripples later clips on that track
@@ -1064,6 +1078,7 @@ pub fn apply(
| Command::SplitClips { .. }
| Command::FreezeFrame { .. }
| Command::ReplaceClipMedia { .. }
+ | Command::SetClipEnhanced { .. }
| Command::MergeClips { .. }
| Command::RemoveClips { .. }) => clips::apply(project, mint, command),
command @ (Command::UpdateClip { .. }
diff --git a/src/crates/concat-project/src/lib.rs b/src/crates/concat-project/src/lib.rs
index 64ad8bfe..4295268b 100644
--- a/src/crates/concat-project/src/lib.rs
+++ b/src/crates/concat-project/src/lib.rs
@@ -752,6 +752,7 @@ mod tests {
clip_id: clip_id.clone(),
item: copy,
source_start: Some(0.0),
+ enhanced: false,
})
.expect("replaces");
assert!(outcome.applied);
@@ -784,6 +785,7 @@ mod tests {
clip_id: clip_id.clone(),
item: copy.clone(),
source_start: None,
+ enhanced: false,
})
.expect("replaces");
assert!(outcome.applied);
@@ -808,6 +810,7 @@ mod tests {
clip_id: clip_id.clone(),
item: copy.clone(),
source_start: None,
+ enhanced: false,
})
.expect("no-op");
assert!(!again.applied);
@@ -822,6 +825,7 @@ mod tests {
..copy
},
source_start: None,
+ enhanced: false,
})
.expect("no-op");
assert!(!nobody.applied);
@@ -854,6 +858,7 @@ mod tests {
clip_id: clip_id.clone(),
item: bad,
source_start: None,
+ enhanced: false,
})
.is_err()
);
@@ -3924,4 +3929,105 @@ mod tests {
r#"{"op":"addTrack"}"#
);
}
+
+ /// Enhance's copy keeps the clip's original beside it: switching it
+ /// off shows the original, on shows the copy, each one undo step, and
+ /// any other replacement - a reversed copy - ends the link.
+ #[test]
+ fn an_enhanced_clip_switches_between_copy_and_original() {
+ use crate::commands::NewMedia;
+ use crate::model::MediaKind;
+ let item = |path: &str| NewMedia {
+ path: path.into(),
+ name: path.into(),
+ duration: Some(10.0),
+ kind: MediaKind::Video,
+ width: Some(64),
+ height: Some(64),
+ frame_rate: Some(30.0),
+ frame_rate_fraction: Some("30/1".into()),
+ video_codec: None,
+ audio_codec: None,
+ has_audio: false,
+ audio_tracks: Vec::new(),
+ origin: None,
+ color_space: Default::default(),
+ };
+ let mut editor = Editor::new();
+ editor
+ .apply(Command::AddMedia {
+ item: item("/a.mp4"),
+ })
+ .expect("imports");
+ let original = editor.project().media[0].id.clone();
+ let track = editor.project().active().tracks[0].id.clone();
+ let clip = editor
+ .apply(Command::AddClip {
+ media_id: original.clone(),
+ track_id: track,
+ start: 0.0,
+ ripple: false,
+ })
+ .expect("places")
+ .created_id
+ .expect("a clip");
+ let copy = editor
+ .apply(Command::ReplaceClipMedia {
+ clip_id: clip.clone(),
+ item: item("/a-enhanced.mp4"),
+ source_start: None,
+ enhanced: true,
+ })
+ .expect("replaces")
+ .created_id
+ .expect("the copy");
+ let shown = |editor: &Editor| {
+ editor
+ .project()
+ .active()
+ .clip(&clip)
+ .cloned()
+ .expect("there")
+ };
+ let link = shown(&editor).enhanced.expect("linked");
+ assert_eq!(
+ (link.original.as_str(), link.copy.as_str(), link.on),
+ (original.as_str(), copy.as_str(), true)
+ );
+
+ editor
+ .apply(Command::SetClipEnhanced {
+ clip_id: clip.clone(),
+ on: false,
+ })
+ .expect("off");
+ assert_eq!(shown(&editor).media_id, original);
+ assert!(!shown(&editor).enhanced.expect("kept").on);
+ editor
+ .apply(Command::SetClipEnhanced {
+ clip_id: clip.clone(),
+ on: true,
+ })
+ .expect("on");
+ assert_eq!(shown(&editor).media_id, copy);
+ editor.undo();
+ assert_eq!(shown(&editor).media_id, original, "one undo step");
+
+ editor
+ .apply(Command::ReplaceClipMedia {
+ clip_id: clip.clone(),
+ item: item("/a-reversed.mp4"),
+ source_start: None,
+ enhanced: false,
+ })
+ .expect("replaces");
+ assert_eq!(shown(&editor).enhanced, None);
+ let off = editor
+ .apply(Command::SetClipEnhanced {
+ clip_id: clip.clone(),
+ on: false,
+ })
+ .expect("no-op");
+ assert!(!off.applied);
+ }
}
diff --git a/src/crates/concat-project/src/model.rs b/src/crates/concat-project/src/model.rs
index 5112006b..8351ba92 100644
--- a/src/crates/concat-project/src/model.rs
+++ b/src/crates/concat-project/src/model.rs
@@ -813,6 +813,18 @@ pub struct SpeedPoint {
pub speed: f64,
}
+/// A clip's Enhance, once it has a copy: see [`Clip::enhanced`].
+#[derive(Clone, PartialEq, Debug, Serialize, Deserialize)]
+#[serde(rename_all = "camelCase")]
+pub struct Enhanced {
+ /// The bin item the clip was cut from.
+ pub original: String,
+ /// The bin item holding the enhanced copy.
+ pub copy: String,
+ /// Whether the clip shows the copy.
+ pub on: bool,
+}
+
/// A transition on the cut into a clip.
#[derive(Clone, PartialEq, Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
@@ -1333,6 +1345,13 @@ pub struct Clip {
#[serde(default, skip_serializing_if = "Option::is_none")]
#[serde(deserialize_with = "wire::maybe")]
pub transition_in: Option<Transition>,
+ /// The clip's Enhance: the media it was cut from and the enhanced copy
+ /// of it, and which of the two it shows. Absent until Enhance has made
+ /// a copy; switching it off shows the original again without running
+ /// the model a second time.
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ #[serde(deserialize_with = "wire::maybe")]
+ pub enhanced: Option<Enhanced>,
/// The overlay, when this is a text clip.
#[serde(default, skip_serializing_if = "Option::is_none")]
#[serde(deserialize_with = "wire::maybe")]
@@ -1434,6 +1453,7 @@ impl Clip {
muted: None,
detached_from: None,
transition_in: None,
+ enhanced: None,
text: None,
shape: None,
extra: Map::new(),
diff --git a/src/crates/concat/locales/de.json b/src/crates/concat/locales/de.json
index 76bc902f..d811aa27 100644
--- a/src/crates/concat/locales/de.json
+++ b/src/crates/concat/locales/de.json
@@ -35,6 +35,9 @@
"clipInspector.darken": "Abdunkeln",
"clipInspector.effectLibrary": "Effektbibliothek",
"clipInspector.enable": "{0} aktivieren",
+ "clipInspector.enhanceExplain": "Stellt das Bild mit dem Verbesserungsmodell wieder her und vergrößert es, als Kopie, die der Clip dann zeigt. Zum Starten anhaken; es läuft im Hintergrund.",
+ "clipInspector.enhanceShowingCopy": "Zeigt die verbesserte Kopie. Haken entfernen, um wieder das Original zu zeigen.",
+ "clipInspector.enhanceShowingOriginal": "Zeigt das Original. Anhaken, um wieder die verbesserte Kopie zu zeigen.",
"clipInspector.enhanceVoice": "Stimme verbessern",
"clipInspector.enhancing": "Wird verbessert… {0}%",
"clipInspector.eraser": "Radierer",
diff --git a/src/crates/concat/locales/en.json b/src/crates/concat/locales/en.json
index 4f7ac647..fcb73748 100644
--- a/src/crates/concat/locales/en.json
+++ b/src/crates/concat/locales/en.json
@@ -35,6 +35,9 @@
"clipInspector.darken": "Darken",
"clipInspector.effectLibrary": "Effect library",
"clipInspector.enable": "Enable {0}",
+ "clipInspector.enhanceExplain": "Restores and enlarges the picture with the enhance model, into a copy the clip then shows. Tick to start; it runs in the background.",
+ "clipInspector.enhanceShowingCopy": "Showing the enhanced copy. Untick to show the original again.",
+ "clipInspector.enhanceShowingOriginal": "Showing the original. Tick to show the enhanced copy again.",
"clipInspector.enhanceVoice": "Enhance voice",
"clipInspector.enhancing": "Enhancing… {0}%",
"clipInspector.eraser": "Eraser",
diff --git a/src/crates/concat/locales/es.json b/src/crates/concat/locales/es.json
index fc8b0d20..a220fa9b 100644
--- a/src/crates/concat/locales/es.json
+++ b/src/crates/concat/locales/es.json
@@ -35,6 +35,9 @@
"clipInspector.darken": "Oscurecer",
"clipInspector.effectLibrary": "Biblioteca de efectos",
"clipInspector.enable": "Activar {0}",
+ "clipInspector.enhanceExplain": "Restaura y amplía la imagen con el modelo de mejora, en una copia que el clip muestra después. Márcalo para empezar; se ejecuta en segundo plano.",
+ "clipInspector.enhanceShowingCopy": "Mostrando la copia mejorada. Desmárcalo para volver a mostrar el original.",
+ "clipInspector.enhanceShowingOriginal": "Mostrando el original. Márcalo para volver a mostrar la copia mejorada.",
"clipInspector.enhanceVoice": "Mejorar voz",
"clipInspector.enhancing": "Mejorando… {0}%",
"clipInspector.eraser": "Borrador",
diff --git a/src/crates/concat/locales/fa.json b/src/crates/concat/locales/fa.json
index 63db4266..b0fe4210 100644
--- a/src/crates/concat/locales/fa.json
+++ b/src/crates/concat/locales/fa.json
@@ -35,6 +35,9 @@
"clipInspector.darken": "تیره‌تر",
"clipInspector.effectLibrary": "افکت کتابخانه",
"clipInspector.enable": "فعال‌کردن {0}",
+ "clipInspector.enhanceExplain": "تصویر را با مدل بهبود بازسازی و بزرگ می‌کند و کلیپ سپس آن نسخه را نشان می‌دهد. برای شروع تیک بزنید؛ در پس‌زمینه اجرا می‌شود.",
+ "clipInspector.enhanceShowingCopy": "نسخهٔ بهبودیافته نمایش داده می‌شود. برای نمایش دوبارهٔ اصل، تیک را بردارید.",
+ "clipInspector.enhanceShowingOriginal": "اصل نمایش داده می‌شود. برای نمایش دوبارهٔ نسخهٔ بهبودیافته تیک بزنید.",
"clipInspector.enhanceVoice": "بهبود صدا",
"clipInspector.enhancing": "در حال بهبود کیفیت… {0}%",
"clipInspector.eraser": "پاک‌کن",
diff --git a/src/crates/concat/locales/fr.json b/src/crates/concat/locales/fr.json
index 554f971c..bb45730e 100644
--- a/src/crates/concat/locales/fr.json
+++ b/src/crates/concat/locales/fr.json
@@ -35,6 +35,9 @@
"clipInspector.darken": "Obscurcir",
"clipInspector.effectLibrary": "Bibliothèque d'effets",
"clipInspector.enable": "Activer {0}",
+ "clipInspector.enhanceExplain": "Restaure et agrandit l'image avec le modèle d'amélioration, dans une copie que le clip affiche ensuite. Cochez pour lancer ; cela tourne en arrière-plan.",
+ "clipInspector.enhanceShowingCopy": "La copie améliorée est affichée. Décochez pour revenir à l'original.",
+ "clipInspector.enhanceShowingOriginal": "L'original est affiché. Cochez pour revenir à la copie améliorée.",
"clipInspector.enhanceVoice": "Améliorer la voix",
"clipInspector.enhancing": "Amélioration… {0} %",
"clipInspector.eraser": "Gomme",
diff --git a/src/crates/concat/locales/hr.json b/src/crates/concat/locales/hr.json
index 94235224..f86600bc 100644
--- a/src/crates/concat/locales/hr.json
+++ b/src/crates/concat/locales/hr.json
@@ -35,6 +35,9 @@
"clipInspector.darken": "Zatamni",
"clipInspector.effectLibrary": "Biblioteka efekata",
"clipInspector.enable": "Uključi {0}",
+ "clipInspector.enhanceExplain": "Obnavlja i povećava sliku modelom za poboljšanje, u kopiju koju isječak zatim prikazuje. Označi za početak; radi u pozadini.",
+ "clipInspector.enhanceShowingCopy": "Prikazuje se poboljšana kopija. Odznači da ponovno prikažeš izvornik.",
+ "clipInspector.enhanceShowingOriginal": "Prikazuje se izvornik. Označi da ponovno prikažeš poboljšanu kopiju.",
"clipInspector.enhanceVoice": "Istakni glas",
"clipInspector.enhancing": "Poboljšavanje… {0} %",
"clipInspector.eraser": "Gumica",
diff --git a/src/crates/concat/locales/it.json b/src/crates/concat/locales/it.json
index fbf82847..e8792bfe 100644
--- a/src/crates/concat/locales/it.json
+++ b/src/crates/concat/locales/it.json
@@ -35,6 +35,9 @@
"clipInspector.darken": "Scurisci",
"clipInspector.effectLibrary": "Libreria effetti",
"clipInspector.enable": "Attiva {0}",
+ "clipInspector.enhanceExplain": "Ripristina e ingrandisce l'immagine con il modello di miglioramento, in una copia che la clip poi mostra. Spunta per avviare; lavora in background.",
+ "clipInspector.enhanceShowingCopy": "Mostra la copia migliorata. Togli la spunta per mostrare di nuovo l'originale.",
+ "clipInspector.enhanceShowingOriginal": "Mostra l'originale. Spunta per mostrare di nuovo la copia migliorata.",
"clipInspector.enhanceVoice": "Migliora voce",
"clipInspector.enhancing": "Miglioramento… {0}%",
"clipInspector.eraser": "Gomma",
diff --git a/src/crates/concat/locales/ja.json b/src/crates/concat/locales/ja.json
index b66e2dfa..4714bb0b 100644
--- a/src/crates/concat/locales/ja.json
+++ b/src/crates/concat/locales/ja.json
@@ -35,6 +35,9 @@
"clipInspector.darken": "比較(暗)",
"clipInspector.effectLibrary": "エフェクトライブラリ",
"clipInspector.enable": "{0} を有効にする",
+ "clipInspector.enhanceExplain": "補正モデルで映像を修復・拡大し、そのコピーをクリップに表示します。チェックすると開始し、バックグラウンドで処理します。",
+ "clipInspector.enhanceShowingCopy": "補正済みのコピーを表示しています。チェックを外すと元の映像に戻ります。",
+ "clipInspector.enhanceShowingOriginal": "元の映像を表示しています。チェックすると補正済みのコピーに戻ります。",
"clipInspector.enhanceVoice": "声を強調",
"clipInspector.enhancing": "高画質化中… {0}%",
"clipInspector.eraser": "消しゴム",
diff --git a/src/crates/concat/locales/ko.json b/src/crates/concat/locales/ko.json
index ba255d95..f8e6ea15 100644
--- a/src/crates/concat/locales/ko.json
+++ b/src/crates/concat/locales/ko.json
@@ -35,6 +35,9 @@
"clipInspector.darken": "어둡게",
"clipInspector.effectLibrary": "효과 라이브러리",
"clipInspector.enable": "{0} 사용",
+ "clipInspector.enhanceExplain": "향상 모델로 화면을 복원하고 확대해, 클립이 보여 줄 사본을 만듭니다. 체크하면 시작되며 백그라운드에서 실행됩니다.",
+ "clipInspector.enhanceShowingCopy": "향상된 사본을 보여 주는 중입니다. 체크를 해제하면 원본을 다시 보여 줍니다.",
+ "clipInspector.enhanceShowingOriginal": "원본을 보여 주는 중입니다. 체크하면 향상된 사본을 다시 보여 줍니다.",
"clipInspector.enhanceVoice": "음성 향상",
"clipInspector.enhancing": "향상 중… {0}%",
"clipInspector.eraser": "지우개",
diff --git a/src/crates/concat/locales/pt-BR.json b/src/crates/concat/locales/pt-BR.json
index 8a5ddca2..02aff3cf 100644
--- a/src/crates/concat/locales/pt-BR.json
+++ b/src/crates/concat/locales/pt-BR.json
@@ -35,6 +35,9 @@
"clipInspector.darken": "Escurecer",
"clipInspector.effectLibrary": "Biblioteca de efeitos",
"clipInspector.enable": "Ativar {0}",
+ "clipInspector.enhanceExplain": "Restaura e amplia a imagem com o modelo de aprimoramento, numa cópia que o clipe passa a mostrar. Marque para começar; roda em segundo plano.",
+ "clipInspector.enhanceShowingCopy": "Mostrando a cópia aprimorada. Desmarque para mostrar o original de novo.",
+ "clipInspector.enhanceShowingOriginal": "Mostrando o original. Marque para mostrar a cópia aprimorada de novo.",
"clipInspector.enhanceVoice": "Realçar voz",
"clipInspector.enhancing": "Melhorando… {0}%",
"clipInspector.eraser": "Borracha",
diff --git a/src/crates/concat/locales/ru.json b/src/crates/concat/locales/ru.json
index f25189d7..cec2ec06 100644
--- a/src/crates/concat/locales/ru.json
+++ b/src/crates/concat/locales/ru.json
@@ -35,6 +35,9 @@
"clipInspector.darken": "Затемнение",
"clipInspector.effectLibrary": "Библиотека эффектов",
"clipInspector.enable": "Включить {0}",
+ "clipInspector.enhanceExplain": "Восстанавливает и увеличивает изображение моделью улучшения в копию, которую затем показывает клип. Отметьте, чтобы начать; работа идёт в фоне.",
+ "clipInspector.enhanceShowingCopy": "Показана улучшенная копия. Снимите отметку, чтобы снова показать оригинал.",
+ "clipInspector.enhanceShowingOriginal": "Показан оригинал. Отметьте, чтобы снова показать улучшенную копию.",
"clipInspector.enhanceVoice": "Улучшить голос",
"clipInspector.enhancing": "Улучшение… {0}%",
"clipInspector.eraser": "Ластик",
diff --git a/src/crates/concat/locales/tr.json b/src/crates/concat/locales/tr.json
index 3b61f17e..93379129 100644
--- a/src/crates/concat/locales/tr.json
+++ b/src/crates/concat/locales/tr.json
@@ -35,6 +35,9 @@
"clipInspector.darken": "Koyulaştır",
"clipInspector.effectLibrary": "Efekt kitaplığı",
"clipInspector.enable": "{0} etkinleştir",
+ "clipInspector.enhanceExplain": "Görüntüyü iyileştirme modeliyle onarıp büyütür; klip ardından bu kopyayı gösterir. Başlatmak için işaretleyin; arka planda çalışır.",
+ "clipInspector.enhanceShowingCopy": "İyileştirilmiş kopya gösteriliyor. Orijinali yeniden göstermek için işareti kaldırın.",
+ "clipInspector.enhanceShowingOriginal": "Orijinal gösteriliyor. İyileştirilmiş kopyayı yeniden göstermek için işaretleyin.",
"clipInspector.enhanceVoice": "Sesi iyileştir",
"clipInspector.enhancing": "İyileştiriliyor… %{0}",
"clipInspector.eraser": "Silgi",
diff --git a/src/crates/concat/locales/zh-Hans.json b/src/crates/concat/locales/zh-Hans.json
index 6072eb4c..4b637c47 100644
--- a/src/crates/concat/locales/zh-Hans.json
+++ b/src/crates/concat/locales/zh-Hans.json
@@ -35,6 +35,9 @@
"clipInspector.darken": "变暗",
"clipInspector.effectLibrary": "效果库",
"clipInspector.enable": "启用{0}",
+ "clipInspector.enhanceExplain": "使用增强模型修复并放大画面,生成一份副本供片段显示。勾选即开始,在后台运行。",
+ "clipInspector.enhanceShowingCopy": "正在显示增强后的副本。取消勾选即可重新显示原片。",
+ "clipInspector.enhanceShowingOriginal": "正在显示原片。勾选即可重新显示增强后的副本。",
"clipInspector.enhanceVoice": "增强人声",
"clipInspector.enhancing": "正在增强… {0}%",
"clipInspector.eraser": "橡皮擦",
diff --git a/src/crates/concat/locales/zh-TW.json b/src/crates/concat/locales/zh-TW.json
index 55f8d36d..cee03da1 100644
--- a/src/crates/concat/locales/zh-TW.json
+++ b/src/crates/concat/locales/zh-TW.json
@@ -35,6 +35,9 @@
"clipInspector.darken": "變暗",
"clipInspector.effectLibrary": "效果庫",
"clipInspector.enable": "啟用{0}",
+ "clipInspector.enhanceExplain": "使用增強模型修復並放大畫面,產生一份副本供片段顯示。勾選即開始,在背景執行。",
+ "clipInspector.enhanceShowingCopy": "正在顯示增強後的副本。取消勾選即可重新顯示原片。",
+ "clipInspector.enhanceShowingOriginal": "正在顯示原片。勾選即可重新顯示增強後的副本。",
"clipInspector.enhanceVoice": "增強人聲",
"clipInspector.enhancing": "正在增強… {0}%",
"clipInspector.eraser": "橡皮擦",
diff --git a/src/crates/concat/src/lib.rs b/src/crates/concat/src/lib.rs
index 94b6b044..6c147046 100644
--- a/src/crates/concat/src/lib.rs
+++ b/src/crates/concat/src/lib.rs
@@ -1162,6 +1162,9 @@ pub fn run() -> Result<(), slint::PlatformError> {
editor.on_cutout_clear(on_window!(|state| {
state.cutout_clear();
}));
+ editor.on_clip_enhance_set(on_window!(|state, on: bool| {
+ state.clip_enhance_set(on);
+ }));
editor.on_transition_remove(on_window!(|state| {
state.remove_transition();
}));
diff --git a/src/crates/concat/src/studio.rs b/src/crates/concat/src/studio.rs
index e9680030..a7acd874 100644
--- a/src/crates/concat/src/studio.rs
+++ b/src/crates/concat/src/studio.rs
@@ -5761,6 +5761,29 @@ impl Studio {
);
}
+ /// The Enhance switch in the inspector, for the one selected clip. A
+ /// clip with a copy shows it or its original; one without starts
+ /// Enhance on the switch going on, and stops a run on it going off.
+ pub fn clip_enhance_set(&mut self, on: bool) {
+ let Some(id) = self.sole_selection() else {
+ return;
+ };
+ let Some(clip) = self.clip(&id) else {
+ return;
+ };
+ if self.locked(&clip.track_id) {
+ return;
+ }
+ if clip.enhanced.is_some() {
+ self.apply(Command::SetClipEnhanced { clip_id: id, on });
+ self.request_preview();
+ } else if on {
+ self.enhance_clip(&id);
+ } else if self.enhance_jobs.contains_key(&id) {
+ self.host.enhancers.cancel();
+ }
+ }
+
pub fn enhance_clip(&mut self, id: &str) {
if !self.enhance_jobs.is_empty() || self.host.enhancers.is_busy() {
self.notify(&t("studio.enhanceAlreadyWorkOne"), true);
@@ -5958,6 +5981,7 @@ impl Studio {
clip_id: id.to_owned(),
item,
source_start: Some(0.0),
+ enhanced: false,
});
self.request_preview();
self.notify(&t("studio.reversedClipNowShows"), false);
@@ -5986,6 +6010,7 @@ impl Studio {
clip_id: id.to_owned(),
item,
source_start: None,
+ enhanced: true,
});
self.request_preview();
self.notify(&t("studio.enhancedClipNowShows"), false);
@@ -8711,6 +8736,9 @@ impl Studio {
.get(&clip.id)
.is_some_and(|(fetching, _)| *fetching),
reverse_progress: self.reverse_jobs.get(&clip.id).copied().unwrap_or(-1.0),
+ enhance_linked: clip.enhanced.is_some(),
+ enhance_on: clip.enhanced.as_ref().is_some_and(|link| link.on)
+ || self.enhance_jobs.contains_key(&clip.id),
}
}
@@ -9210,17 +9238,15 @@ impl Studio {
&& !locked
&& (clip.kind == model::ClipKind::Video || clip.kind == model::ClipKind::Image),
),
- // The picture restored and enlarged by the model, as a copy
- // the clip then shows. Greyed while one is being written,
- // since the job runs one at a time.
+ // The picture restored and enlarged by the model: the row opens
+ // the clip's Enhance in the inspector, whose switch runs it.
action(
"enhance",
t("common.enhance"),
Glyph::Sparkle,
"",
!locked
- && (clip.kind == model::ClipKind::Video || clip.kind == model::ClipKind::Image)
- && self.enhance_jobs.is_empty(),
+ && (clip.kind == model::ClipKind::Video || clip.kind == model::ClipKind::Image),
),
rule(),
];
@@ -9885,7 +9911,14 @@ impl Studio {
self.split_at(at, true);
}
"freeze" => self.freeze_at_playhead(),
- "enhance" => self.enhance_clip(id),
+ // The menu opens the clip's Enhance in the inspector, where its
+ // switch starts it and later turns it off and on again.
+ "enhance" => {
+ self.flush_commit();
+ self.selection = vec![id.to_owned()];
+ self.transition_selected = None;
+ self.inspector_jump = (self.inspector_jump.0 + 1, "Video", "Enhance");
+ }
"export-audio" => self.export_clip_audio(id),
"detach" => {
self.apply(Command::DetachAudio {
diff --git a/src/crates/concat/ui/editor.slint b/src/crates/concat/ui/editor.slint
index 027482ea..388c728d 100644
--- a/src/crates/concat/ui/editor.slint
+++ b/src/crates/concat/ui/editor.slint
@@ -272,6 +272,7 @@ export global Editor {
callback cutout-painting(on: bool);
callback cutout-subject(index: int);
callback cutout-clear();
+ callback clip-enhance-set(on: bool);
/// The transition riding into the selected clip; see VideoPanel.
callback transition-remove();
callback transition-duration-set(seconds: float);
diff --git a/src/crates/concat/ui/inspector/clip-inspector.slint b/src/crates/concat/ui/inspector/clip-inspector.slint
index c63bd262..e67a6668 100644
--- a/src/crates/concat/ui/inspector/clip-inspector.slint
+++ b/src/crates/concat/ui/inspector/clip-inspector.slint
@@ -1193,6 +1193,13 @@ export component VideoPanel inherits VerticalLayout {
cutout := SectionHeader {
title: I18n.t("clipInspector.removeBackground");
collapsible: true;
+ // On is whichever removal is set; going on picks the custom one
+ // when strokes are waiting for it, the automatic one otherwise.
+ switchable: true;
+ on: root.removal != 0;
+ switched(on) => {
+ root.remove-by(!on ? 0 : root.selected.cutout-strokes > 0 ? 2 : 1);
+ }
summary: root.removal == 0 ? I18n.t("common.off")
: root.removal == 1 ? I18n.t("clipInspector.autoRemoval")
: root.removal == 2 ? I18n.t("clipInspector.customRemoval") : I18n.t("clipInspector.chromaKey");
@@ -1458,6 +1465,40 @@ export component VideoPanel inherits VerticalLayout {
}
}
+/// Enhance: the picture restored and enlarged by the model, into a copy the
+/// clip then shows. The header's tick starts it the first time; once there
+/// is a copy, it switches between the copy and the original without running
+/// the model again.
+export component EnhancePanel inherits VerticalLayout {
+ in property <SelectedClipData> selected;
+
+ callback enhance-set(on: bool);
+
+ Section {
+ first: true;
+ SectionHeader {
+ title: I18n.t("common.enhance");
+ switchable: true;
+ on: root.selected.enhance-on;
+ switched(on) => { root.enhance-set(on); }
+ }
+
+ SectionBody {
+ if root.selected.enhance-progress >= 0: EnhanceRow {
+ progress: root.selected.enhance-progress;
+ fetching: root.selected.enhance-fetching;
+ }
+ if root.selected.enhance-progress < 0: Note {
+ text: root.selected.enhance-linked
+ ? (root.selected.enhance-on
+ ? I18n.t("clipInspector.enhanceShowingCopy")
+ : I18n.t("clipInspector.enhanceShowingOriginal"))
+ : I18n.t("clipInspector.enhanceExplain");
+ }
+ }
+ }
+}
+
/// A transition picked on its own on the lanes: what it is, the clip it
/// rides into, its length, and the way to take it off. Its own panel and
/// not a section of the clip's, since it belongs to the cut between two
@@ -1582,10 +1623,6 @@ export component AudioPanel inherits VerticalLayout {
? root.audio-tracks[root.selected.audio-track] : "";
}
if source.open: SectionBody {
- if root.selected.enhance-progress >= 0: EnhanceRow {
- progress: root.selected.enhance-progress;
- fetching: root.selected.enhance-fetching;
- }
if root.audio-tracks.length > 1: Row {
label: I18n.t("clipInspector.audioTrack");
Select {
diff --git a/src/crates/concat/ui/primitives/panel.slint b/src/crates/concat/ui/primitives/panel.slint
index d26bba5a..f538ce37 100644
--- a/src/crates/concat/ui/primitives/panel.slint
+++ b/src/crates/concat/ui/primitives/panel.slint
@@ -84,6 +84,14 @@ export component SectionHeader inherits Rectangle {
/// of the way should not also hide what it was set to.
in property <string> summary;
in-out property <bool> open: true;
+ /// A tick before the title that turns what the section holds on and
+ /// off - Enhance, a background removal - so the switch is where the
+ /// section's name is, open or folded.
+ in property <bool> switchable;
+ in property <bool> on;
+ in property <bool> switch-enabled: true;
+
+ callback switched(on: bool);
height: 36px;
// A step up from the panel, so a column of sections reads as a stack of
@@ -109,6 +117,33 @@ export component SectionHeader inherits Rectangle {
padding-right: Theme.pad;
spacing: 8px;
+ if root.switchable: VerticalLayout {
+ alignment: center;
+ Rectangle {
+ width: 16px;
+ height: 16px;
+ border-radius: 4px;
+ background: root.on ? Theme.accent : Theme.field-active;
+ opacity: root.switch-enabled ? 1.0 : 0.45;
+
+ animate background { duration: 120ms; easing: cubic-bezier(0.4, 0, 0.2, 1); }
+
+ if root.on: Icon {
+ x: (parent.width - self.width) / 2;
+ y: (parent.height - self.height) / 2;
+ glyph: Glyph.check;
+ size: 11px;
+ tint: Theme.on-accent;
+ }
+
+ TouchArea {
+ enabled: root.switch-enabled;
+ mouse-cursor: pointer;
+ clicked => { root.switched(!root.on); }
+ }
+ }
+ }
+
Text {
text: root.title;
color: Theme.fg;
diff --git a/src/crates/concat/ui/timeline/model.slint b/src/crates/concat/ui/timeline/model.slint
index a673a203..f030e733 100644
--- a/src/crates/concat/ui/timeline/model.slint
+++ b/src/crates/concat/ui/timeline/model.slint
@@ -341,6 +341,11 @@ export struct SelectedClipData {
// than frames being restored
enhance-progress: float,
enhance-fetching: bool,
+ /// Enhance has made a copy for this clip, which it shows when
+ /// `enhance-on`; the switch flips between it and the original
+ enhance-linked: bool,
+ /// The Enhance switch: the copy shown, or a run under way
+ enhance-on: bool,
/// Reverse writing this clip's backwards copy: -1 when it is not,
/// else how far along
reverse-progress: float,
diff --git a/src/crates/concat/ui/workspace/config-pane.slint b/src/crates/concat/ui/workspace/config-pane.slint
index 1b2e0826..31bd0949 100644
--- a/src/crates/concat/ui/workspace/config-pane.slint
+++ b/src/crates/concat/ui/workspace/config-pane.slint
@@ -9,7 +9,7 @@ import { PaneKind, PaneSwitcher } from "pane-switcher.slint";
import { EffectData } from "../demo/effects-panel.slint";
import {
AdjustPanel, AppliedEntryData, AppliedParamData, AudioPanel, ProcessorRows,
- CatalogueEntryData, ColourKnobData, FilterPanel, PresetStack, SpeedPanel,
+ CatalogueEntryData, ColourKnobData, EnhancePanel, FilterPanel, PresetStack, SpeedPanel,
TransitionPanel, VideoPanel,
} from "../inspector/clip-inspector.slint";
import {
@@ -203,6 +203,8 @@ export component ConfigPane inherits Rectangle {
callback cutout-painting(on: bool);
callback cutout-subject(index: int);
callback cutout-clear();
+ /// The Enhance switch: start it, or show the copy or the original.
+ callback clip-enhance-set(on: bool);
callback transition-remove();
callback transition-duration-set(seconds: float);
@@ -269,8 +271,8 @@ export component ConfigPane inherits Rectangle {
/// The sections of the current tab, as the dropdown lists them.
property <[string]> sections: root.heading == "Video"
? (root.is-shape ? ["Basic"]
- : root.is-image ? ["Basic", "Adjust"]
- : ["Basic", "Speed", "Adjust"])
+ : root.is-image ? ["Basic", "Enhance", "Adjust"]
+ : ["Basic", "Enhance", "Speed", "Adjust"])
: root.heading == "Audio"
? (root.is-audio ? ["Sound", "Speed"] : ["Sound"])
: root.heading == "Effects" ? ["Effects"]
@@ -279,8 +281,8 @@ export component ConfigPane inherits Rectangle {
/// The sections as the dropdown shows them; see `tabs-shown`.
property <[string]> sections-shown: root.heading == "Video"
? (root.is-shape ? [I18n.t("configPane.basic")]
- : root.is-image ? [I18n.t("configPane.basic"), I18n.t("common.adjust")]
- : [I18n.t("configPane.basic"), I18n.t("common.speed"), I18n.t("common.adjust")])
+ : root.is-image ? [I18n.t("configPane.basic"), I18n.t("common.enhance"), I18n.t("common.adjust")]
+ : [I18n.t("configPane.basic"), I18n.t("common.enhance"), I18n.t("common.speed"), I18n.t("common.adjust")])
: root.heading == "Audio"
? (root.is-audio ? [I18n.t("configPane.sound"), I18n.t("common.speed")] : [I18n.t("configPane.sound")])
: root.heading == "Effects" ? [I18n.t("common.effects")]
@@ -319,7 +321,8 @@ export component ConfigPane inherits Rectangle {
if (root.jump-tab == "Video") { root.tab = 0; }
else if (root.jump-tab == "Audio") { root.tab = root.is-audio ? 0 : 1; }
else if (root.jump-tab == "Effects") { root.tab = root.tabs.length - 1; }
- root.pick-section(0);
+ // Enhance sits second in the Video tab for a video and a still alike.
+ root.pick-section(root.jump-section == "Enhance" ? 1 : 0);
}
changed jump-token => { root.jump(); }
init => { root.jump(); }
@@ -625,6 +628,11 @@ export component ConfigPane inherits Rectangle {
cutout-clear => { root.cutout-clear(); }
}
+ if root.showing == "Enhance": EnhancePanel {
+ selected: root.selected;
+ enhance-set(on) => { root.clip-enhance-set(on); }
+ }
+
if root.showing == "Speed": SpeedPanel {
selected: root.selected;
set(field, value) => { root.clip-set(field, value); }
diff --git a/src/crates/concat/ui/workspace/seat.slint b/src/crates/concat/ui/workspace/seat.slint
index 81a5157c..d672d2d6 100644
--- a/src/crates/concat/ui/workspace/seat.slint
+++ b/src/crates/concat/ui/workspace/seat.slint
@@ -253,6 +253,7 @@ export component Seat inherits Rectangle {
cutout-painting(on) => { Editor.cutout-painting(on); }
cutout-subject(index) => { Editor.cutout-subject(index); }
cutout-clear => { Editor.cutout-clear(); }
+ clip-enhance-set(on) => { Editor.clip-enhance-set(on); }
transition-remove => { Editor.transition-remove(); }
transition-duration-set(seconds) => { Editor.transition-duration-set(seconds); }