Skip to content

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

Merged
foreverlms merged 4 commits into
NVIDIA:mainfrom
casper88:fix/video-h264-compat-profile
Jun 8, 2026
Merged

Fix all-black H.264 output by avoiding lossless x264 in video handler#23
foreverlms merged 4 commits into
NVIDIA:mainfrom
casper88:fix/video-h264-compat-profile

Conversation

@casper88

@casper88 casper88 commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

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
@foreverlms
foreverlms merged commit 19a00f8 into NVIDIA:main Jun 8, 2026
7 checks passed
rahul-steiger-nv pushed a commit to rahul-steiger-nv/cosmos-framework that referenced this pull request Jun 15, 2026
…NVIDIA#23)

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.

Signed-off-by: Casper88tw <casper88tw@gmail.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Co-authored-by: Maosheng Liao <maoshengl@nvidia.com>
Co-authored-by: lfengad <liangf@nvidia.com>
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.

3 participants