fix(encode): reject a codec the container cannot hold, before rendering - #194
Merged
Conversation
rustmotion render --codec prores -o out.mp4 rendered the whole video, handed
it to ffmpeg, and surfaced ffmpeg's internals:
[vf#0:0] Task finished with error code: -22 (Invalid argument)
[out#0/mp4] Nothing was written into output file, because at least one of
its streams received no packets.
with no output file to show for it. The pair was never checked. --codec prores
is the documented recommendation for dark gradients and .mp4 is the extension
everyone types, so the combination is a natural mistake, and the cost of
finding out was a full render.
check_codec_container is a pure lookup run before the first frame in both
cmd_render and cmd_watch. It names what works rather than restating the
failure. An unknown codec passes through untouched — guessing would block
combinations ffmpeg supports — and gif/png-seq/raw never reach the muxer.
LeadcodeDev
added a commit
that referenced
this pull request
Aug 12, 2026
The guard added in #194 ran before cmd_render's single-frame branch, so rustmotion render -f s.json -o f.png --frame 0 failed with "codec 'h264' cannot be written into a .png file". A --frame still is written by render_single_frame and never reaches an encoder, so the codec is not part of that operation — the check does not apply. This is a regression I shipped in #194: every local check passed because none of them exercised --frame, which is the documented way to preview a scene.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #191.
What
The codec/container pair was never validated: rustmotion rendered every frame, handed the result to ffmpeg, and passed ffmpeg's internals through. No output file was produced.
--codec proresis the documented recommendation for dark gradients (CLAUDE.md) and.mp4is the default extension, so the two together are a natural mistake — and the cost of discovering it was a complete render.After
How
check_codec_containeris a pure lookup inencode::video::formats, called before the first frame in bothcmd_renderandcmd_watch. Design choices worth flagging:gif/png-seq/raware left alone — they have their own encode path and never reach the ffmpeg muxer.Tests
Five, no ffmpeg needed: prores/mp4 refused with
.movnamed, the documented pairs accepted, vp9/mp4 refused, unknown codecs passed through, own-path containers untouched.cargo test --workspacegreen,cargo fmt --checkandcargo clippy --all-targets -- -D warningsclean.