diff --git a/MCP.md b/MCP.md index 687340e..8142287 100644 --- a/MCP.md +++ b/MCP.md @@ -335,7 +335,7 @@ prints it live, and `help {topic:""}` gives one op's entry. The recipes and | captions | edit ops, not tools: `subtitles_import {path}` (tracks, no lane yet) · `captions_place {track, lane?, at?}` · `sub_move {clip, at, to_lane?}` [group] · `sub_trim {clip, edge:in|out, to}` · `sub_delete {clip}` · `captions_remove {track, force?}` · `cue_add {track, at, to, text, overwrite?}` · `cue_text {track, index, text}` (`\n` = line break) · `cue_delete {track, index}` · `cue_time {track, index, at?, to?}` (timeline times: trim or move one cue inside its neighbours, 0.1 s minimum) · `cue_merge {track, index}` (with the next cue) · `cue_split {track, index, at}` · `cue_replace {track?, find, replace, case_sensitive?}` (every cue of one track, or all tracks; case-insensitive unless `case_sensitive`; reports occurrences and cues). Written as `edit {ops:[{op:"cue_text", …}]}`; `captions` (the tool) lists the cues as `track T cue C` | | markers | `chapter_add {at, title}` · `chapter_set {chapter, title?, at?}` · `chapter_remove {chapter}` (a chapter is `C@` or `C#n`, its place in the list, 1 first; cuts and inserts move chapters with the picture; `timeline` prints them as a YouTube description, with warnings) | | comment markers | `marker_add {at, name, note?, color?, length?}` · `marker_set {marker, name?, note?, color?, at?, length?}` · `marker_remove {marker}` · `beats {clip, every?=1}` (finds the tempo of a sound clip and marks each `every`th beat, 1, 2 or 4 for bars, as a yellow marker noted "Beat"; the reply gives the BPM, the count and the `M@` addresses; the clip's earlier beat markers are replaced in the same undo step; a clip with no sound, a silent one or one with no steady pulse is refused; `engine::beats`) (a marker is `M@`, the first on that frame, or `M#n`; color is red, orange, yellow, green, blue or purple, default blue; a `length` makes a range and `length: 0` turns it back into a point; several markers may share a frame; they move with the picture as chapters do, a range growing or shrinking with an insert or cut; `timeline` prints a `markers:` line and a `markers` list; `export_start chapters: "markers"` writes them as the file's chapters) | -| titles | `title_add {at, duration, text, preset?=lower_third\|centered\|caption_bar, size?=80, outline?, boxed?, place?=centre\|top\|bottom, hplace?=centre\|left\|right, color?=#ffffff, weight?=regular\|bold, align?=centre\|left\|right, box_color?, box_opacity?, fade_in?, fade_out?, in_anim?=none\|fade\|typewriter\|slide_up\|slide_left\|pop\|word_by_word, out_anim?=(same), anim_secs?=0.5}` · `title_set {title, …}` · `title_remove {title}`. The title and burned-caption text draws Latin, Greek, Cyrillic, Arabic, Hebrew, Devanagari and Thai from bundled Noto faces, shaped, right-to-left in order. Colour emoji and CJK come from the system's Noto Color Emoji and Noto Sans CJK when installed; otherwise emoji draw monochrome and CJK draws as empty boxes (soft subtitle tracks keep that text). Only a character no face has draws as a box. `title_remove` renumbers the titles after it (T2 becomes T1). `preset` is the app's one-click look (the same values as the Title menu's styles): the fields given with it win, and `title_set {preset}` applies it to an existing title keeping its words and timing. `hplace` is the side the block sits against (a lower third is `place:bottom, hplace:left`), `align` how its lines line up in it, `color` the letters (`#rrggbb`), `weight` Archivo Medium or Bold (Latin only), `box_color` `#rrggbb` (keeps the opacity) or `#rrggbbaa`, `box_opacity` 0..1. A title with any of these off the default saves as format v49 (`titlestyle` lines); older projects load with the defaults. `in_anim` and `out_anim` are the entrance and exit animations, each of the seven names above; an exit is the entrance played backwards, eased in on the way out and out on the way in. `anim_secs` is how long each takes (a bare number is seconds, unlike the frame fades), `title_set` takes all three too. Typewriter and word_by_word reveal the text over the animation. A title with an animation saves as format v54 (`titleanim` lines) | +| titles | `title_add {at, duration, text, preset?=lower_third\|centered\|caption_bar, size?=80, outline?, boxed?, place?=centre\|top\|bottom, hplace?=centre\|left\|right, color?=#ffffff, weight?=regular\|bold, align?=centre\|left\|right, box_color?, box_opacity?, fade_in?, fade_out?, in_anim?=none\|fade\|typewriter\|slide_up\|slide_left\|pop\|word_by_word, out_anim?=(same), anim_secs?=0.5, keys?=[{at, x?, y?, scale?, opacity?, ease?}]}` · `title_set {title, …}` · `title_remove {title}`. `keys` animates the title over its own length: `at` is a time from the title's first frame (a key past the end holds its value), `x` and `y` shift it as a share of the picture (-1..1, y down positive), `scale` multiplies its size (0.05..10) and `opacity` multiplies its alpha (0..1); missing fields are 0, 0, 1, 1, and `keys:[]` takes the animation off. A title with keys saves as format v56, and the title readback lists them. The title and burned-caption text draws Latin, Greek, Cyrillic, Arabic, Hebrew, Devanagari and Thai from bundled Noto faces, shaped, right-to-left in order. Colour emoji and CJK come from the system's Noto Color Emoji and Noto Sans CJK when installed; otherwise emoji draw monochrome and CJK draws as empty boxes (soft subtitle tracks keep that text). Only a character no face has draws as a box. `title_remove` renumbers the titles after it (T2 becomes T1). `preset` is the app's one-click look (the same values as the Title menu's styles): the fields given with it win, and `title_set {preset}` applies it to an existing title keeping its words and timing. `hplace` is the side the block sits against (a lower third is `place:bottom, hplace:left`), `align` how its lines line up in it, `color` the letters (`#rrggbb`), `weight` Archivo Medium or Bold (Latin only), `box_color` `#rrggbb` (keeps the opacity) or `#rrggbbaa`, `box_opacity` 0..1. A title with any of these off the default saves as format v49 (`titlestyle` lines); older projects load with the defaults. `in_anim` and `out_anim` are the entrance and exit animations, each of the seven names above; an exit is the entrance played backwards, eased in on the way out and out on the way in. `anim_secs` is how long each takes (a bare number is seconds, unlike the frame fades), `title_set` takes all three too. Typewriter and word_by_word reveal the text over the animation. A title with an animation saves as format v54 (`titleanim` lines) | `freeze` writes the composed frame at `at` to `/freeze/--.png` and places it as a still on `lane`. The hash is of the pixels, so an identical diff --git a/crates/app/src/player/titling.rs b/crates/app/src/player/titling.rs index 2859ceb..8886e83 100644 --- a/crates/app/src/player/titling.rs +++ b/crates/app/src/player/titling.rs @@ -154,6 +154,7 @@ impl Player { in_anim: Default::default(), out_anim: Default::default(), anim_frames: 0, + keys: Vec::new(), }; title.apply_preset(Preset::Centered, fps); // Up at once: a fade-in would have the new words nearly invisible where the playhead is. @@ -434,7 +435,7 @@ mod tests { use engine::text::{Align, HPlace, Outline, Place, Weight}; fn title() -> Title { - Title { start: 100, frames: 125, text: "Hi".into(), style: TextStyle::default(), fade_in: 0, fade_out: 0, in_anim: Default::default(), out_anim: Default::default(), anim_frames: 0 } + Title { start: 100, frames: 125, text: "Hi".into(), style: TextStyle::default(), fade_in: 0, fade_out: 0, in_anim: Default::default(), out_anim: Default::default(), anim_frames: 0, keys: Vec::new() } } #[test] @@ -490,7 +491,7 @@ mod tests { #[test] fn a_new_title_goes_after_the_one_on_the_playhead_and_fits_before_the_next() { - let t = |start, frames| Title { start, frames, text: "t".into(), style: TextStyle::default(), fade_in: 0, fade_out: 0, in_anim: Default::default(), out_anim: Default::default(), anim_frames: 0 }; + let t = |start, frames| Title { start, frames, text: "t".into(), style: TextStyle::default(), fade_in: 0, fade_out: 0, in_anim: Default::default(), out_anim: Default::default(), anim_frames: 0, keys: Vec::new() }; let titles = [t(0, 150), t(200, 150)]; // Free: where it was asked, and cut to the room before the next title. assert_eq!(free_title_slot(&[], 10, 150, 30.), (10, 150)); diff --git a/crates/app/src/tests/titles.rs b/crates/app/src/tests/titles.rs index d8adaf0..93524ee 100644 --- a/crates/app/src/tests/titles.rs +++ b/crates/app/src/tests/titles.rs @@ -21,6 +21,7 @@ fn title(start: u32, frames: u32, fade_in: u32, fade_out: u32) -> Title { in_anim: Default::default(), out_anim: Default::default(), anim_frames: 0, + keys: Vec::new(), } } diff --git a/crates/engine/src/edith.rs b/crates/engine/src/edith.rs index eb3804e..0e7716a 100644 --- a/crates/engine/src/edith.rs +++ b/crates/engine/src/edith.rs @@ -234,6 +234,12 @@ //! only a mask's position, size and soft edge, are still read. A project with none is the bytes a //! v55 one was bar the version line. //! +//! A `ttkeys` line is `ttkeys <at>:<ease>:<x>,<y>,<scale>,<opacity> ...`: a title's own +//! keyframe animation ([`crate::titleanim::TitleKey`]), the title named by its place in the list +//! and the keys in frame order, `at` counted from the title's first frame. Written after the +//! title's `titleanim` line, one per title that has keys. It is also v56, so a project with title +//! keys is written as v56 and a project with none is the bytes a v55 one was bar the version line. +//! //! A `cueadd` line is one cue added to a subtitle track, which no file has: //! `cueadd <track> <start_us> <end_us> <text>`, the track by its position in //! the `subtitle` lines, the times in microseconds on the track's own clock, and @@ -430,7 +436,7 @@ use crate::subtitle::SubtitleTrack; use crate::captionanim::{CaptionAnim, CaptionStyle, MAX_WORDS_PER_LINE}; use crate::voice::{Compressor, DeEsser, Gate, NoiseReduction, VoiceFx}; use crate::text::{Align, HPlace, Outline, Place, TextStyle, Weight}; -use crate::titleanim::TitleAnim; +use crate::titleanim::{TitleAnim, TitleKey}; use crate::color::{ColorKey, MAX_COLOR_KEYS}; use crate::transitions::TransitionKind; use crate::transform::{KeyEase, MAX_TRANSFORM_KEYS, OpacityKey, TransformKey, TransformParams}; @@ -819,7 +825,9 @@ pub fn encode_flagged( let keyed = lanes.iter().any(|(_, clips)| clips.iter().any(|c| c.effects.iter().any(|e| !e.keys.is_empty()))); // ...and one with a clip's pitch shift is v55. let pitched = lanes.iter().any(|(_, clips)| clips.iter().any(|c| c.pitch != 0)); - let curved = keyed || lanes.iter().any(|(_, clips)| clips.iter().any(has_bezier)); + // ...and one with a title's own keys is v56 (`ttkeys`). + let title_keyed = titles.iter().any(|t| !t.keys.is_empty()); + let curved = keyed || title_keyed || lanes.iter().any(|(_, clips)| clips.iter().any(has_bezier)); if curved || pitched || titled || panned || styled || marked || angled || named || deinterlaced || steadied || looked || effected || voiced || captioned || animated || reversed || transitioned || ramped || !chapters.is_empty() || !markers.is_empty() { let first_end = bytes.iter().position(|&b| b == b'\n').unwrap_or(bytes.len()); let header = if curved { @@ -1947,6 +1955,17 @@ fn title_lines(titles: &[Title]) -> Vec<u8> { } out.extend_from_slice(format!("titleanim {i} {} {} {}\n", t.in_anim.name(), t.out_anim.name(), t.anim_frames).as_bytes()); } + // A title's own keys, one line per title that has any, after its `titleanim` line. + for (i, t) in titles.iter().enumerate() { + if t.keys.is_empty() { + continue; + } + out.extend_from_slice(format!("ttkeys {i}").as_bytes()); + for k in &t.keys { + out.extend_from_slice(format!(" {}:{}:{},{},{},{}", k.at, k.ease.token(), k.x, k.y, k.scale, k.opacity).as_bytes()); + } + out.push(b'\n'); + } out } @@ -3235,6 +3254,7 @@ fn parse(data: &[u8], dir: &Path) -> crate::Result<Document> { in_anim: TitleAnim::None, out_anim: TitleAnim::None, anim_frames: 0, + keys: Vec::new(), }; check_title(&title).map_err(|e| format!("line {n}: {e}"))?; doc.titles.push(title); @@ -3484,6 +3504,37 @@ fn parse(data: &[u8], dir: &Path) -> crate::Result<Document> { title.anim_frames = anim_frames; check_title(title).map_err(|e| format!("line {n}: {e}"))?; } + // A title's own keys (v56): the title by its place in the list, then each key as + // `at:ease:x,y,scale,opacity`, in frame order. `check_title` holds the ranges and order. + b"ttkeys" if v56 => { + let f: Vec<&[u8]> = rest.split(|&b| b == b' ').filter(|f| !f.is_empty()).collect(); + if f.is_empty() { + return Err(format!("line {n}: ttkeys wants a title and its keys").into()); + } + let idx = number(f[0], n)? as usize; + let mut keys = Vec::with_capacity(f.len() - 1); + for point in &f[1..] { + let parts: Vec<&[u8]> = point.splitn(3, |&b| b == b':').collect(); + if parts.len() != 3 { + return Err(format!("line {n}: ttkeys key wants at:ease:x,y,scale,opacity").into()); + } + let at = number(parts[0], n)?; + let ease = KeyEase::from_token(parts[1]) + .ok_or_else(|| format!("line {n}: ttkeys ease is lin, in, out, ease, hold or a bezier curve"))?; + let v: Vec<&[u8]> = parts[2].split(|&b| b == b',').collect(); + if v.len() != 4 { + return Err(format!("line {n}: ttkeys key wants 4 values").into()); + } + let (x, y, scale, opacity) = (float(v[0], n)?, float(v[1], n)?, float(v[2], n)?, float(v[3], n)?); + keys.push(TitleKey { at, x, y, scale, opacity, ease }); + } + let title = doc + .titles + .get_mut(idx) + .ok_or_else(|| format!("line {n}: ttkeys names title {idx}, which the file does not have"))?; + title.keys = keys; + check_title(title).map_err(|e| format!("line {n}: {e}"))?; + } b"mark" if v48 => { let f: Vec<&[u8]> = rest.split(|&b| b == b' ').collect(); if f.len() != 5 { @@ -7800,6 +7851,7 @@ mod title_tests { in_anim: TitleAnim::None, out_anim: TitleAnim::None, anim_frames: 0, + keys: Vec::new(), }, Title { start: 60, @@ -7811,6 +7863,7 @@ mod title_tests { in_anim: Default::default(), out_anim: Default::default(), anim_frames: 0, + keys: Vec::new(), }, ] } diff --git a/crates/engine/src/export.rs b/crates/engine/src/export.rs index c48f417..bf55cda 100644 --- a/crates/engine/src/export.rs +++ b/crates/engine/src/export.rs @@ -10925,6 +10925,7 @@ mod tests { in_anim: Default::default(), out_anim: Default::default(), anim_frames: 0, + keys: Vec::new(), }; // Captions 86.0 to 88.0 s; a bottom title from frame 2163 (86.52 s at 25 fps) for 3 s. let cues = [cue(86.0, 88.0, "hello")]; diff --git a/crates/engine/src/project.rs b/crates/engine/src/project.rs index e851722..33e0ac6 100644 --- a/crates/engine/src/project.rs +++ b/crates/engine/src/project.rs @@ -98,7 +98,7 @@ use sequence::{FlatCache, Seqs}; /// drops it. const CUT_SLIVER_FRAMES: f64 = 4.0; use crate::text::{Align, HPlace, Outline, Place, SIZE_RANGE, TextStyle, Weight}; -use crate::titleanim::TitleAnim; +use crate::titleanim::{KEY_SCALE_RANGE, TitleAnim, TitleKey}; use crate::color::{ColorKey, MAX_COLOR_KEYS, evaluate_color}; use crate::transform::{ KeyEase, Keyed, MAX_TRANSFORM_KEYS, OpacityKey, TransformKey, TransformParams, ease_shape, @@ -2554,7 +2554,7 @@ pub const MAX_TITLE_END: u32 = 100_000_000; /// lane: they are drawn over the composed picture (black where no clip plays), /// in list order, so a later title sits on top of an earlier one. Saved as /// `title` lines ([`crate::edith`]). -#[derive(Clone, Debug, PartialEq, Eq)] +#[derive(Clone, Debug, PartialEq)] pub struct Title { /// The first timeline frame the title shows on. pub start: u32, @@ -2577,6 +2577,9 @@ pub struct Title { pub out_anim: TitleAnim, /// How many frames each animation takes; `>= 1` when either is set and at most `frames`. pub anim_frames: u32, + /// The title's own keyframe animation, counted from its first frame: sorted by `at`, no two + /// at one frame, at most [`MAX_TRANSFORM_KEYS`]. Empty for a title without one. + pub keys: Vec<TitleKey>, } impl Title { @@ -2683,6 +2686,22 @@ pub fn check_title(title: &Title) -> crate::Result<()> { ) .into()); } + if title.keys.len() > MAX_TRANSFORM_KEYS { + return Err(format!("a title holds at most {MAX_TRANSFORM_KEYS} keys").into()); + } + for (i, k) in title.keys.iter().enumerate() { + // A NaN fails every range check, so it is refused along with the out-of-range values. + let in_range = (-1.0..=1.0).contains(&k.x) + && (-1.0..=1.0).contains(&k.y) + && (KEY_SCALE_RANGE.0..=KEY_SCALE_RANGE.1).contains(&k.scale) + && (0.0..=1.0).contains(&k.opacity); + if !in_range { + return Err("a title key's x and y are -1..=1, its scale 0.05..=10 and its opacity 0..=1".into()); + } + if i > 0 && title.keys[i - 1].at >= k.at { + return Err("a title's keys are in frame order, with no two at one frame".into()); + } + } Ok(()) } @@ -19771,6 +19790,7 @@ mod title_tests { in_anim: Default::default(), out_anim: Default::default(), anim_frames: 0, + keys: Vec::new(), } } diff --git a/crates/engine/src/titleanim.rs b/crates/engine/src/titleanim.rs index 7f5c04d..28b2c35 100644 --- a/crates/engine/src/titleanim.rs +++ b/crates/engine/src/titleanim.rs @@ -5,6 +5,52 @@ //! resting state down to nothing, with the easing reversed (ease-out in, ease-in out). use crate::project::Title; +use crate::transform::{KeyEase, Keyed, sample}; + +/// The shortest and longest scale a title key may set, as a multiple of the title's size. +pub const KEY_SCALE_RANGE: (f32, f32) = (0.05, 10.0); + +/// One point of a title's own keyframe animation: how far the title is moved, how much it is +/// scaled and how much it is faded at `at` frames from its first frame. Its values add onto +/// (shift) or multiply (scale, opacity) what the title's entrance and exit already do, and +/// between two keys they blend the way a clip's keys do. +#[derive(Clone, Copy, Debug, PartialEq)] +pub struct TitleKey { + /// Frames from the title's first frame. A key past the title's length holds its value. + pub at: u32, + /// Added to the horizontal shift, as a share of the picture's width, `-1..=1`. + pub x: f32, + /// Added to the vertical shift, as a share of the picture's height, `-1..=1`; down is positive. + pub y: f32, + /// Multiplies the size, within [`KEY_SCALE_RANGE`]. `1` leaves it alone. + pub scale: f32, + /// Multiplies the opacity, `0..=1`. `1` leaves it alone. + pub opacity: f32, + /// The easing of the segment that leaves this key. + pub ease: KeyEase, +} + +impl Keyed for TitleKey { + fn at(&self) -> u32 { + self.at + } + fn ease(&self) -> KeyEase { + self.ease + } + fn placed(self, at: u32, ease: KeyEase) -> Self { + Self { at, ease, ..self } + } + fn mix(a: &Self, b: &Self, t: f32) -> Self { + let l = |x: f32, y: f32| x + (y - x) * t; + Self { + x: l(a.x, b.x), + y: l(a.y, b.y), + scale: l(a.scale, b.scale), + opacity: l(a.opacity, b.opacity), + ..*a + } + } +} /// One of the animations a title plays on the way in or out. #[derive(Clone, Copy, Debug, Default, PartialEq, Eq)] @@ -255,13 +301,21 @@ impl Title { (Some(x), Some(y)) => Some(if x.1 <= y.1 { x } else { y }), (x, y) => x.or(y), }; - Some(Motion { + let mut motion = Motion { alpha: (alpha * a.alpha * b.alpha * 255.0) as u8, dx: a.dx + b.dx, dy: a.dy + b.dy, scale: a.scale * b.scale, reveal, - }) + }; + // The title's own keys come last: they shift, scale and fade whatever the entrance left. + if let Some(key) = sample(&self.keys, f64::from(k)) { + motion.dx += key.x; + motion.dy += key.y; + motion.scale *= key.scale; + motion.alpha = (f32::from(motion.alpha) * key.opacity).round() as u8; + } + Some(motion) } } @@ -282,9 +336,21 @@ mod tests { in_anim: anim, out_anim: TitleAnim::None, anim_frames: 12, + keys: Vec::new(), } } + #[test] + fn two_keys_fade_and_shift_a_title_halfway_between_them() { + // Opacity goes 0 to 1 and x 0 to 0.2 over the first ten frames: at frame 5 that is half + // the alpha and a shift of 0.1 of the width. + let key = |at, x, opacity| crate::titleanim::TitleKey { at, x, y: 0.0, scale: 1.0, opacity, ease: crate::transform::KeyEase::Linear }; + let t = Title { keys: vec![key(0, 0.0, 0.0), key(10, 0.2, 1.0)], ..title(TitleAnim::None, 60) }; + let m = t.motion_at(5).expect("up"); + assert!(m.alpha.abs_diff(128) <= 1, "alpha {}", m.alpha); + assert!((m.dx - 0.1).abs() < 1e-6, "dx {}", m.dx); + } + #[test] fn a_typewriter_title_shows_more_letters_from_its_start_to_its_middle_to_its_end() { // A 26-frame typewriter in a 60-frame title: the letters come up over its first 26 frames. diff --git a/crates/engine/tests/burn_subs.rs b/crates/engine/tests/burn_subs.rs index f5a28ce..09ec882 100644 --- a/crates/engine/tests/burn_subs.rs +++ b/crates/engine/tests/burn_subs.rs @@ -221,6 +221,7 @@ fn a_title_past_the_clip_is_exported_over_black() { in_anim: Default::default(), out_anim: Default::default(), anim_frames: 0, + keys: Vec::new(), }) .expect("the title is added"); let out = Scratch::file("ve_title_gap", "mp4"); diff --git a/crates/engine/tests/it/compose_at.rs b/crates/engine/tests/it/compose_at.rs index f34c1e9..4c04760 100644 --- a/crates/engine/tests/it/compose_at.rs +++ b/crates/engine/tests/it/compose_at.rs @@ -146,6 +146,7 @@ fn title(start: u32, frames: u32, place: Place) -> Title { in_anim: Default::default(), out_anim: Default::default(), anim_frames: 0, + keys: Vec::new(), } } diff --git a/crates/engine/tests/it/export_deep_ten_bit.rs b/crates/engine/tests/it/export_deep_ten_bit.rs index a046bde..711c16c 100644 --- a/crates/engine/tests/it/export_deep_ten_bit.rs +++ b/crates/engine/tests/it/export_deep_ten_bit.rs @@ -303,7 +303,7 @@ fn title() { check( "title", |s, _| { - s.add_title(Title { start: 0, frames: 25, text: "T".into(), style: TextStyle::default(), fade_in: 0, fade_out: 0, in_anim: Default::default(), out_anim: Default::default(), anim_frames: 0 }) + s.add_title(Title { start: 0, frames: 25, text: "T".into(), style: TextStyle::default(), fade_in: 0, fade_out: 0, in_anim: Default::default(), out_anim: Default::default(), anim_frames: 0, keys: Vec::new() }) .expect("title"); }, None, diff --git a/crates/engine/tests/it/fps_round_trip.rs b/crates/engine/tests/it/fps_round_trip.rs index 20aaa5f..271457b 100644 --- a/crates/engine/tests/it/fps_round_trip.rs +++ b/crates/engine/tests/it/fps_round_trip.rs @@ -87,6 +87,7 @@ fn edit() -> PlaybackSession { in_anim: Default::default(), out_anim: Default::default(), anim_frames: 0, + keys: Vec::new(), }) .expect("title"); s @@ -188,6 +189,7 @@ fn on_grid_edit() -> PlaybackSession { in_anim: Default::default(), out_anim: Default::default(), anim_frames: 0, + keys: Vec::new(), }) .expect("title"); s diff --git a/crates/engine/tests/it/project_fuzz.rs b/crates/engine/tests/it/project_fuzz.rs index 85d40e3..f1a6144 100644 --- a/crates/engine/tests/it/project_fuzz.rs +++ b/crates/engine/tests/it/project_fuzz.rs @@ -391,6 +391,7 @@ fn random_project(rng: &mut Rng, dir: &Path) -> Project { in_anim: Default::default(), out_anim: Default::default(), anim_frames: 0, + keys: Vec::new(), }); } for _ in 0..rng.range(0, 3) { @@ -1052,6 +1053,7 @@ fn wild_values_the_setters_accept_still_save_and_load() { in_anim: Default::default(), out_anim: Default::default(), anim_frames: 0, + keys: Vec::new(), }); let _ = project.add_chapter(Chapter { frame: rng.range(0, 1000), diff --git a/crates/engine/tests/it/saveload.rs b/crates/engine/tests/it/saveload.rs index b28674d..62f1ff3 100644 --- a/crates/engine/tests/it/saveload.rs +++ b/crates/engine/tests/it/saveload.rs @@ -1790,6 +1790,7 @@ fn titles_survive_a_save_and_an_open() { in_anim: Default::default(), out_anim: Default::default(), anim_frames: 0, + keys: Vec::new(), }; let lower = Title { start: 60, @@ -1801,6 +1802,7 @@ fn titles_survive_a_save_and_an_open() { in_anim: Default::default(), out_anim: Default::default(), anim_frames: 0, + keys: Vec::new(), }; saved.add_title(card.clone()).expect("the card is added"); saved @@ -1837,7 +1839,7 @@ fn a_title_look_survives_a_save_and_an_open_as_v49() { let dir = scratch("title_look"); let source = copy_in(&dir, "test_av.mp4"); let mut plain = PlaybackSession::open(&source).expect("open the fixture"); - let mk = |style: TextStyle| Title { start: 30, frames: 60, text: "Jane\nDirector".into(), style, fade_in: 0, fade_out: 0, in_anim: Default::default(), out_anim: Default::default(), anim_frames: 0 }; + let mk = |style: TextStyle| Title { start: 30, frames: 60, text: "Jane\nDirector".into(), style, fade_in: 0, fade_out: 0, in_anim: Default::default(), out_anim: Default::default(), anim_frames: 0, keys: Vec::new() }; plain.add_title(mk(TextStyle::default())).expect("added"); let p0 = dir.join("plain.edith"); plain.save_project(&p0).expect("save"); diff --git a/crates/engine/tests/it/undo_stress.rs b/crates/engine/tests/it/undo_stress.rs index 796f087..0e88bc4 100644 --- a/crates/engine/tests/it/undo_stress.rs +++ b/crates/engine/tests/it/undo_stress.rs @@ -186,6 +186,7 @@ fn random_title(rng: &mut Rng) -> Title { in_anim: Default::default(), out_anim: Default::default(), anim_frames: 0, + keys: Vec::new(), } } diff --git a/crates/mcp/src/help.rs b/crates/mcp/src/help.rs index 3c0c6d0..7580744 100644 --- a/crates/mcp/src/help.rs +++ b/crates/mcp/src/help.rs @@ -177,7 +177,7 @@ RECIPES Intro title and a lower third: a centred card over black, then a boxed caption over the picture. edit {ops:[{op:\"title_add\", at:\"0\", duration:3, text:\"Episode 17\", place:\"centre\", fade_in:12, fade_out:12}, {op:\"title_add\", at:\"5.0s\", duration:4, text:\"Jane Doe, director\", place:\"bottom\", boxed:true, fade_in:12, fade_out:12}]} A title past the last clip extends the timeline; edit {ops:[{op:\"title_set\", title:\"T2\", size:60}]} changes one, edit {ops:[{op:\"title_remove\", title:\"T1\"}]} takes it off (the titles after it renumber: T2 becomes T1), and timeline lists them as T lines. - A title can start in one of the app's looks with preset (lower_third, centered or caption_bar): edit {ops:[{op:\"title_add\", at:\"5.0s\", duration:4, text:\"Jane Doe\", preset:\"lower_third\"}]}; fields given with it win. A title can carry a look: color (\"#ffcc00\"), weight (regular|bold; Latin letters, other scripts keep their one weight), hplace (centre|left|right: the side the block sits against, the margin from the edge), align (centre|left|right: how its lines line up inside the block), box_color (\"#000000\" keeps the opacity, \"#000000c8\" sets it) and box_opacity (0..1). A lower third: edit {ops:[{op:\"title_add\", at:\"5.0s\", duration:4, text:\"Jane Doe\\nDirector\", place:\"bottom\", hplace:\"left\", align:\"left\", weight:\"bold\", boxed:true, box_color:\"#112233\", box_opacity:0.8}]}. A project that uses one saves as format v49 (an older edith refuses it by name). A title can animate in and out: in_anim and out_anim are none, fade, typewriter (letters appear one by one), slide_up, slide_left, pop (grows from 60% with a slight overshoot) or word_by_word; anim_secs is how long each takes (a bare number is seconds, default 0.5). An exit is the entrance played backwards. Example: edit {ops:[{op:\"title_add\", at:\"0\", duration:4, text:\"Episode 17\", in_anim:\"typewriter\", out_anim:\"fade\", anim_secs:0.6}]}. An animated title saves as format v54 (a titleanim line; an older edith refuses it by name). + A title can start in one of the app's looks with preset (lower_third, centered or caption_bar): edit {ops:[{op:\"title_add\", at:\"5.0s\", duration:4, text:\"Jane Doe\", preset:\"lower_third\"}]}; fields given with it win. A title can carry a look: color (\"#ffcc00\"), weight (regular|bold; Latin letters, other scripts keep their one weight), hplace (centre|left|right: the side the block sits against, the margin from the edge), align (centre|left|right: how its lines line up inside the block), box_color (\"#000000\" keeps the opacity, \"#000000c8\" sets it) and box_opacity (0..1). A lower third: edit {ops:[{op:\"title_add\", at:\"5.0s\", duration:4, text:\"Jane Doe\\nDirector\", place:\"bottom\", hplace:\"left\", align:\"left\", weight:\"bold\", boxed:true, box_color:\"#112233\", box_opacity:0.8}]}. A project that uses one saves as format v49 (an older edith refuses it by name). A title can animate in and out: in_anim and out_anim are none, fade, typewriter (letters appear one by one), slide_up, slide_left, pop (grows from 60% with a slight overshoot) or word_by_word; anim_secs is how long each takes (a bare number is seconds, default 0.5). An exit is the entrance played backwards. Example: edit {ops:[{op:\"title_add\", at:\"0\", duration:4, text:\"Episode 17\", in_anim:\"typewriter\", out_anim:\"fade\", anim_secs:0.6}]}. An animated title saves as format v54 (a titleanim line; an older edith refuses it by name). A title can also carry its own keys, which move, scale and fade it over its length: title_add keys:[{at:\"0s\", opacity:0}, {at:\"1s\", opacity:1, x:0.1, scale:1.2}] (at counts from the title's first frame; x and y are a share of the picture, scale multiplies its size, opacity its alpha; missing fields are 0, 0, 1, 1; keys:[] takes them off). Keys save as format v56 (a ttkeys line). Black lead-in for an intro title: edit {ops:[{op:\"insert_time\", at:\"0\", duration:\"3s\"}]} opens black before the picture, then title_add at 0 sits over that black. edit {ops:[{op:\"insert_time\", at:\"0\", duration:\"3s\"}, {op:\"title_add\", at:\"0\", duration:3, text:\"Episode 17\", place:\"centre\", fade_in:12, fade_out:12}]} Speed a clip that has narration over it (the examples need a picture clip at V1@0, and the narration lane A3 from first_video): narration on its own lane (A3, as in first_video) is outside the ripple by default, so edit {ops:[{op:\"speed\", clip:\"V1@0\", x:0.5, ripple:true}]} changes the picture's length and the narration keeps its times. diff --git a/crates/mcp/src/tools/edit.rs b/crates/mcp/src/tools/edit.rs index cf515a9..72addbf 100644 --- a/crates/mcp/src/tools/edit.rs +++ b/crates/mcp/src/tools/edit.rs @@ -151,8 +151,9 @@ cue_time {track, index, at?, to?} — trim or move one cue: its new start (at) a cue_merge {track, index} — join a cue with the next one. cue_split {track, index, at} — divide a cue in two at a timeline time. cue_replace {track?, find, replace, case_sensitive?} — replace a word or phrase in every cue of a track (all tracks when track is omitted); case-insensitive unless case_sensitive. Reports occurrences and cues; one undo step. TITLES -title_add {at, duration, text, preset?=lower_third|centered|caption_bar, size?=80, outline?=thin|none|thick, boxed?=false, place?=centre|top|bottom, hplace?=centre|left|right, color?=#ffffff, weight?=regular|bold, align?=centre|left|right, box_color?=#000000 (or #rrggbbaa), box_opacity?=0.6 (0..1), fade_in?, fade_out?} — a card over the picture (black where no clip plays). place is the vertical position, hplace the side the block sits against (a lower third is place:bottom, hplace:left), align how its lines line up inside it. preset gives the app's one-click look (lower_third: bold, bottom left, boxed; centered: large, outlined, middle; caption_bar: boxed, bottom, no fades); the fields given with it win over its look, and title_set applies a preset to a title and keeps its words and timing. A look off the default saves as format v49. at and duration are times (a bare number is seconds). Fades: int = frames, "0.5s" = time. Past the last clip it extends the timeline. Named T1.. in start order. +title_add {at, duration, text, preset?=lower_third|centered|caption_bar, size?=80, outline?=thin|none|thick, boxed?=false, place?=centre|top|bottom, hplace?=centre|left|right, color?=#ffffff, weight?=regular|bold, align?=centre|left|right, box_color?=#000000 (or #rrggbbaa), box_opacity?=0.6 (0..1), fade_in?, fade_out?, in_anim?, out_anim?, anim_secs?, keys?=[{at, x?, y?, scale?, opacity?, ease?}]} — a card over the picture (black where no clip plays). place is the vertical position, hplace the side the block sits against (a lower third is place:bottom, hplace:left), align how its lines line up inside it. preset gives the app's one-click look (lower_third: bold, bottom left, boxed; centered: large, outlined, middle; caption_bar: boxed, bottom, no fades); the fields given with it win over its look, and title_set applies a preset to a title and keeps its words and timing. A look off the default saves as format v49. at and duration are times (a bare number is seconds). Fades: int = frames, "0.5s" = time. Past the last clip it extends the timeline. Named T1.. in start order. title_set {title:"T1" or "T@45", ...any of the same fields} — merged onto the title. A title is named T1.. in start order, or by its start frame as T@45 (the form a reply prints after each title op, which stays right when titles renumber). title_remove {title} — takes it off. +Title keys animate the title over its own length: keys:[{at:"0s", opacity:0}, {at:"1s", opacity:1, x:0.1, scale:1.2, y:-0.05, ease:"ease_out"}]. at is a time from the title's first frame (a bare number is seconds, "50%" or "end" also work); a key past the title's end holds its value. x and y shift the title as a share of the picture (-1..1, y down is positive), scale multiplies its size (0.05..10), opacity multiplies its alpha (0..1). A missing field is x 0, y 0, scale 1, opacity 1, and ease is the segment's easing as for transform_keys. keys:[] takes the animation off. Titles with keys save as format v56. GENERATED generator_add {kind: solid|gradient|countdown|bars|tone|rectangle|ellipse|line|arrow, color?, color2?, angle?, from?, fill?, stroke?, width?, radius?, lane?=V1, at?, duration?=5s} — a clip made from numbers, not a file, on a video lane that exists (else lane_add first). color is hex such as ff3366 or #ff3366 (solid; gradient start), color2 the gradient end, angle 0..359 degrees (0 left to right, 90 top to bottom), from the countdown's seconds (1..3600; its duration defaults to the count). Shapes (rectangle, ellipse, line, arrow) draw on a transparent canvas and land at 40% scale over the lanes below: fill and stroke are hex or none, width the stroke in pixels (0..400), radius rounds a rectangle; size and place come from the transform op. at defaults to the end of the lane. It trims, moves, grades and takes effects like any clip; it overwrites what it lands on, as a still does. generator_set {clip, color?, color2?, angle?, from?, fill?, stroke?, width?, radius?} — change a generator clip's params, keeping its place and length; a clip that plays a file is refused. @@ -335,8 +336,8 @@ fn accepted_keys(name: &str) -> Option<&'static [&'static str]> { "group" => &["clips"], "ungroup" => &["clip"], "subtitles_import" => &["path", "lang"], - "title_add" => &["at", "duration", "text", "preset", "size", "outline", "boxed", "place", "hplace", "color", "colour", "weight", "align", "box_color", "box_colour", "box_opacity", "fade_in", "fade_out", "in_anim", "out_anim", "anim_secs"], - "title_set" => &["title", "at", "duration", "text", "preset", "size", "outline", "boxed", "place", "hplace", "color", "colour", "weight", "align", "box_color", "box_colour", "box_opacity", "fade_in", "fade_out", "in_anim", "out_anim", "anim_secs"], + "title_add" => &["at", "duration", "text", "preset", "size", "outline", "boxed", "place", "hplace", "color", "colour", "weight", "align", "box_color", "box_colour", "box_opacity", "fade_in", "fade_out", "in_anim", "out_anim", "anim_secs", "keys"], + "title_set" => &["title", "at", "duration", "text", "preset", "size", "outline", "boxed", "place", "hplace", "color", "colour", "weight", "align", "box_color", "box_colour", "box_opacity", "fade_in", "fade_out", "in_anim", "out_anim", "anim_secs", "keys"], "title_remove" => &["title"], "chapter_add" => &["at", "title"], "chapter_set" => &["chapter", "title", "at"], diff --git a/crates/mcp/src/tools/edit_fx.rs b/crates/mcp/src/tools/edit_fx.rs index 9ff6eca..48156c1 100644 --- a/crates/mcp/src/tools/edit_fx.rs +++ b/crates/mcp/src/tools/edit_fx.rs @@ -24,7 +24,7 @@ use engine::scale::FitPolicy; use engine::text::{layout_share, missing_glyphs, Align, HPlace, Outline, Place, TextStyle, Weight, SIZE_RANGE}; use engine::color::{ColorKey, MAX_COLOR_KEYS}; use engine::transform::{Bezier, Corner, KeyEase, OpacityKey, TransformKey, TransformParams, MAX_TRANSFORM_KEYS}; -use engine::titleanim::TitleAnim; +use engine::titleanim::{KEY_SCALE_RANGE, TitleAnim, TitleKey}; use engine::PlaybackSession; use serde_json::{json, Value}; @@ -2360,7 +2360,7 @@ pub(super) fn title_line(name: &str, t: &Title, fps: f64) -> String { } let boxed = if t.style.boxed { " boxed" } else { "" }; format!( - "title {name} \"{}\" {:.3}–{:.3} {} size {} outline {}{boxed}{look} fade {}f/{}f{anim}", + "title {name} \"{}\" {:.3}–{:.3} {} size {} outline {}{boxed}{look} fade {}f/{}f{anim}{keys}", t.text.replace('\n', "\\n"), parse::secs(t.start, fps), parse::secs(t.end(), fps), @@ -2373,7 +2373,8 @@ pub(super) fn title_line(name: &str, t: &Title, fps: f64) -> String { String::new() } else { format!(" anim in {} out {} {}f", t.in_anim.name(), t.out_anim.name(), t.anim_frames) - } + }, + keys = title_keys_text(t, fps) ) } @@ -2505,9 +2506,132 @@ fn title_preset_arg(op: &Value) -> Result<Option<TitlePreset>, String> { } } -/// `title_add {at, duration, text, preset?, size?=80, outline?="thin", boxed?=false, place?="centre", fade_in?=0, fade_out?=0, in_anim?, out_anim?, anim_secs?=0.5}`. +/// The `at` of a title key: a time from the title's first frame, read as `title_add` reads its +/// times (a bare number is seconds), `end` for the title's last frame, or a percentage of its length. +fn title_key_offset(n: usize, at: &Value, frames: u32, fps: f64) -> Result<u32, String> { + if let Some(text) = at.as_str() { + let text = text.trim(); + if text.eq_ignore_ascii_case("end") { + return Ok(frames); + } + if let Some(pct) = text.strip_suffix('%') { + let share: f64 = pct + .trim() + .parse() + .map_err(|_| format!("title keys: key {n} at {text:?} is not a percentage"))?; + if !(0.0..=100.0).contains(&share) { + return Err(format!("title keys: key {n} at {text} is outside the title, 0% to 100%")); + } + return Ok((f64::from(frames) * share / 100.0).round() as u32); + } + } + parse::frame(at, fps, u32::MAX).map_err(|e| format!("title keys: key {n}: {e}")) +} + +/// The `keys` of a `title_add` or `title_set`: a list of `{at, x?, y?, scale?, opacity?, ease?}`, +/// each `at` a time from the title's first frame. A key leaves x and y at 0 and scale and opacity +/// at 1 when it does not name them. `[]` takes the animation off, and `None` means the op gives no +/// `keys`. A key past the title's `frames` holds its value there. +fn title_keys_arg(op: &Value, fps: f64, frames: u32) -> Result<Option<Vec<TitleKey>>, String> { + let list = match op.get("keys") { + None | Some(Value::Null) => return Ok(None), + Some(Value::Array(a)) => a, + Some(v) => { + return Err(format!( + "title keys must be a list of {{at, x?, y?, scale?, opacity?, ease?}} objects, got {}", + kind_of(v) + )) + } + }; + if list.len() > MAX_TRANSFORM_KEYS { + return Err(format!("title keys: {} keys, and at most {MAX_TRANSFORM_KEYS} fit", list.len())); + } + let who = "title keys"; + let mut keys: Vec<TitleKey> = Vec::with_capacity(list.len()); + for (i, k) in list.iter().enumerate() { + let n = i + 1; + let obj = k.as_object().ok_or_else(|| { + format!("{who}: key {n} must be an object such as {{\"at\": \"0s\", \"opacity\": 0}}") + })?; + if let Some(bad) = obj + .keys() + .find(|name| !matches!(name.as_str(), "at" | "x" | "y" | "scale" | "opacity" | "ease")) + { + return Err(format!( + "{who}: key {n} has `{bad}`, which a title key does not take: x, y, scale, opacity, ease, at" + )); + } + let at = obj + .get("at") + .ok_or_else(|| format!("{who}: key {n} has no `at`, the time from the title's first frame"))?; + keys.push(TitleKey { + at: title_key_offset(n, at, frames, fps)?, + x: or_default(who, k, "x", 0.0, -1.0, 1.0)?, + y: or_default(who, k, "y", 0.0, -1.0, 1.0)?, + scale: or_default(who, k, "scale", 1.0, KEY_SCALE_RANGE.0, KEY_SCALE_RANGE.1)?, + opacity: or_default(who, k, "opacity", 1.0, 0.0, 1.0)?, + ease: ease_of(who, n, k)?, + }); + } + keys.sort_by_key(|k| k.at); + if keys.windows(2).any(|w| w[0].at == w[1].at) { + return Err(format!("{who}: two keys at the same time; space them further apart")); + } + Ok(Some(keys)) +} + +/// A title's keys as the JSON a listing carries: each `at` in seconds from the title's start. +pub(super) fn title_keys_json(t: &Title, fps: f64) -> Value { + Value::Array( + t.keys + .iter() + .map(|k| { + json!({ + "at": parse::secs(k.at, fps), + "x": k.x, + "y": k.y, + "scale": k.scale, + "opacity": k.opacity, + "ease": k.ease.name(), + }) + }) + .collect(), + ) +} + +/// A title's keys as a reply fragment, ` keys 2: +0.000s x 0.00 y 0.00 scale 1.00 opacity 0.00 · …`, +/// at most twelve, then `(+N more)`. Empty for a title with none. +pub(super) fn title_keys_text(t: &Title, fps: f64) -> String { + const SHOWN: usize = 12; + if t.keys.is_empty() { + return String::new(); + } + let mut parts: Vec<String> = t + .keys + .iter() + .take(SHOWN) + .map(|k| { + format!( + "+{} x {:.2} y {:.2} scale {:.2} opacity {:.2}{}", + tsec(f64::from(k.at), fps), + k.x, + k.y, + k.scale, + k.opacity, + ease_suffix(k.ease) + ) + }) + .collect(); + if t.keys.len() > SHOWN { + parts.push(format!("(+{} more)", t.keys.len() - SHOWN)); + } + format!(" keys {}: {}", t.keys.len(), parts.join(" · ")) +} + +/// `title_add {at, duration, text, preset?, size?=80, outline?="thin", boxed?=false, place?="centre", fade_in?=0, fade_out?=0, in_anim?, out_anim?, anim_secs?=0.5, keys?}`. /// `at` and `duration` are times (a bare number is seconds). Fades are frames as -/// an integer, or a time string. The title lands in start order; the reply gives +/// an integer, or a time string. `keys` animates the title itself ([`title_keys_arg`]). +/// The title lands in start order; the reply gives /// the `T<n>` it now holds, and says when titles after it renumber. fn title_add(s: &mut PlaybackSession, op: &Value, fps: f64) -> Result<Applied, String> { let end = parse::session_end(s); @@ -2516,7 +2640,7 @@ fn title_add(s: &mut PlaybackSession, op: &Value, fps: f64) -> Result<Applied, S let text = req_str(op, "text")?.to_string(); let base = TextStyle { size: 80, outline: Outline::Thin, boxed: false, place: Place::Centre, ..TextStyle::default() }; // A preset is the look the title starts in; the fields given after it win over the preset. - let mut t = Title { start, frames, text, style: base, fade_in: 0, fade_out: 0, in_anim: Default::default(), out_anim: Default::default(), anim_frames: 0 }; + let mut t = Title { start, frames, text, style: base, fade_in: 0, fade_out: 0, in_anim: Default::default(), out_anim: Default::default(), anim_frames: 0, keys: Vec::new() }; if let Some(p) = title_preset_arg(op)? { t.apply_preset(p, fps); } @@ -2524,6 +2648,9 @@ fn title_add(s: &mut PlaybackSession, op: &Value, fps: f64) -> Result<Applied, S t.fade_in = length(op, "fade_in", fps)?.unwrap_or(t.fade_in); t.fade_out = length(op, "fade_out", fps)?.unwrap_or(t.fade_out); title_anim_fields(op, &mut t, fps)?; + if let Some(keys) = title_keys_arg(op, fps, t.frames)? { + t.keys = keys; + } check_title(&t).map_err(|e| format!("title_add: {e}"))?; let warnings = title_warnings(s, &t); // The new title is not in the list yet, so every title there is one it may overlap. @@ -2585,6 +2712,9 @@ fn title_set(s: &mut PlaybackSession, op: &Value, fps: f64) -> Result<Applied, S t.fade_out = f; } title_anim_fields(op, &mut t, fps)?; + if let Some(keys) = title_keys_arg(op, fps, t.frames)? { + t.keys = keys; + } let name = title_name(idx); if t == old { return Ok(Applied { text: format!("{name} unchanged"), touched: Vec::new() }); diff --git a/crates/mcp/src/tools/look.rs b/crates/mcp/src/tools/look.rs index 405dfd3..7dd6c84 100644 --- a/crates/mcp/src/tools/look.rs +++ b/crates/mcp/src/tools/look.rs @@ -462,6 +462,7 @@ fn title_rows(s: &PlaybackSession, fps: f64, range: Option<(u32, u32)>, full: bo "fade_out": t.fade_out, "in_anim": t.in_anim.name(), "out_anim": t.out_anim.name(), + "keys": super::edit_fx::title_keys_json(t, fps), }) }) .collect(); @@ -469,12 +470,13 @@ fn title_rows(s: &PlaybackSession, fps: f64, range: Option<(u32, u32)>, full: bo let mut used = 0; for (k, (i, t)) in shown.iter().enumerate() { let line = format!( - "T {} {:.3}–{:.3} \"{}\" {}", + "T {} {:.3}–{:.3} \"{}\" {}{}", title_name(*i), parse::secs(t.start, fps), parse::secs(t.end(), fps), short_text(&t.text), - place_word(t.style.place) + place_word(t.style.place), + super::edit_fx::title_keys_text(t, fps) ); if !full && k > 0 && used + line.len() + 1 > room { lines.push(format!("T … {} more titles (use range)", shown.len() - k)); @@ -2525,9 +2527,9 @@ mod tests { let style = TextStyle { size: 80, outline: Outline::Thin, boxed: false, place: Place::Centre, ..TextStyle::default() }; let sess = srv.session.as_mut().unwrap(); let long = "x".repeat(60); - sess.add_title(Title { start: 0, frames: 90, text: "Episode 17".into(), style: style.clone(), fade_in: 0, fade_out: 0, in_anim: Default::default(), out_anim: Default::default(), anim_frames: 0 }) + sess.add_title(Title { start: 0, frames: 90, text: "Episode 17".into(), style: style.clone(), fade_in: 0, fade_out: 0, in_anim: Default::default(), out_anim: Default::default(), anim_frames: 0, keys: Vec::new() }) .unwrap(); - sess.add_title(Title { start: 150, frames: 30, text: long.clone(), style, fade_in: 0, fade_out: 0, in_anim: Default::default(), out_anim: Default::default(), anim_frames: 0 }).unwrap(); + sess.add_title(Title { start: 150, frames: 30, text: long.clone(), style, fade_in: 0, fade_out: 0, in_anim: Default::default(), out_anim: Default::default(), anim_frames: 0, keys: Vec::new() }).unwrap(); let r = call(&mut srv, "timeline", json!({})); let t1 = format!("T T1 0.000–{:.3} \"Episode 17\" centre", 90.0 / fps);