programmatic video rendering framework that is actually fast
chore(cargo-fframes): stop generating frame snapshot tests (#184)
Dmitriy Kovalenko9982a328207d
diff --git a/AGENTS.md b/AGENTS.mdindex 9d00d33b..1bc5fee1 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -274,7 +274,6 @@ my-video/media/ # embedded by include_media_dir! (a DM Sans font to start with)src/lib.rs # the Video from the templatesrc/main.rs # fframes::cli (render, frame, strip, onion, svg, timeline, inspect, snapshot, audio)- tests/frames.rs # frame snapshots + "no warnings in any frame"```For the web editor copy `examples/hello-world/editor` next to it and adapt step 9; gate the@@ -681,7 +680,6 @@ $R strip -n 12 # overall flow; `strip Intro -n 8` for one s$R frame Intro@end,Outro@50% # full size details, check text stays inside its boxes$R audio analyze --waveform w.png # levels, silence, cue positions$R render # final file-cargo test -p my-video # frame snapshotsjust clippy && cargo fmt --all && just check-wasm my-video # if it has an editor bridge```diff --git a/cargo-fframes/src/main.rs b/cargo-fframes/src/main.rsindex 6b97a606..1c5dd693 100644--- a/cargo-fframes/src/main.rs+++ b/cargo-fframes/src/main.rs@@ -1,5 +1,5 @@-//! `cargo fframes new <name>`: creates a video project that renders, previews and tests-//! out of the box.+//! `cargo fframes new <name>`: creates a video project that renders and previews out of+//! the box.//!//! Interactive in a terminal (asks for everything that was not passed as a flag); with//! `--yes` or without a terminal it never asks and uses defaults, so scripts and AI agents@@ -15,7 +15,6 @@ const LIB_SINGLE_SCENE: &str = include_str!("../templates/lib_single_scene.rs.tmconst LIB_MULTI_SCENE: &str = include_str!("../templates/lib_multi_scene.rs.tmpl");const MAIN_CPU: &str = include_str!("../templates/main_cpu.rs.tmpl");const MAIN_SKIA: &str = include_str!("../templates/main_skia.rs.tmpl");-const FRAMES_TEST: &str = include_str!("../templates/frames_test.rs.tmpl");const CARGO_TOML: &str = include_str!("../templates/Cargo.toml.tmpl");const README: &str = include_str!("../templates/README.md.tmpl");const GITIGNORE: &str = include_str!("../templates/gitignore.tmpl");@@ -71,14 +70,6 @@ impl Template {}}- /// Settled frames for the snapshot test.- fn snapshot_specs(self) -> &'static str {- match self {- Template::SingleScene => r#""2s", "4s""#,- Template::MultiScene => r#""ProductScene@3s", "DataScene@3s""#,- }- }-/// A range worth a contact sheet or a draft render in the README.fn strip_range(self) -> &'static str {match self {@@ -515,10 +506,6 @@ fn new(args: NewArgs) -> Result<(), String> {("skia_hint", skia_hint.to_owned()),("backend_label", backend_label.to_owned()),("run", run.clone()),- (- "snapshot_specs",- project.template.snapshot_specs().to_owned(),- ),("strip_range", project.template.strip_range().to_owned()),("entrance_range",@@ -542,11 +529,10 @@ fn new(args: NewArgs) -> Result<(), String> {} else {MAIN_SKIA};- let files: [(&str, String); 6] = [+ let files: [(&str, String); 5] = [("Cargo.toml", render(CARGO_TOML, &vars)),("src/lib.rs", render(project.template.lib(), &vars)),("src/main.rs", render(main, &vars)),- ("tests/frames.rs", render(FRAMES_TEST, &vars)),("README.md", render(README, &vars)),(".gitignore", render(GITIGNORE, &vars)),];@@ -582,7 +568,7 @@ fn new(args: NewArgs) -> Result<(), String> {println!("Added it to the fframes workspace members.");}println!(- "\nNext:\n {cd}\n {run} timeline\n {run} frame 1s,50%,end # writes frames/*.png\n {run} strip -n 12 # writes strip.png{preview}\n {run} render # writes out.mp4\n cargo test # frame snapshots",+ "\nNext:\n {cd}\n {run} timeline\n {run} frame 1s,50%,end # writes frames/*.png\n {run} strip -n 12 # writes strip.png{preview}\n {run} render # writes out.mp4",preview = if project.backend == Backend::Cpu {String::new()} else {@@ -628,7 +614,6 @@ mod tests {"backend_label","run","preview_line",- "snapshot_specs","strip_range","entrance_range",]@@ -640,7 +625,6 @@ mod tests {LIB_MULTI_SCENE,MAIN_CPU,MAIN_SKIA,- FRAMES_TEST,CARGO_TOML,README,GITIGNORE,diff --git a/cargo-fframes/templates/README.md.tmpl b/cargo-fframes/templates/README.md.tmplindex 41bfd39f..53822356 100644--- a/cargo-fframes/templates/README.md.tmpl+++ b/cargo-fframes/templates/README.md.tmpl@@ -8,7 +8,6 @@ rendered with the {{backend_label}} backend.| `src/lib.rs` | the video: scenes, animation, audio map || `src/main.rs` | the command line (`fframes::cli`) || `media/` | fonts, images and audio embedded into the binary |-| `tests/frames.rs` | frame snapshots and a check of every frame for problems |## Work on it@@ -21,8 +20,7 @@ rendered with the {{backend_label}} backend.{{run}} render {{strip_range}} --draft # a part of the video, half resolution, fast preset{{run}} audio analyze --waveform w.png # loudness (LUFS), peaks, silence per scene{{run}} render # the final video, writes out.mp4-{{preview_line}}cargo test # frame snapshots (FFRAMES_UPDATE_SNAPSHOTS=1 to accept)-```+{{preview_line}}```Times accept frames (`120`), seconds (`3.2s`), `m:ss`, percentages (`50%`), scenes (`DataScene`,`#1`) and offsets inside scenes (`[email protected]`, `@50%`, `@end`). Add `--json` to anydiff --git a/cargo-fframes/templates/frames_test.rs.tmpl b/cargo-fframes/templates/frames_test.rs.tmpldeleted file mode 100644index 2d295b14..00000000--- a/cargo-fframes/templates/frames_test.rs.tmpl+++ /dev/null@@ -1,50 +0,0 @@-//! Visual regression: renders a few frames and compares them with the approved PNGs in-//! `_frame_snapshots/`. The first run only creates them, so look at the PNGs before you-//! commit them. `FFRAMES_UPDATE_SNAPSHOTS=1 cargo test` accepts intentional changes; failing-//! frames leave `.actual.png` and `.diff.png` files.-use fframes::{CpuFrameRenderer, Previewer, RenderOptions, StaticMediaProvider, snapshot};-use {{lib_name}}::{ {{Struct}}Media, {{Struct}}Video };--#[test]-fn key_frames_match_snapshots() {- let media = {{Struct}}Media::prepare().unwrap();- let video = {{Struct}}Video::new(&media, "{{title}}");- let options = RenderOptions {- media: Some(&media),- scale_resolution: 0.5,- ..Default::default()- };- let mut previewer = Previewer::new(&video, &options).unwrap();-- snapshot::assert_frames(- &mut previewer,- &mut CpuFrameRenderer::default(),- // Settled frames: the middle of a scene, not the end of it where it fades out.- &[{{snapshot_specs}}],- &snapshot::SnapshotOptions::default(),- );-}--#[test]-fn no_problems_in_any_frame() {- // Converting a frame without rasterizing it is fast, so every frame is checked.- let media = {{Struct}}Media::prepare().unwrap();- let video = {{Struct}}Video::new(&media, "{{title}}");- let options = RenderOptions {- media: Some(&media),- ..Default::default()- };- let mut previewer = Previewer::new(&video, &options).unwrap();-- let duration = previewer.timeline().duration_in_frames;- for frame in 0..duration {- let report = previewer.inspect(frame).unwrap();- let problems: Vec<_> = report- .diagnostics- .iter()- .filter(|d| d.severity >= fframes::diagnostics::Severity::Warning)- .map(|d| d.message.as_str())- .collect();- assert!(problems.is_empty(), "frame {frame} ({:.2}s): {problems:?}", report.seconds);- }-}diff --git a/skills/fframes-video/SKILL.md b/skills/fframes-video/SKILL.mdindex b53aac8d..7aeea802 100644--- a/skills/fframes-video/SKILL.md+++ b/skills/fframes-video/SKILL.md@@ -84,7 +84,6 @@ my-video/src/lib.rs # the video (from the template)src/main.rs # the command linemedia/ # fonts, images and audio compiled into the binary (one starter font)- tests/frames.rs # frame snapshots and a check of every frame for problemsREADME.md # the commands below```@@ -125,11 +124,6 @@ Rules:- Prefer `strip` to many `frame` calls; add `--scale 0.5` when composition is all you need.- Add `--json` when parsing output: the result goes to stdout, progress to stderr.- Keep `--release`: debug builds render many times slower.-- `cargo test` compares settled frames with approved snapshots in `_frame_snapshots/` and- fails if any frame has warnings. The first run only creates the snapshots: look at the PNGs- before committing them, a created baseline is not a reviewed one.- `FFRAMES_UPDATE_SNAPSHOTS=1 cargo test` accepts intended changes. Snapshot the middle of a- scene (`Intro@3s`), not its end where it fades out.### Addressing time@@ -240,7 +234,6 @@ the user listen in `$R preview`.3. `$R audio analyze` shows sensible levels.4. `$R render -o out.mp4`, then confirm size, frame count and audio with`ffprobe -v error -show_entries stream=codec_type,width,height,nb_frames,duration out.mp4`.-5. Run `cargo test` if the project keeps snapshots, and commit `_frame_snapshots/*.png`.Tell the user the output path, the duration, the path of a strip image and the `preview`command to watch it.