Skip to content

FilmCraft: An open-source, nonlinear video editor written by scratch in pure Rust

M10.4: caption UI — caption track rows above the video tracks (select, drag to move/trim, eye/lock headers), Text panel Captions tab (segment list with editable in/out/text, add/split/merge/delete/export, track picker, style strip), Burn Captions Into Video in Export mode, caption file dialogs; docs/captions.md

Brandon Thomas098dcc8a6157
diff --git a/ROADMAP.md b/ROADMAP.md
index 245a1e2d3..fa755f07c 100644
--- a/ROADMAP.md
+++ b/ROADMAP.md
@@ -38,7 +38,7 @@ Status: ✅ done · 🟡 in progress · ⬜ not started. Estimates are remaining
| M7 | Audio | 🟡 | Mixer basics, peak meters, BS.1770 loudness meters (M/S/I LUFS, true peak; matches ffmpeg), DSP crate, 12 clip audio effects running on it (EQ, filters, dynamics, limiter, delay, reverb, DeNoise, DeHum, pitch) with keyframes | Effects UI polish (EQ curve), remaining effects (multiband, convolution reverb), track effects/mixers with automation, Essential Sound, audio transitions, 5.1 | 6–10 |
| M8 | Colour | 🟡 | Lumetri: basic, creative + looks, RGB & hue curves, wheels, HSL secondary, vignette; basic scopes | LUT import UI, colour match, colour management + HDR (PQ/HLG, log, tone mapping) | 8–12 |
| M9 | More codecs | 🟡 | ProRes decode+encode, AAC decode+encode, HEVC Main/Main 10 decoder (bit-exact on 41 fixtures, ~225 fps 1080p), Matroska/WebM import (H.264/HEVC/ProRes/MJPEG + AAC/FLAC/MP3/Vorbis/PCM) | VP9 and Opus (in progress), AV1 (rav1d), DNxHR, MXF, hardware decode | 12–20 |
-| M10 | Graphics & captions | ⬜ | — | Text engine, Type tool, Essential Graphics, captions (SRT/VTT/SCC), speech-to-text | 20–30 |
+| M10 | Graphics & captions | 🟡 | Caption tracks (Subtitle/CEA-608/708/Teletext formats, track style), SRT/WebVTT/SCC import+export (frame-exact, property-tested), caption editing (add/split/merge/trim/move, sync-locked insert/extract), Text panel Captions tab, burn-in in Program monitor and export | Text engine with shaping, Type tool, Essential Graphics, rolls/crawls, MCC/STL/TTML, 608/708 embedding, speech-to-text | 18–27 |
| M11 | Interchange & project management | 🟡 | `.fcproj` save/open | Autosave/recovery, FCP7 XML, FCPXML, EDL, OTIO, relink, project manager, proxies | 15 |
| M12–M16 | Web (WASM), platform, long tail | 🟡 | L0–L4 crates compile to wasm32 | Web app shell (file access, WebCodecs, audio), ~850 remaining commands and dialogs, performance hardening | 40–65 |
diff --git a/apps/filmcraft/src/main.rs b/apps/filmcraft/src/main.rs
index f2de58659..34d8f3cfc 100644
--- a/apps/filmcraft/src/main.rs
+++ b/apps/filmcraft/src/main.rs
@@ -75,6 +75,9 @@ fn main() -> eframe::Result {
app.hooks.pick_save = Some(Box::new(|name: &str| {
rfd::FileDialog::new().add_filter("FilmCraft Project", &["fcproj"]).set_file_name(name).save_file().map(|p| p.to_string_lossy().to_string())
}));
+ app.hooks.pick_save_as = Some(Box::new(|filter: &str, exts: &[&str], name: &str| {
+ rfd::FileDialog::new().add_filter(filter, exts).set_file_name(name).save_file().map(|p| p.to_string_lossy().to_string())
+ }));
app.hooks.pick_open_project =
Some(Box::new(|| rfd::FileDialog::new().add_filter("FilmCraft Project", &["fcproj"]).pick_file().map(|p| p.to_string_lossy().to_string())));
#[cfg(target_os = "macos")]
diff --git a/crates/ui-egui/src/frames.rs b/crates/ui-egui/src/frames.rs
index 209251404..79642695b 100644
--- a/crates/ui-egui/src/frames.rs
+++ b/crates/ui-egui/src/frames.rs
@@ -193,7 +193,7 @@ impl FrameServer {
&job.project,
seq,
job.time,
- filmcraft_render::RenderOptions { scale: job.scale, ..Default::default() },
+ filmcraft_render::RenderOptions { scale: job.scale, captions: true, ..Default::default() },
&provider,
);
self.shared.plans.lock().unwrap_or_else(|e| e.into_inner()).insert(job.key, (Arc::new(plan), 0));
@@ -226,7 +226,7 @@ fn worker(sh: Arc<Shared>, pool: Arc<MediaPool>, services: Arc<dyn Services>, re
&job.project,
seq,
job.time,
- filmcraft_render::RenderOptions { scale: job.scale, ..Default::default() },
+ filmcraft_render::RenderOptions { scale: job.scale, captions: true, ..Default::default() },
&provider,
);
let mut g = sh.plans.lock().unwrap_or_else(|e| e.into_inner());
@@ -257,7 +257,7 @@ fn render_job(job: &Job, pool: &Arc<MediaPool>, services: &Arc<dyn Services>) ->
&job.project,
seq,
job.time,
- filmcraft_render::RenderOptions { scale: job.scale, ..Default::default() },
+ filmcraft_render::RenderOptions { scale: job.scale, captions: true, ..Default::default() },
&provider,
)),
Target::Item(item) => filmcraft_render::render_item(&job.project, item, job.time, job.scale, &provider),
@@ -265,7 +265,7 @@ fn render_job(job: &Job, pool: &Arc<MediaPool>, services: &Arc<dyn Services>) ->
&job.project,
seq,
job.time,
- filmcraft_render::RenderOptions { scale: job.scale, ..Default::default() },
+ filmcraft_render::RenderOptions { scale: job.scale, captions: true, ..Default::default() },
&provider,
)),
};
diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs
index 6bd56fd39..e28744579 100644
--- a/crates/ui-egui/src/lib.rs
+++ b/crates/ui-egui/src/lib.rs
@@ -48,6 +48,8 @@ pub struct HostHooks {
pub pick_files: Option<Box<dyn FnMut(&[&str]) -> Vec<String>>>,
pub pick_save: Option<Box<dyn FnMut(&str) -> Option<String>>>,
pub pick_open_project: Option<Box<dyn FnMut() -> Option<String>>>,
+ /// Save dialog with a filter: (filter name, extensions, suggested file name) → path.
+ pub pick_save_as: Option<Box<dyn FnMut(&str, &[&str], &str) -> Option<String>>>,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
@@ -432,13 +434,14 @@ impl FilmcraftApp {
// ---------------------------------------------------------------- files
- pub fn file_dialog(&mut self, id: &str) -> Result<Value, String> {
+ pub fn file_dialog(&mut self, id: &str, params: &Value) -> Result<Value, String> {
match id {
"file.import" => {
let exts: Vec<&str> = filmcraft_media::VIDEO_EXTENSIONS
.iter()
.chain(filmcraft_media::AUDIO_EXTENSIONS)
.chain(filmcraft_media::STILL_EXTENSIONS)
+ .chain(&["srt", "vtt", "scc", "edl", "xml", "fcpxml", "otio"])
.copied()
.collect();
let paths = self.hooks.pick_files.as_mut().map(|f| f(&exts)).unwrap_or_default();
@@ -463,6 +466,21 @@ impl FilmcraftApp {
let Some(path) = self.hooks.pick_open_project.as_mut().and_then(|f| f()) else { return Ok(Value::Null) };
self.session.execute("file.open", json!({"path": path})).map_err(|e| e.to_string())
}
+ "captions.import" => {
+ let paths = self.hooks.pick_files.as_mut().map(|f| f(&["srt", "vtt", "scc"])).unwrap_or_default();
+ let Some(path) = paths.into_iter().next() else { return Ok(Value::Null) };
+ self.session.execute("captions.import", json!({"path": path})).map_err(|e| e.to_string())
+ }
+ "captions.export" => {
+ let name = self.session.state.active_sequence.and_then(|s| self.session.project.item(s)).map(|i| i.name.clone()).unwrap_or_default();
+ let suggested = format!("{}.srt", name.replace(' ', "_"));
+ let Some(path) = self.hooks.pick_save_as.as_mut().and_then(|f| f("Captions (SRT, WebVTT, SCC)", &["srt", "vtt", "scc"], &suggested)) else {
+ return Ok(Value::Null);
+ };
+ let mut p = params.clone();
+ p["path"] = json!(path);
+ self.session.execute("captions.export", p).map_err(|e| e.to_string())
+ }
_ => Err(format!("no dialog for {id}")),
}
}
diff --git a/crates/ui-egui/src/menus.rs b/crates/ui-egui/src/menus.rs
index 4c76afe69..950212a37 100644
--- a/crates/ui-egui/src/menus.rs
+++ b/crates/ui-egui/src/menus.rs
@@ -180,8 +180,9 @@ pub fn invoke(app: &mut FilmcraftApp, ctx: &egui::Context, id: &str, params: Val
|| (id == "file.saveAs" && params.get("path").is_none())
|| (id == "file.open" && params.get("path").is_none())
|| (id == "file.save" && params.get("path").is_none() && app.session.path.is_none())
+ || (matches!(id, "captions.import" | "captions.export") && params.get("path").is_none())
{
- return app.file_dialog(id);
+ return app.file_dialog(id, &params);
}
let r = app.session.execute(id, params).map_err(|e| e.to_string());
if let Err(e) = &r {
diff --git a/crates/ui-egui/src/panels/export_mode.rs b/crates/ui-egui/src/panels/export_mode.rs
index a7f8f0377..7131857e0 100644
--- a/crates/ui-egui/src/panels/export_mode.rs
+++ b/crates/ui-egui/src/panels/export_mode.rs
@@ -73,6 +73,12 @@ pub fn show(app: &mut FilmcraftApp, ui: &mut egui::Ui, rect: Rect) {
ui.label(v);
});
}
+ if !q.caption_tracks.is_empty() {
+ sui.add_space(6.0);
+ sui.label(egui::RichText::new("Captions").color(t.text_dim));
+ let r = sui.checkbox(&mut app.ui.export_burn_captions, "Burn Captions Into Video");
+ app.auto.add("export.burnCaptions", r.rect, "Burn Captions Into Video");
+ }
sui.add_space(12.0);
// jobs
let jobs: Vec<serde_json::Value> = app.session.jobs.iter().rev().take(4).map(|j| j.to_json()).collect();
@@ -97,7 +103,10 @@ pub fn show(app: &mut FilmcraftApp, ui: &mut egui::Ui, rect: Rect) {
ui.painter().text(b.center(), Align2::CENTER_CENTER, "Export", Tokens::semibold(13.0), Color32::WHITE);
app.auto.add("export.button", b, "Export");
if resp.clicked() {
- let r = app.session.execute("file.exportMedia", serde_json::json!({"path": expand_home(&app.ui.export_path), "format": app.ui.export_format}));
+ let r = app.session.execute(
+ "file.exportMedia",
+ serde_json::json!({"path": expand_home(&app.ui.export_path), "format": app.ui.export_format, "burnCaptions": app.ui.export_burn_captions}),
+ );
if let Err(e) = r {
app.ui.status = e.to_string();
}
diff --git a/crates/ui-egui/src/panels/mod.rs b/crates/ui-egui/src/panels/mod.rs
index ca9cca988..b9eed02a3 100644
--- a/crates/ui-egui/src/panels/mod.rs
+++ b/crates/ui-egui/src/panels/mod.rs
@@ -11,7 +11,9 @@ pub mod meters;
pub mod misc;
pub mod monitor;
pub mod project;
+pub mod text;
pub mod timeline;
+pub mod timeline_captions;
pub mod tools;
use egui::{Align2, Color32, Rect};
@@ -39,6 +41,7 @@ pub fn show(app: &mut FilmcraftApp, ui: &mut egui::Ui, p: PanelKind, rect: Rect)
PanelKind::MediaBrowser => misc::media_browser(app, ui, rect),
PanelKind::AudioTrackMixer => meters::track_mixer(app, ui, rect),
PanelKind::LumetriScopes => misc::scopes(app, ui, rect),
+ PanelKind::Text => text::show(app, ui, rect),
other => crate::dock::placeholder(ui, rect, &app.tokens, &format!("{} — coming in a later milestone", other.title())),
}
}
diff --git a/crates/ui-egui/src/panels/text.rs b/crates/ui-egui/src/panels/text.rs
new file mode 100644
index 000000000..7189c6508
--- /dev/null
+++ b/crates/ui-egui/src/panels/text.rs
@@ -0,0 +1,312 @@
+//! The Text panel: Transcript / Captions / Graphics tabs. The Captions tab lists the caption
+//! segments of a caption track with editable in/out timecodes and text, a toolbar (add, split,
+//! merge, delete), track choice and the track style. Every edit dispatches a `captions.*` engine
+//! command; every widget registers an automation id (`text.*`).
+
+use egui::{Align2, Color32, Rect, Sense, Stroke, StrokeKind, pos2, vec2};
+use filmcraft_project::{CaptionAlign, CaptionAnchor, CaptionFormat};
+use filmcraft_time::{TimeDisplay, format_time};
+use serde_json::{Value, json};
+
+use crate::FilmcraftApp;
+use crate::icons::{self, Icon};
+use crate::theme::Tokens;
+
+const TABS: [&str; 3] = ["Transcript", "Captions", "Graphics"];
+
+pub fn show(app: &mut FilmcraftApp, ui: &mut egui::Ui, rect: Rect) {
+ let t = app.tokens;
+ ui.painter().rect_filled(rect, 0.0, t.panel_bg);
+ // tabs
+ let mut x = rect.min.x + 12.0;
+ for tab in TABS {
+ let w = tab.len() as f32 * 7.0 + 16.0;
+ let r = Rect::from_min_size(pos2(x, rect.min.y + 4.0), vec2(w, 24.0));
+ let resp = ui.interact(r, egui::Id::new(("text-tab", tab)), Sense::click());
+ let active = app.ui.text_tab == tab;
+ ui.painter().text(
+ pos2(r.min.x, r.center().y),
+ Align2::LEFT_CENTER,
+ tab,
+ if active { Tokens::semibold(12.5) } else { Tokens::ui(12.5) },
+ if active { t.text } else { t.text_dim },
+ );
+ if active {
+ ui.painter().line_segment([pos2(r.min.x, r.max.y), pos2(r.min.x + w - 16.0, r.max.y)], Stroke::new(2.0, t.text));
+ }
+ app.auto.add(&format!("text.tab.{tab}"), r, tab);
+ if resp.clicked() {
+ app.ui.text_tab = tab.to_string();
+ }
+ x += w + 6.0;
+ }
+ let body = Rect::from_min_max(pos2(rect.min.x, rect.min.y + 34.0), rect.max);
+ match app.ui.text_tab.as_str() {
+ "Captions" => captions(app, ui, body),
+ "Transcript" => crate::dock::placeholder(ui, body, &t, "Transcript (speech-to-text) arrives in M10.5"),
+ _ => crate::dock::placeholder(ui, body, &t, "Graphics text search arrives with M10.1–M10.2"),
+ }
+}
+
+fn tool_button(app: &mut FilmcraftApp, ui: &mut egui::Ui, r: Rect, icon: Icon, id: &str, label: &str, enabled: bool) -> bool {
+ let t = app.tokens;
+ let resp = ui.interact(r, egui::Id::new(("text-tool", id)), if enabled { Sense::click() } else { Sense::hover() });
+ if enabled && resp.hovered() {
+ ui.painter().rect_filled(r, 3.0, t.hover);
+ }
+ icons::paint(ui.painter(), r.shrink(5.0), icon, if enabled { t.icon } else { t.text_faint });
+ app.auto.add(id, r, label);
+ resp.on_hover_text(label).clicked() && enabled
+}
+
+fn captions(app: &mut FilmcraftApp, ui: &mut egui::Ui, rect: Rect) {
+ let t = app.tokens;
+ let Some(seq) = app.session.active_sequence().cloned() else {
+ crate::dock::placeholder(ui, rect, &t, "Open a sequence to work with captions");
+ return;
+ };
+ let mut actions: Vec<(String, Value)> = Vec::new();
+ if seq.caption_tracks.is_empty() {
+ let c = rect.center();
+ icons::paint(ui.painter(), Rect::from_center_size(c - vec2(0.0, 70.0), vec2(40.0, 40.0)), Icon::Captions, t.text_dim);
+ ui.painter().text(c - vec2(0.0, 30.0), Align2::CENTER_CENTER, "Add captions", Tokens::semibold(16.0), t.text);
+ ui.painter().text(c - vec2(0.0, 8.0), Align2::CENTER_CENTER, "Create a caption track or import a caption file.", Tokens::ui(12.0), t.text_dim);
+ for (i, (id, label, cmd)) in
+ [("text.captions.newTrack", "Create new caption track", "captions.newTrack"), ("text.captions.import", "Import captions file…", "captions.import")]
+ .into_iter()
+ .enumerate()
+ {
+ let r = Rect::from_center_size(c + vec2(0.0, 26.0 + i as f32 * 34.0), vec2(200.0, 26.0));
+ let resp = ui.interact(r, egui::Id::new(id), Sense::click());
+ ui.painter().rect_filled(r, 13.0, if i == 0 { if resp.hovered() { t.accent_hover } else { t.accent } } else { t.field_bg });
+ ui.painter().text(r.center(), Align2::CENTER_CENTER, label, Tokens::semibold(12.0), Color32::WHITE);
+ app.auto.add(id, r, label);
+ if resp.clicked() {
+ actions.push((cmd.into(), json!({})));
+ }
+ }
+ run(app, ui, actions);
+ return;
+ }
+ let rate = seq.settings.frame_rate;
+ let df = seq.settings.drop_frame;
+ let tc = |x: filmcraft_time::Tick| format_time(x, rate, df, TimeDisplay::Timecode, 48_000);
+ // the track shown: the one holding the first selected caption, else C1
+ let sel = app.session.state.caption_selection.clone();
+ let track_idx = sel.first().and_then(|c| seq.caption_tracks.iter().position(|tr| tr.caption(*c).is_some())).unwrap_or(0);
+ let track_idx = ui.ctx().data(|d| d.get_temp::<usize>(egui::Id::new("text-cap-track"))).filter(|i| *i < seq.caption_tracks.len()).unwrap_or(track_idx);
+ let track = &seq.caption_tracks[track_idx];
+
+ // ---- toolbar: search, track picker, add / split / merge / delete
+ let bar = Rect::from_min_size(rect.min + vec2(10.0, 2.0), vec2(rect.width() - 20.0, 26.0));
+ let mut child = ui.new_child(egui::UiBuilder::new().max_rect(Rect::from_min_size(bar.min, vec2(170.0f32.min(bar.width() * 0.4), 24.0))));
+ let sresp = crate::widgets::search_field(&mut child, &mut app.ui.caption_search, "Search", 170.0f32.min(bar.width() * 0.4), &t);
+ app.auto.add("text.captions.search", sresp.rect, "Search captions");
+ let mut x = bar.min.x + 180.0f32.min(bar.width() * 0.4 + 10.0);
+ let picker = Rect::from_min_size(pos2(x, bar.min.y + 1.0), vec2(130.0, 22.0));
+ let label = format!("C{} · {}", track_idx + 1, track.name);
+ let presp = crate::widgets::dropdown_text(ui, picker, &label, &t, egui::Id::new("text-cap-track-picker"));
+ app.auto.add("text.captions.track", picker, "Caption track");
+ egui::Popup::menu(&presp).show(|ui| {
+ for (i, tr) in seq.caption_tracks.iter().enumerate() {
+ if ui.selectable_label(i == track_idx, format!("C{} · {} ({})", i + 1, tr.name, tr.format.label())).clicked() {
+ ui.ctx().data_mut(|d| d.insert_temp(egui::Id::new("text-cap-track"), i));
+ }
+ }
+ ui.separator();
+ for f in CaptionFormat::ALL {
+ if ui.button(format!("New {} track", f.label())).clicked() {
+ actions.push(("captions.newTrack".into(), json!({"format": f.label()})));
+ }
+ }
+ });
+ x = picker.max.x + 8.0;
+ let ph = app.session.playhead();
+ let any_sel = !sel.is_empty();
+ let under = track.caption_at(ph).filter(|c| c.start < ph).map(|c| c.id);
+ let tools: [(Icon, &str, &str, bool, &str, Value); 5] = [
+ (Icon::Plus, "text.captions.add", "Add caption at playhead", track.caption_at(ph).is_none(), "captions.add", json!({"track": track.id.0})),
+ (
+ Icon::Razor,
+ "text.captions.split",
+ "Split caption at playhead",
+ under.is_some(),
+ "captions.split",
+ json!({"caption": under.map(|c| c.0), "time": ph.0}),
+ ),
+ (Icon::Link, "text.captions.merge", "Merge selected captions", sel.len() > 1, "captions.merge", json!({})),
+ (Icon::Trash, "text.captions.delete", "Delete selected captions", any_sel, "captions.delete", json!({})),
+ (Icon::Export, "text.captions.export", "Export captions…", !track.captions.is_empty(), "captions.export", json!({"track": track.id.0})),
+ ];
+ for (icon, id, label, enabled, cmd, params) in tools {
+ let r = Rect::from_min_size(pos2(x, bar.min.y), vec2(24.0, 24.0));
+ if r.max.x > rect.max.x {
+ break;
+ }
+ if tool_button(app, ui, r, icon, id, label, enabled) {
+ actions.push((cmd.into(), params));
+ }
+ x += 28.0;
+ }
+
+ // ---- style strip
+ let style_h = 30.0;
+ let style_rect = Rect::from_min_max(pos2(rect.min.x + 10.0, rect.max.y - style_h), pos2(rect.max.x - 10.0, rect.max.y - 2.0));
+ style_strip(app, ui, style_rect, track_idx, &mut actions);
+
+ // ---- segment list
+ let list = Rect::from_min_max(pos2(rect.min.x + 6.0, bar.max.y + 8.0), pos2(rect.max.x - 6.0, style_rect.min.y - 6.0));
+ ui.painter().rect_filled(list, 3.0, t.app_bg);
+ let q = app.ui.caption_search.to_lowercase();
+ let mut child = ui.new_child(egui::UiBuilder::new().max_rect(list.shrink(4.0)).id_salt("caption-list"));
+ let current = track.caption_at(ph).map(|c| c.id);
+ egui::ScrollArea::vertical().auto_shrink([false, false]).id_salt("caption-scroll").show(&mut child, |ui| {
+ ui.set_width(list.width() - 12.0);
+ let mut shown = 0;
+ for (n, c) in track.captions.iter().enumerate() {
+ if !q.is_empty() && !c.text.to_lowercase().contains(&q) && !c.speaker.as_deref().unwrap_or("").to_lowercase().contains(&q) {
+ continue;
+ }
+ shown += 1;
+ let selected = sel.contains(&c.id);
+ let fill = if selected {
+ t.row_selected
+ } else if n % 2 == 1 {
+ t.row_alt
+ } else {
+ Color32::TRANSPARENT
+ };
+ let frame = egui::Frame::NONE.fill(fill).inner_margin(egui::Margin::symmetric(6, 4)).corner_radius(3.0);
+ let fr = frame.show(ui, |ui| {
+ ui.horizontal_top(|ui| {
+ ui.vertical(|ui| {
+ ui.set_width(92.0);
+ let num = ui.add(egui::Button::new(egui::RichText::new(format!("{}", n + 1)).size(11.0).color(t.text_dim)).frame(false));
+ app.auto.add(&format!("text.captions.{}.goto", c.id.0), num.rect, "Go to caption");
+ if num.clicked() {
+ if ui.input(|i| i.modifiers.command || i.modifiers.shift) {
+ actions.push(("captions.select".into(), json!({"captions": [c.id.0], "add": true})));
+ } else {
+ actions.push(("captions.goTo".into(), json!({"caption": c.id.0})));
+ }
+ }
+ for (edge, val) in [("in", c.start), ("out", c.end())] {
+ let key = egui::Id::new(("cap-tc", c.id.0, edge));
+ let mut buf = ui.data(|d| d.get_temp::<String>(key)).unwrap_or_else(|| tc(val));
+ let resp = ui.add(
+ egui::TextEdit::singleline(&mut buf)
+ .id(key.with("te"))
+ .desired_width(88.0)
+ .font(Tokens::mono(11.0))
+ .text_color(if edge == "in" { t.hot_text } else { t.text_dim }),
+ );
+ app.auto.add(&format!("text.captions.{}.{edge}", c.id.0), resp.rect, if edge == "in" { "Caption in" } else { "Caption out" });
+ if resp.has_focus() {
+ ui.data_mut(|d| d.insert_temp(key, buf.clone()));
+ } else {
+ ui.data_mut(|d| d.remove::<String>(key));
+ }
+ if resp.lost_focus() && buf.trim() != tc(val) {
+ let k = if edge == "in" { "startTimecode" } else { "endTimecode" };
+ actions.push(("captions.setTimes".into(), json!({"caption": c.id.0, k: buf.trim()})));
+ }
+ }
+ });
+ ui.vertical(|ui| {
+ if let Some(sp) = &c.speaker {
+ ui.label(egui::RichText::new(sp).size(11.0).color(t.text_dim).strong());
+ }
+ let key = egui::Id::new(("cap-text", c.id.0));
+ let mut buf = ui.data(|d| d.get_temp::<String>(key)).unwrap_or_else(|| c.text.clone());
+ let resp = ui.add(
+ egui::TextEdit::multiline(&mut buf)
+ .id(key.with("te"))
+ .desired_rows(1)
+ .desired_width(ui.available_width())
+ .font(Tokens::ui(12.5))
+ .frame(egui::Frame::NONE),
+ );
+ app.auto.add(&format!("text.captions.{}.text", c.id.0), resp.rect, "Caption text");
+ if resp.has_focus() {
+ ui.data_mut(|d| d.insert_temp(key, buf.clone()));
+ if !selected {
+ actions.push(("captions.select".into(), json!({"captions": [c.id.0]})));
+ }
+ } else {
+ ui.data_mut(|d| d.remove::<String>(key));
+ }
+ if resp.lost_focus() && buf != c.text {
+ actions.push(("captions.setText".into(), json!({"caption": c.id.0, "text": buf})));
+ }
+ });
+ });
+ });
+ let row = fr.response.rect;
+ if current == Some(c.id) {
+ ui.painter().rect_stroke(row, 3.0, Stroke::new(1.0, t.accent), StrokeKind::Inside);
+ }
+ app.auto.add(&format!("text.captions.{}.row", c.id.0), row, &c.text);
+ ui.add_space(2.0);
+ }
+ if shown == 0 {
+ ui.label(
+ egui::RichText::new(if q.is_empty() { "No captions on this track. Press + to add one at the playhead." } else { "No matching captions." })
+ .color(t.text_faint),
+ );
+ }
+ });
+ run(app, ui, actions);
+}
+
+fn style_strip(app: &mut FilmcraftApp, ui: &mut egui::Ui, r: Rect, track_idx: usize, actions: &mut Vec<(String, Value)>) {
+ let Some(tr) = app.session.active_sequence().and_then(|q| q.caption_tracks.get(track_idx)).cloned() else { return };
+ let st = tr.style.clone();
+ let mut child = ui.new_child(egui::UiBuilder::new().max_rect(r).id_salt("caption-style"));
+ child.horizontal_centered(|ui| {
+ ui.spacing_mut().item_spacing.x = 6.0;
+ let mut size = st.size;
+ let resp = ui.add(egui::DragValue::new(&mut size).range(8.0..=200.0).speed(0.5).suffix(" px"));
+ app.auto.add("text.captions.style.size", resp.rect, "Caption size");
+ if resp.drag_stopped() || (resp.changed() && !resp.dragged()) {
+ actions.push(("captions.setStyle".into(), json!({"track": tr.id.0, "size": size})));
+ }
+ let mut col = Color32::from_rgba_unmultiplied(st.color[0], st.color[1], st.color[2], st.color[3]);
+ let resp = egui::color_picker::color_edit_button_srgba(ui, &mut col, egui::color_picker::Alpha::Opaque);
+ app.auto.add("text.captions.style.color", resp.rect, "Text colour");
+ if resp.changed() {
+ let c = col.to_srgba_unmultiplied();
+ actions.push(("captions.setStyle".into(), json!({"track": tr.id.0, "color": c})));
+ }
+ let mut bg = st.background;
+ let resp = ui.checkbox(&mut bg, "Box");
+ app.auto.add("text.captions.style.background", resp.rect, "Background box");
+ if resp.changed() {
+ actions.push(("captions.setStyle".into(), json!({"track": tr.id.0, "background": bg})));
+ }
+ ui.label(egui::RichText::new("Align").size(11.0).color(app.tokens.text_dim));
+ for (a, icon_txt, name) in [(CaptionAlign::Left, "L", "left"), (CaptionAlign::Center, "C", "center"), (CaptionAlign::Right, "R", "right")] {
+ let resp = ui.selectable_label(st.align == a, icon_txt).on_hover_text(format!("Align {name}"));
+ app.auto.add(&format!("text.captions.style.align.{name}"), resp.rect, name);
+ if resp.clicked() {
+ actions.push(("captions.setStyle".into(), json!({"track": tr.id.0, "align": name})));
+ }
+ }
+ ui.label(egui::RichText::new("Position").size(11.0).color(app.tokens.text_dim));
+ for (a, name) in [(CaptionAnchor::Top, "top"), (CaptionAnchor::Middle, "middle"), (CaptionAnchor::Bottom, "bottom")] {
+ let resp = ui.selectable_label(st.anchor == a, name[..1].to_uppercase()).on_hover_text(format!("Position: {name}"));
+ app.auto.add(&format!("text.captions.style.anchor.{name}"), resp.rect, name);
+ if resp.clicked() {
+ actions.push(("captions.setStyle".into(), json!({"track": tr.id.0, "anchor": name})));
+ }
+ }
+ });
+}
+
+fn run(app: &mut FilmcraftApp, ui: &egui::Ui, actions: Vec<(String, Value)>) {
+ let ctx = ui.ctx().clone();
+ for (cmd, p) in actions {
+ if let Err(e) = crate::menus::invoke(app, &ctx, &cmd, p) {
+ app.ui.status = e;
+ }
+ }
+}
diff --git a/crates/ui-egui/src/panels/timeline.rs b/crates/ui-egui/src/panels/timeline.rs
index 6ef671f7f..7f4ad4596 100644
--- a/crates/ui-egui/src/panels/timeline.rs
+++ b/crates/ui-egui/src/panels/timeline.rs
@@ -162,7 +162,11 @@ pub fn show(app: &mut FilmcraftApp, ui: &mut egui::Ui, rect: Rect) {
let scroll = app.ui.timeline.scroll;
// ---- rows
- let tracks_area = Rect::from_min_max(content.min, content.max);
+ // caption tracks sit in their own area above the video tracks
+ let cap_n = seq.caption_tracks.len();
+ let caption_area = Rect::from_min_max(pos2(rect.min.x, content.min.y), pos2(content.max.x, content.min.y + cap_n as f32 * super::timeline_captions::ROW_H));
+ let cap_h = if cap_n > 0 { caption_area.height() + DIVIDER_H } else { 0.0 };
+ let tracks_area = Rect::from_min_max(pos2(content.min.x, content.min.y + cap_h), content.max);
let split_y = tracks_area.min.y + (tracks_area.height() - DIVIDER_H) * app.ui.timeline.split;
let video_area = Rect::from_min_max(pos2(rect.min.x, tracks_area.min.y), pos2(content.max.x, split_y));
let audio_area = Rect::from_min_max(pos2(rect.min.x, split_y + DIVIDER_H), pos2(content.max.x, tracks_area.max.y - MASTER_H));
@@ -284,6 +288,12 @@ pub fn show(app: &mut FilmcraftApp, ui: &mut egui::Ui, rect: Rect) {
t.hot_text,
);
+ // ---- caption tracks
+ if cap_n > 0 {
+ painter.rect_filled(Rect::from_min_max(pos2(rect.min.x, caption_area.max.y), pos2(content.max.x, caption_area.max.y + DIVIDER_H)), 0.0, t.app_bg);
+ super::timeline_captions::paint(app, ui, &seq, caption_area, &layout, &t);
+ }
+
// ---- top block: timecode + toggles, ruler
draw_top(app, ui, rect, &seq, &layout, &t, seq_id);
@@ -333,6 +343,9 @@ pub fn show(app: &mut FilmcraftApp, ui: &mut egui::Ui, rect: Rect) {
// ---- interaction
interact(app, ui, &seq, &layout, rect);
+ if cap_n > 0 {
+ super::timeline_captions::interact(app, ui, &seq, caption_area, &layout);
+ }
let _ = (visible, TICKS_PER_SECOND);
}
diff --git a/crates/ui-egui/src/panels/timeline_captions.rs b/crates/ui-egui/src/panels/timeline_captions.rs
new file mode 100644
index 000000000..b154f5540
--- /dev/null
+++ b/crates/ui-egui/src/panels/timeline_captions.rs
@@ -0,0 +1,268 @@
+//! Caption track rows of the Timeline: drawn in their own area above the video tracks (Premiere's
+//! layout). Each row has a header (C1…, name, format, output eye, lock) and caption blocks in a
+//! distinct colour showing their text. Click selects (Cmd/Shift adds), dragging the body moves,
+//! dragging an edge trims, double-click opens the Text panel's Captions tab. Every gesture ends in
+//! one `captions.*` command; every element registers an automation id (`timeline.caption.*`,
+//! `timeline.captionTrack.C1.*`).
+
+use egui::{Align2, Color32, CursorIcon, Rect, Sense, Stroke, StrokeKind, pos2, vec2};
+use filmcraft_project::{CaptionTrack, ClipId, Sequence};
+use filmcraft_time::Tick;
+use serde_json::{Value, json};
+
+use super::timeline::Layout;
+use crate::FilmcraftApp;
+use crate::dock::PanelKind;
+use crate::icons::Icon;
+use crate::theme::Tokens;
+
+/// Height of one caption track row.
+pub const ROW_H: f32 = 28.0;
+/// Caption block colours (fill, selected fill).
+const FILL: Color32 = Color32::from_rgb(0x6b, 0x4f, 0x8f);
+const FILL_SEL: Color32 = Color32::from_rgb(0x8c, 0x6c, 0xb4);
+const ROW_BG: Color32 = Color32::from_rgb(0x23, 0x20, 0x2a);
+
+/// Row rects (full width incl. header) for each caption track, top first.
+pub fn rows(area: Rect, n: usize) -> Vec<Rect> {
+ (0..n).map(|i| Rect::from_min_size(pos2(area.min.x, area.min.y + i as f32 * ROW_H), vec2(area.width(), ROW_H))).collect()
+}
+
+#[derive(Clone, Copy, Debug)]
+enum Gesture {
+ Move,
+ TrimIn,
+ TrimOut,
+}
+
+fn drag_id() -> egui::Id {
+ egui::Id::new("caption-drag")
+}
+
+/// Live drag state: (caption, gesture, delta ticks).
+fn drag_state(ctx: &egui::Context) -> Option<(u64, u8, i64)> {
+ ctx.data(|d| d.get_temp::<(u64, u8, i64)>(drag_id()))
+}
+
+fn block_rect(c: &filmcraft_project::Caption, row: Rect, layout: &Layout, drag: Option<(u64, u8, i64)>) -> Rect {
+ let (mut s, mut e) = (c.start, c.end());
+ if let Some((id, g, d)) = drag.filter(|d| d.0 == c.id.0) {
+ let _ = id;
+ match g {
+ 0 => {
+ s += Tick(d);
+ e += Tick(d);
+ }
+ 1 => s = (s + Tick(d)).min(e),
+ _ => e = (e + Tick(d)).max(s),
+ }
+ }
+ Rect::from_min_max(pos2(layout.x_of(s), row.min.y + 2.0), pos2(layout.x_of(e).max(layout.x_of(s) + 1.0), row.max.y - 2.0))
+}
+
+/// Paint headers and caption blocks.
+pub fn paint(app: &mut FilmcraftApp, ui: &mut egui::Ui, seq: &Sequence, area: Rect, layout: &Layout, t: &Tokens) {
+ if seq.caption_tracks.is_empty() {
+ return;
+ }
+ let hw = app.ui.timeline.header_w;
+ let content = layout.content;
+ let painter = ui.painter().with_clip_rect(area);
+ let sel = app.session.state.caption_selection.clone();
+ let drag = drag_state(ui.ctx());
+ let mut actions: Vec<(String, Value)> = Vec::new();
+ for (i, (tr, row)) in seq.caption_tracks.iter().zip(rows(area, seq.caption_tracks.len())).enumerate() {
+ let lane = Rect::from_min_max(pos2(content.min.x, row.min.y), pos2(content.max.x, row.max.y));
+ painter.rect_filled(lane, 0.0, ROW_BG);
+ painter.line_segment([pos2(row.min.x, row.max.y - 0.5), pos2(row.max.x, row.max.y - 0.5)], Stroke::new(1.0, t.tl_bg));
+ // header
+ let label = format!("C{}", i + 1);
+ let hrect = Rect::from_min_max(row.min, pos2(row.min.x + hw, row.max.y));
+ painter.rect_filled(hrect, 0.0, t.tl_header_bg);
+ painter.line_segment([pos2(hrect.min.x, hrect.max.y - 0.5), pos2(hrect.max.x, hrect.max.y - 0.5)], Stroke::new(1.0, t.separator));
+ let badge = Rect::from_min_size(pos2(hrect.min.x + 13.0, row.min.y + 3.0), vec2(24.0, ROW_H - 6.0));
+ painter.rect_filled(badge, 3.0, if tr.enabled { FILL } else { t.field_bg });
+ painter.text(badge.center(), Align2::CENTER_CENTER, &label, Tokens::semibold(10.5), Color32::WHITE);
+ app.auto.add(&format!("timeline.captionTrack.{label}"), badge, &tr.name);
+ let lock_r = Rect::from_center_size(pos2(hrect.min.x + 49.0, row.center().y), vec2(18.0, 18.0));
+ let lresp = crate::widgets::icon_toggle(
+ ui,
+ lock_r,
+ if tr.locked { Icon::Lock } else { Icon::Unlock },
+ true,
+ t,
+ egui::Id::new(("cap-lock", tr.id.0)),
+ Some(if tr.locked { Color32::from_rgb(0xd1, 0xd1, 0xd1) } else { t.text_dim }),
+ );
+ app.auto.add(&format!("timeline.captionTrack.{label}.locked"), lock_r, "Toggle Caption Track Lock");
+ if lresp.clicked() {
+ actions.push(("captions.setTrack".into(), json!({"track": tr.id.0, "locked": !tr.locked})));
+ }
+ let eye_r = Rect::from_center_size(pos2(hrect.min.x + 73.0, row.center().y), vec2(18.0, 18.0));
+ let eresp = crate::widgets::icon_toggle(
+ ui,
+ eye_r,
+ if tr.enabled { Icon::Eye } else { Icon::EyeOff },
+ true,
+ t,
+ egui::Id::new(("cap-eye", tr.id.0)),
+ Some(t.text_dim),
+ );
+ app.auto.add(&format!("timeline.captionTrack.{label}.enabled"), eye_r, "Toggle Caption Track Output");
+ if eresp.clicked() {
+ actions.push(("captions.setTrack".into(), json!({"track": tr.id.0, "enabled": !tr.enabled})));
+ }
+ let name = format!("{} · {}", tr.name, tr.format.label());
+ painter.with_clip_rect(Rect::from_min_max(pos2(hrect.min.x + 86.0, row.min.y), pos2(hrect.max.x - 4.0, row.max.y))).text(
+ pos2(hrect.min.x + 90.0, row.center().y),
+ Align2::LEFT_CENTER,
+ name,
+ Tokens::ui(11.0),
+ t.text_dim,
+ );
+ // caption blocks
+ let p = painter.with_clip_rect(lane);
+ let (v0, v1) = (layout.tick_at(content.min.x - 2.0), layout.tick_at(content.max.x + 2.0));
+ for c in tr.captions.iter().filter(|c| c.end() >= v0 && c.start <= v1) {
+ let r = block_rect(c, row, layout, drag);
+ let selected = sel.contains(&c.id);
+ p.rect_filled(r, 3.0, if selected { FILL_SEL } else { FILL });
+ if selected {
+ p.rect_stroke(r, 3.0, Stroke::new(1.0, t.clip_selected_border), StrokeKind::Inside);
+ }
+ if r.width() > 14.0 {
+ let text = filmcraft_project::plain_text(&c.text).replace('\n', " ");
+ p.with_clip_rect(r.shrink2(vec2(4.0, 0.0)).intersect(lane)).text(
+ pos2(r.min.x + 5.0, r.center().y),
+ Align2::LEFT_CENTER,
+ text,
+ Tokens::ui(11.0),
+ if tr.enabled { Color32::WHITE } else { t.text_dim },
+ );
+ }
+ app.auto.add(&format!("timeline.caption.{}", c.id.0), r.intersect(lane), &c.text);
+ }
+ if tr.locked {
+ p.rect_filled(lane, 0.0, Color32::from_black_alpha(70));
+ }
+ }
+ // column separator
+ painter.line_segment([pos2(area.min.x + hw - 0.5, area.min.y), pos2(area.min.x + hw - 0.5, area.max.y)], Stroke::new(1.0, t.separator));
+ run(app, ui, actions);
+}
+
+/// Pointer interaction on caption blocks (call after the timeline's own interaction so captions
+/// are on top).
+pub fn interact(app: &mut FilmcraftApp, ui: &mut egui::Ui, seq: &Sequence, area: Rect, layout: &Layout) {
+ let ctx = ui.ctx().clone();
+ let rate = seq.settings.frame_rate;
+ let drag = drag_state(&ctx);
+ let mut actions: Vec<(String, Value)> = Vec::new();
+ for (tr, row) in seq.caption_tracks.iter().zip(rows(area, seq.caption_tracks.len())) {
+ let lane = Rect::from_min_max(pos2(layout.content.min.x, row.min.y), pos2(layout.content.max.x, row.max.y));
+ for c in &tr.captions {
+ let r = block_rect(c, row, layout, drag).intersect(lane);
+ if r.width() <= 0.0 {
+ continue;
+ }
+ interact_block(app, ui, tr, c, r, rate, &mut actions);
+ }
+ }
+ run(app, ui, actions);
+}
+
+fn interact_block(
+ app: &mut FilmcraftApp,
+ ui: &mut egui::Ui,
+ tr: &CaptionTrack,
+ c: &filmcraft_project::Caption,
+ r: Rect,
+ rate: filmcraft_time::FrameRate,
+ actions: &mut Vec<(String, Value)>,
+) {
+ let ctx = ui.ctx().clone();
+ let resp = ui.interact(r, egui::Id::new(("caption-block", c.id.0)), Sense::click_and_drag());
+ let edge = 5.0f32.min(r.width() / 4.0);
+ let gesture_at = |x: f32| {
+ if x - r.min.x < edge {
+ Gesture::TrimIn
+ } else if r.max.x - x < edge {
+ Gesture::TrimOut
+ } else {
+ Gesture::Move
+ }
+ };
+ if let Some(p) = resp.hover_pos()
+ && !tr.locked
+ {
+ ctx.set_cursor_icon(match gesture_at(p.x) {
+ Gesture::Move => CursorIcon::Default,
+ _ => CursorIcon::ResizeColumn,
+ });
+ }
+ if resp.double_clicked() {
+ app.show_panel(PanelKind::Text);
+ app.ui.text_tab = "Captions".into();
+ actions.push(("captions.goTo".into(), json!({"caption": c.id.0})));
+ return;
+ }
+ if resp.clicked() {
+ let add = ctx.input(|i| i.modifiers.command || i.modifiers.shift);
+ actions.push(("captions.select".into(), json!({"captions": [c.id.0], "add": add})));
+ }
+ if tr.locked {
+ return;
+ }
+ if resp.drag_started()
+ && let Some(p) = resp.interact_pointer_pos()
+ {
+ let g = match gesture_at(p.x) {
+ Gesture::Move => 0u8,
+ Gesture::TrimIn => 1,
+ Gesture::TrimOut => 2,
+ };
+ ctx.data_mut(|d| d.insert_temp(egui::Id::new("caption-drag-origin"), p.x));
+ ctx.data_mut(|d| d.insert_temp(drag_id(), (c.id.0, g, 0i64)));
+ if !app.session.state.caption_selection.contains(&c.id) {
+ actions.push(("captions.select".into(), json!({"captions": [c.id.0]})));
+ }
+ }
+ if resp.dragged()
+ && let (Some((id, g, _)), Some(p)) = (drag_state(&ctx), resp.interact_pointer_pos())
+ && id == c.id.0
+ {
+ let x0 = ctx.data(|d| d.get_temp::<f32>(egui::Id::new("caption-drag-origin"))).unwrap_or(p.x);
+ let pps = app.ui.timeline.pps;
+ let d = rate.snap_nearest(Tick::from_seconds_f64((p.x - x0) as f64 / pps));
+ ctx.data_mut(|dd| dd.insert_temp(drag_id(), (id, g, d.0)));
+ }
+ if resp.drag_stopped()
+ && let Some((id, g, d)) = drag_state(&ctx)
+ && id == c.id.0
+ {
+ ctx.data_mut(|dd| dd.remove::<(u64, u8, i64)>(drag_id()));
+ if d != 0 {
+ match g {
+ 0 => {
+ let sel: Vec<u64> = if app.session.state.caption_selection.contains(&ClipId(id)) {
+ app.session.state.caption_selection.iter().map(|c| c.0).collect()
+ } else {
+ vec![id]
+ };
+ actions.push(("captions.move".into(), json!({"captions": sel, "delta": d})));
+ }
+ 1 => actions.push(("captions.trim".into(), json!({"caption": id, "edge": "in", "delta": d}))),
+ _ => actions.push(("captions.trim".into(), json!({"caption": id, "edge": "out", "delta": d}))),
+ }
+ }
+ }
+}
+
+fn run(app: &mut FilmcraftApp, ui: &egui::Ui, actions: Vec<(String, Value)>) {
+ let ctx = ui.ctx().clone();
+ for (cmd, p) in actions {
+ if let Err(e) = crate::menus::invoke(app, &ctx, &cmd, p) {
+ app.ui.status = e;
+ }
+ }
+}
diff --git a/crates/ui-egui/src/state.rs b/crates/ui-egui/src/state.rs
index 8c214ff43..7e89c264d 100644
--- a/crates/ui-egui/src/state.rs
+++ b/crates/ui-egui/src/state.rs
@@ -263,6 +263,19 @@ pub struct UiState {
pub export_format: String,
#[serde(default)]
pub export_path: String,
+ /// Export mode: burn visible caption tracks into the video.
+ #[serde(default)]
+ pub export_burn_captions: bool,
+ /// Text panel: active tab ("Transcript" / "Captions" / "Graphics").
+ #[serde(default = "captions_tab")]
+ pub text_tab: String,
+ /// Text panel: caption search filter.
+ #[serde(default)]
+ pub caption_search: String,
+}
+
+fn captions_tab() -> String {
+ "Captions".into()
}
impl Default for UiState {
@@ -289,6 +302,9 @@ impl Default for UiState {
status: String::new(),
export_format: "h264".into(),
export_path: String::new(),
+ export_burn_captions: false,
+ text_tab: captions_tab(),
+ caption_search: String::new(),
}
}
}
diff --git a/docs/captions.md b/docs/captions.md
new file mode 100644
index 000000000..0cac44d7a
--- /dev/null
+++ b/docs/captions.md
@@ -0,0 +1,79 @@
+# Captions
+
+FilmCraft keeps captions on **caption tracks** in the sequence, shown in their own area above the
+video tracks (as Premiere does). Caption tracks are saved in the `.fcproj` (project format
+version 2; version 1 projects open with no caption tracks).
+
+## Model
+
+- **Caption track** (`CaptionTrack`, `crates/project/src/caption.rs`): name, format (`Subtitle`,
+ `CEA-608`, `CEA-708`, `Teletext`), language, output eye (shown in the Program monitor and
+ burned in on export), lock, sync lock, and a **track style**:
+ font size (pixels at 1080 lines, scaled to the frame), text colour, background box and its colour,
+ outline width and colour, alignment (left/centre/right), position (top/middle/bottom) and
+ margin, line spacing.
+- **Caption**: in/out in exact `Tick`s, text (lines separated by `\n`; `<i>`, `<b>`, `<u>` kept
+ as written), optional speaker, and the WebVTT cue id and cue settings, kept for round trips.
+ Captions on a track never overlap.
+
+## Files
+
+| Format | Import | Export | Notes |
+|---|---|---|---|
+| SubRip `.srt` | ✓ | ✓ | Forgiving reader (BOM, UTF-16, Windows-1252, CRLF, missing indexes, `,`/`.` ms, missing hours). |
+| WebVTT `.vtt` | ✓ | ✓ | Keeps cue ids, cue settings, `<v Speaker>`, STYLE/REGION/NOTE blocks. `line:N%` and `align:` are honoured when drawing. |
+| Scenarist SCC `.scc` | ✓ | ✓ | CEA-608 at 29.97 fps. Reads pop-on, roll-up and paint-on; writes pop-on with drop-frame (default) or non-drop timecode. |
+
+`File ▸ Import` (or dropping a file) recognises caption files by extension and content and adds a
+new caption track to the open sequence (a sequence is created when none is open). Cue times are
+snapped to the sequence's frames. `File ▸ Export ▸ Captions…` writes the chosen caption track in
+the format given by the file extension (`.srt`, `.vtt`, `.scc`).
+
+Details of each format and the SCC encoder are in [`crates/captions/README.md`](../crates/captions/README.md).
+
+## Editing
+
+| Command | Menu / shortcut | Params |
+|---|---|---|
+| `captions.newTrack` | Sequence ▸ Captions ▸ Add New Caption Track… (⌥⌘A) | `format`, `name`, `language` |
+| `captions.add` | Sequence ▸ Captions ▸ Add Caption at Playhead (⌥⌘C) | `track`, `text`, `time`, `durationSeconds` (3) |
+| `captions.next` / `captions.previous` | Sequence ▸ Captions ▸ Go to Next/Previous Caption Segment (⌥⌘↓/↑) | |
+| `captions.showAll` / `captions.hideAll` | Sequence ▸ Captions | |
+| `captions.split` | Text panel ✂ | `caption`, `time` (default: every caption under the playhead) |
+| `captions.merge` | Text panel | `captions` (consecutive, one track) |
+| `captions.setText` | Text panel text field | `caption`, `text`, `speaker` |
+| `captions.setTimes` | Text panel in/out fields | `caption`, `start…`/`end…` (`Time` ticks, `Frame`, `Seconds`, `Timecode`) |
+| `captions.trim` | drag a caption edge in the timeline | `caption`, `edge` (`in`/`out`), `delta` or `deltaFrames` |
+| `captions.move` | drag a caption in the timeline | `captions`, `delta` or `deltaFrames` |
+| `captions.delete` | Edit ▸ Clear / Ripple Delete with captions selected | `captions`, `ripple` |
+| `captions.select`, `captions.goTo` | click / number button | `captions`, `add` / `caption` |
+| `captions.setTrack` | caption track header (eye, lock) | `track`, `name`, `format`, `language`, `enabled`, `locked`, `syncLock` |
+| `captions.setStyle` | Text panel style strip | `track`, `size`, `color`, `background`, `backgroundColor`, `outline`, `outlineColor`, `align`, `anchor`, `margin`, `lineSpacing`, `reset` |
+| `captions.deleteTrack` | | `track` |
+| `captions.import` / `captions.export` | File ▸ Export ▸ Captions… | `path`, `format`, `track`, `dropFrame` |
+| `captions.list` | (query) | `track` — tracks, styles and captions with timecodes |
+
+Tracks are addressed by id or `"C1"`, `"C2"`… (top first). Edits are limited by neighbouring
+captions and a one-frame minimum. Sync-locked caption tracks follow insert and extract edits on
+the media tracks (a caption across an insert point is split). `Add Edit to All Tracks` (⇧⌘K)
+also splits captions.
+
+## Timeline and Text panel
+
+- Caption rows: header with `C1…` badge, lock, output eye, name and format; caption blocks in
+ violet showing their text. Click selects (⌘/⇧ adds), drag moves, edge drag trims, double-click
+ opens the Text panel. Automation ids: `timeline.caption.<id>`,
+ `timeline.captionTrack.C1[.locked|.enabled]`.
+- **Text panel ▸ Captions**: search, track picker (also creates tracks of each format), add /
+ split / merge / delete / export buttons, the list of segments with editable in/out timecodes
+ and text (committed when the field loses focus), and the track style strip (size, colour, box,
+ alignment, position). Automation ids: `text.tab.Captions`, `text.captions.add|split|merge|delete|export|search|track`,
+ `text.captions.<id>.in|out|text|goto|row`, `text.captions.style.*`.
+
+## Burn-in
+
+The Program monitor shows the visible caption tracks. On export, `file.exportMedia`
+`{"burnCaptions": true}` (Export mode: **Burn Captions Into Video**) draws them into every frame.
+Captions are set in Inter SemiBold (OFL, bundled) with our own rasteriser; italics/bold markup is
+not yet drawn differently, and text is not shaped (no kerning or complex scripts) until the M10.1
+text engine lands. Nested sequences do not burn in their own captions.