Skip to content

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

Merge origin/main into issue-539 (keep both CLI helpers)

Brandon Thomas14d217128297
diff --cc apps/filmcraft-cli/src/main.rs
index 49be8852b,555240357..be104b30c
--- a/apps/filmcraft-cli/src/main.rs
+++ b/apps/filmcraft-cli/src/main.rs
@@@ -454,25 -460,23 +460,40 @@@ fn written_paths(result: &Value, reques
if paths.is_empty() { vec![requested.to_string()] } else { paths }
}
+/// The active sequence at the playhead, or the reason it cannot be rendered (no sequence, bad scale).
+fn render_at_playhead(s: &Session, scale: f32) -> Result<filmcraft_engine::render::Image, String> {
+ s.try_render_program_at(scale, s.playhead()).map_err(|e| e.to_string())
+}
+
+ /// `--start` / `--end` ask for a custom range. A lone bound is forwarded too, so the engine reports the missing one
+ /// instead of the export silently running over the whole sequence.
+ fn set_custom_bounds(p: &mut Value, start: Option<&str>, end: Option<&str>) {
+ if start.is_none() && end.is_none() {
+ return;
+ }
+ p["range"] = json!("custom");
+ if let Some(s0) = start {
+ p["startSeconds"] = parse_value(s0);
+ }
+ if let Some(s1) = end {
+ p["endSeconds"] = parse_value(s1);
+ }
+ }
+
#[cfg(test)]
mod format_tests {
+ #[test]
+ fn render_reports_the_real_reason() {
+ let mut s = filmcraft_engine::Session::default();
+ assert!(super::render_at_playhead(&s, 0.5).unwrap_err().contains("sequence"));
+ s.execute("file.newSequence", serde_json::json!({"width": 16, "height": 16})).unwrap();
+ for scale in [0.0, -1.0, f32::NAN] {
+ let e = super::render_at_playhead(&s, scale).unwrap_err();
+ assert!(e.contains("finite and positive"), "{e}");
+ }
+ assert_eq!(super::render_at_playhead(&s, 0.5).unwrap().w, 8);
+ }
+
/// The CLI (and MCP / headless runs, which share its entry point) registers the hardware
/// decoders at start-up.
#[test]