Fix all-black H.264 output by avoiding lossless x264 in video handler#23
Open
casper88 wants to merge 1 commit into
Open
Fix all-black H.264 output by avoiding lossless x264 in video handler#23casper88 wants to merge 1 commit into
casper88 wants to merge 1 commit into
Conversation
Generated videos played back as all-black in most players, browsers, and hardware decoders. ffprobe showed the cause: the stream advertised the "High 4:4:4 Predictive" profile while its pixels were actually yuv420p — a profile/chroma mismatch that breaks decoding. Root cause: ImageioVideoHandler.dump_to_fileobj forwarded the caller's `quality` to imageio-ffmpeg. At its top setting (quality=10, used for action rollouts) imageio-ffmpeg requests *lossless* x264, and lossless x264 is only available under the High 4:4:4 Predictive profile — so x264 stamped that profile even though the chroma stayed 4:2:0. Fix: encode with an explicit, finite CRF instead of imageio's quality knob. Append `-pix_fmt yuv420p -crf 18` to the ffmpeg output params, force `codec=libx264`, and drop the caller's `quality` so it cannot reintroduce lossless mode. The result is a standard "High" profile that plays everywhere at visually-lossless quality. Verified end-to-end: both quality=5 and quality=10 paths, plus a real action_forward_dynamics inference run, now produce profile=High / yuv420p. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: Casper88tw <casper88tw@gmail.com>
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.
Generated videos played back as all-black in most players, browsers, and hardware decoders. ffprobe showed the cause: the stream advertised the "High 4:4:4 Predictive" profile while its pixels were actually yuv420p — a profile/chroma mismatch that breaks decoding.
Root cause: ImageioVideoHandler.dump_to_fileobj forwarded the caller's
qualityto imageio-ffmpeg. At its top setting (quality=10, used for action rollouts) imageio-ffmpeg requests lossless x264, and lossless x264 is only available under the High 4:4:4 Predictive profile — so x264 stamped that profile even though the chroma stayed 4:2:0.Fix: encode with an explicit, finite CRF instead of imageio's quality knob. Append
-pix_fmt yuv420p -crf 18to the ffmpeg output params, forcecodec=libx264, and drop the caller'squalityso it cannot reintroduce lossless mode. The result is a standard "High" profile that plays everywhere at visually-lossless quality.Verified end-to-end: both quality=5 and quality=10 paths, plus a real action_forward_dynamics inference run, now produce profile=High / yuv420p.