fix(engine): detect VP9 alpha tag case-insensitively in ffprobe

Newer libavformat builds write the VP9-alpha sidecar tag as 'ALPHA_MODE'
(uppercase); older builds write 'alpha_mode'. ffprobe.ts only checked the
lowercase form, so files produced by recent ffmpeg encoders (including the
output of 'hyperframes remove-background' itself) were misclassified as
having no alpha channel. Knock-on effect: the producer extracted them as
JPGs (no alpha), the injected <img> overlays were fully opaque rectangles,
and any element below them on the z-stack (text, captions, other layers)
silently disappeared from the rendered output — even though the studio
preview rendered the same composition correctly via native <video> playback.

Symptom in our repro: a text-behind-subject composition showed the
headline correctly in studio preview but the production render covered
the headline entirely with the opaque avatar image.

Fix: read videoStream.tags.alpha_mode OR videoStream.tags.ALPHA_MODE.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
James
2026-05-04 20:29:33 -07:00
co-authored by Claude Opus 4.7
parent 5fca4becbc
commit b836941f09
+7 -1
View File
@@ -277,7 +277,13 @@ export async function extractMediaMetadata(filePath: string): Promise<VideoMetad
: null;
const colorSpace = ffprobeColorSpace ?? stillImageMeta?.colorSpace ?? null;
const pixelFormat = videoStream.pix_fmt || "";
const alphaMode = videoStream.tags?.alpha_mode || "";
// ffmpeg writes the VP9-alpha sidecar tag as either `alpha_mode` (older
// builds) or `ALPHA_MODE` (libavformat ≥ 6.x). Read case-insensitively
// so the alpha-aware extraction path triggers on both — without this
// the producer extracted alpha-having webms as opaque JPGs and the
// injected <img> covered everything below it on the z-stack.
const tags = (videoStream.tags ?? {}) as Record<string, string | undefined>;
const alphaMode = tags.alpha_mode ?? tags.ALPHA_MODE ?? "";
const hasAlpha =
/(^|[^a-z])yuva|rgba|argb|bgra|gbrap|gray[a-z0-9]*a/i.test(pixelFormat) || alphaMode === "1";