{"slug": "transparent-video-exports-why-one-mp4-url-isn-t-enough", "title": "Transparent video exports: why one MP4 URL isn't enough", "summary": "A developer working on unbg.video, a video background remover and editor, explains why a single MP4 URL is insufficient for transparent video exports, detailing the distinct requirements for WebM, ProRes 4444 MOV, and separate H.264 color and alpha files. The post includes an FFmpeg experiment to verify alpha channels and warns against recovering transparency by deleting black pixels.", "body_md": "A background-removal API can finish successfully while the exported file is still wrong for the next step. A video that plays on a black background might have lost its transparency—or the player might simply be displaying it against black. Those are different problems.\n\nI work on [unbg.video](https://unbg.video/), a video background remover and editor. The project has export paths for WebM, ProRes 4444 MOV, and separate H.264 color and alpha files. Here is a practical way to reason about those outputs, with a small FFmpeg experiment you can run without an AI service.\n\n“Download video” hides several different jobs:\n\n| Next step | Output to consider | What to verify | \n|---|---|---|\n| Display transparent footage on a website | WebM with alpha | Actual transparency in the target browser and device | \n| Continue compositing in an editor | ProRes 4444 MOV with alpha | Import behavior and alpha interpretation in that editor | \n| Transfer color and a separate matte | H.264 color + grayscale alpha files | Matching dimensions, timestamps, duration, and mask convention | \n| Publish a finished scene with its new background | Flattened H.264 MP4 | The final composition; transparency is no longer needed | \n\nThe extension alone does not describe the whole contract. A MOV file does not automatically contain alpha. An ordinary H.264 MP4 export is not a portable RGBA deliverable. In the two-file workflow, the second MP4 stores a grayscale matte as picture data; it is not an embedded alpha channel in the color file.\n\nFor straight alpha, the basic compositing relationship is:\n\n```\noutput = alpha * foreground + (1 - alpha) * background\n```\n\nHere alpha is normalized from 0 to 1: zero reveals the background, one keeps the foreground, and intermediate values produce partial coverage. For physically meaningful blending, color-space handling also matters; this equation is a conceptual starting point.\n\nA useful consequence: you cannot safely recover transparency by deleting every black pixel. Black clothing and shadows are legitimate foreground content. Keep the matte.\n\nAlso establish whether color is straight or premultiplied. With premultiplied color, RGB already includes multiplication by alpha. Multiplying again can darken the edges. If the silhouette looks right but has a dark fringe, inspect this convention before blaming the segmentation model.\n\nThis synthetic example creates one second of red video and a horizontal grayscale ramp, combines them, and writes ProRes 4444. It needs an FFmpeg build with `prores_ks`.\n\n```\nffmpeg \\\n  -f lavfi -i 'color=c=red:s=64x64:r=10:d=1,format=rgb24' \\\n  -f lavfi -i 'nullsrc=s=64x64:r=10:d=1,format=gray,geq=lum=255*X/W' \\\n  -filter_complex '[0:v][1:v]alphamerge,format=yuva444p10le[v]' \\\n  -map '[v]' -an \\\n  -c:v prores_ks -profile:v 4 -pix_fmt yuva444p10le \\\n  foreground.mov\n```\n\nThen extract a frame of the stored alpha:\n\n```\nffmpeg -i foreground.mov \\\n  -vf 'alphaextract,format=gray' -frames:v 1 -update 1 mask.png\n```\n\nThe expected mask is a horizontal dark-to-light ramp, not a solid white frame. The red image should become progressively more opaque when composited over a background.\n\nThis example was run locally with FFmpeg 8.0.1 for this article: the output decoded as ProRes 4444 with an alpha-capable pixel format, and the extracted 8-bit alpha ramp ranged from 0 to 251 (the last column is 63/64 of full scale). It is an export smoke test, not evidence of browser compatibility or segmentation quality. Audio is deliberately omitted.\n\nFFmpeg documents [alpha extraction and merging](https://ffmpeg.org/ffmpeg-filters.html#alphamerge) and the [ProRes encoder options](https://www.ffmpeg.org/ffmpeg-codecs.html#ProRes). When replacing the synthetic inputs with real color and matte files, first align their dimensions and timeline. Resetting a timestamp does not repair missing or mismatched frames.\n\nThe project stores multiple video assets with color/alpha variants and can package the H.264 pair into a ZIP. That matters: a single `videoUrl` cannot tell a consumer whether it has a finished composition or only half of a compositing input.\n\nFor a new API, a small discriminated union can make that distinction explicit. This is an illustrative design, not a copy of the project's implementation:\n\n```\ntype VideoExport =\n  | { kind: 'transparent'; url: string; format: 'webm' | 'prores4444' }\n  | { kind: 'matte-pair'; colorUrl: string; alphaUrl: string }\n  | { kind: 'flattened'; url: string; format: 'mp4' };\n```\n\nOnly mark a pair ready when both assets are available. Give files explicit names such as `clip_color.mp4` and `clip_alpha.mp4`, and document which mask values mean opaque. Otherwise the ZIP merely moves the ambiguity to the user.\n\nMy suggested acceptance checklist is short:\n\nThe useful product question is: **Can the recipient use this file for their next step without guessing?** That question should shape the export format, the API response, and the download label.", "url": "https://wpnews.pro/news/transparent-video-exports-why-one-mp4-url-isn-t-enough", "canonical_source": "https://dev.to/bill_king_d4cd78085ee37d2/transparent-video-exports-why-one-mp4-url-isnt-enough-3kko", "published_at": "2026-09-08 05:35:06+00:00", "updated_at": "2026-09-08 06:01:57.438660+00:00", "lang": "en", "topics": ["developer-tools"], "entities": ["unbg.video", "FFmpeg", "ProRes 4444", "H.264", "WebM"], "alternates": {"html": "https://wpnews.pro/news/transparent-video-exports-why-one-mp4-url-isn-t-enough", "markdown": "https://wpnews.pro/news/transparent-video-exports-why-one-mp4-url-isn-t-enough.md", "text": "https://wpnews.pro/news/transparent-video-exports-why-one-mp4-url-isn-t-enough.txt", "jsonld": "https://wpnews.pro/news/transparent-video-exports-why-one-mp4-url-isn-t-enough.jsonld"}}