Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions crates/rustmotion-cli/src/commands/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
Expand Down Expand Up @@ -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"));
Expand Down
12 changes: 12 additions & 0 deletions crates/rustmotion/src/encode/video/formats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Loading