Skip to content

Fix all-black H.264 output by avoiding lossless x264 in video handler#23

Open
casper88 wants to merge 1 commit into
NVIDIA:mainfrom
casper88:fix/video-h264-compat-profile
Open

Fix all-black H.264 output by avoiding lossless x264 in video handler#23
casper88 wants to merge 1 commit into
NVIDIA:mainfrom
casper88:fix/video-h264-compat-profile

Conversation

@casper88
Copy link
Copy Markdown

@casper88 casper88 commented Jun 6, 2026

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.

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>
@casper88 casper88 marked this pull request as ready for review June 6, 2026 19:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant