diff --git a/crates/rustmotion-cli/src/commands/render.rs b/crates/rustmotion-cli/src/commands/render.rs index 2adff84..3172bbb 100644 --- a/crates/rustmotion-cli/src/commands/render.rs +++ b/crates/rustmotion-cli/src/commands/render.rs @@ -56,7 +56,10 @@ pub fn cmd_render( // Refuse a codec the container cannot hold before rendering anything: // ffmpeg otherwise discovers it after every frame is done, and reports it // as a raw -22 with no output file. - { + // + // `--frame` is exempt: it writes a PNG still through `render_single_frame` + // and never reaches an encoder, so the codec is not part of that operation. + if frame.is_none() { let container = format .as_deref() .unwrap_or_else(|| output.extension().and_then(|e| e.to_str()).unwrap_or("mp4")); @@ -262,10 +265,9 @@ pub fn cmd_watch( use notify::{RecursiveMode, Watcher}; use std::sync::mpsc; - // Refuse a codec the container cannot hold before rendering anything: - // ffmpeg otherwise discovers it after every frame is done, and reports it - // as a raw -22 with no output file. - { + // Refuse a codec the container cannot hold before rendering anything (see + // `cmd_render`; `--frame` is exempt for the same reason). + if frame.is_none() { let container = format .as_deref() .unwrap_or_else(|| output.extension().and_then(|e| e.to_str()).unwrap_or("mp4")); diff --git a/crates/rustmotion/src/encode/video/formats.rs b/crates/rustmotion/src/encode/video/formats.rs index 0b48fa9..ee06ab7 100644 --- a/crates/rustmotion/src/encode/video/formats.rs +++ b/crates/rustmotion/src/encode/video/formats.rs @@ -637,6 +637,18 @@ mod codec_container_tests { check_codec_container("av1", "mp4").expect("unknown codec must not be second-guessed"); } + /// A `--frame` still is written by `render_single_frame`, never by an + /// encoder, so the codec is not part of that operation at all. The guard + /// is skipped for it in `cmd_render`/`cmd_watch`; this pins the reason a + /// `.png` extension is not in any codec's list. + #[test] + fn png_is_not_a_container_any_codec_claims() { + assert!( + check_codec_container("h264", "png").is_err(), + "a still is not an h264 container — the caller must not ask" + ); + } + /// These containers never reach the ffmpeg muxer. #[test] fn own_path_containers_are_left_alone() {