fix(render): preserve alpha on .webm overlays by forcing libvpx-vp9 decoder#59
Open
DanielOwusu wants to merge 1 commit into
Open
fix(render): preserve alpha on .webm overlays by forcing libvpx-vp9 decoder#59DanielOwusu wants to merge 1 commit into
DanielOwusu wants to merge 1 commit into
Conversation
…preserved ffmpeg's native VP9 decoder decodes alpha-carrying WebM (alpha stored as a side-data plane) to opaque yuv420p. As a result a full-frame transparent overlay (e.g. a caption or lower-third track exported as VP9+alpha) becomes an opaque black layer that hides the base video and every overlay beneath it. Force `-c:v libvpx-vp9` on `.webm` overlay inputs in build_final_composite so the alpha-aware decoder is used and overlay transparency is honored. mp4/other overlays are unaffected. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
There was a problem hiding this comment.
1 issue found across 1 file
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="helpers/render.py">
<violation number="1" location="helpers/render.py:522">
P1: Extension-based decoder selection for .webm files is incorrect — WebM is a container that can hold VP8, VP9, or AV1 video. Forcing `libvpx-vp9` (a VP9-only decoder) for all `.webm` files will cause ffmpeg decode failure and abort the render when the overlay uses VP8 or AV1.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Fix all with cubic | Re-trigger cubic
| # decoder drops it (decodes to yuv420p → opaque), which turns a full-frame | ||
| # transparent overlay into an opaque black layer. Force the alpha-aware | ||
| # libvpx-vp9 decoder so overlay alpha is honored. | ||
| if ov_path.suffix.lower() == ".webm": |
There was a problem hiding this comment.
P1: Extension-based decoder selection for .webm files is incorrect — WebM is a container that can hold VP8, VP9, or AV1 video. Forcing libvpx-vp9 (a VP9-only decoder) for all .webm files will cause ffmpeg decode failure and abort the render when the overlay uses VP8 or AV1.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At helpers/render.py, line 522:
<comment>Extension-based decoder selection for .webm files is incorrect — WebM is a container that can hold VP8, VP9, or AV1 video. Forcing `libvpx-vp9` (a VP9-only decoder) for all `.webm` files will cause ffmpeg decode failure and abort the render when the overlay uses VP8 or AV1.</comment>
<file context>
@@ -515,7 +515,14 @@ def build_final_composite(
+ # decoder drops it (decodes to yuv420p → opaque), which turns a full-frame
+ # transparent overlay into an opaque black layer. Force the alpha-aware
+ # libvpx-vp9 decoder so overlay alpha is honored.
+ if ov_path.suffix.lower() == ".webm":
+ inputs += ["-c:v", "libvpx-vp9", "-i", str(ov_path)]
+ else:
</file context>
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.
What
build_final_compositeinhelpers/render.pynow forces-c:v libvpx-vp9on.webmoverlay inputs so their alpha channel is honored during compositing. Other overlay formats (mp4, etc.) are unaffected.Why
ffmpeg's native VP9 decoder decodes alpha-carrying WebM (alpha stored as a side-data plane, reported as
yuv420p+ALPHA_MODE=1) to opaqueyuv420p. When such a file is used as an overlay via theoverlayfilter, the transparent regions render as opaque black. For a full-frame transparent overlay — e.g. a captions track or lower-third exported as VP9+alpha — this turns the entire frame black and hides the base video and every overlay beneath it.Forcing the alpha-aware
libvpx-vp9decoder on the input makes ffmpeg decode toyuva420p, so overlay transparency composites correctly.How it showed up
Compositing an EDL whose
overlaysincluded VP9+alpha WebM layers (a transparent caption overlay and a transparent CTA lower-third) produced an output that was entirely black except for the opaque pixels of the topmost overlay. The base talking-head video and an opaque demo overlay were both hidden. Swapping in thelibvpx-vp9decoder for the.webminputs fixed it with no other changes.Change
inputs: list[str] = ["-i", str(base_path)] for ov in overlays: ov_path = resolve_path(ov["file"], edit_dir) - inputs += ["-i", str(ov_path)] + # VP9/WebM overlays carry alpha as a side-data plane. ffmpeg's native vp9 + # decoder drops it (decodes to yuv420p -> opaque), which turns a full-frame + # transparent overlay into an opaque black layer. Force the alpha-aware + # libvpx-vp9 decoder so overlay alpha is honored. + if ov_path.suffix.lower() == ".webm": + inputs += ["-c:v", "libvpx-vp9", "-i", str(ov_path)] + else: + inputs += ["-i", str(ov_path)]Notes for reviewers
libvpx-vp9re: alpha is the root cause.libvpxenabled (already required elsewhere in the project for HyperFrames/VP9 work)..webmoverlays.🤖 Generated with Claude Code
Summary by cubic
Preserves alpha in
.webmoverlays by forcing thelibvpx-vp9decoder inbuild_final_composite, fixing black frames from VP9+alpha sources. Other overlay formats are unaffected..webmoverlays, add-c:v libvpx-vp9before-isoffmpegdecodes toyuva420pand theoverlayfilter honors transparency.Written for commit 257db63. Summary will update on new commits.