---
agent:
  instructions: "Use this search API to find relevant content across this site with keywords or natural-language queries, instead of crawling individual pages. Results are returned in Markdown."
  endpoint: "https://framesfield.com/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://developers.cloudflare.com/ai-search/how-to/search-for-agents/"
title: "Fix Transparent Video Losing Alpha Channel in Browsers"
description: "Ship transparent web video as a dual-source pair: encode VP9 yuva420p WebM (-c:v libvpx-vp9 -pix_fmt yuva420p -auto-alt-ref 0) for Chrome/Firefox plus HEVC with Alpha MOV (-c:v hevc_videotoolbox -alpha_quality 0.75 -vtag hvc1) for Safari, and list the hvc1 source first in HTML."
canonical: "https://framesfield.com/fixes/ffmpeg-alpha-channel-webm-vp9-hevc-transparent-video-fix"
---

# Fix Transparent Video Losing Alpha Channel in Browsers

> Ship transparent web video as a dual-source pair: encode VP9 yuva420p WebM (-c:v libvpx-vp9 -pix_fmt yuva420p -auto-alt-ref 0) for Chrome/Firefox plus HEVC with Alpha MOV (-c:v hevc_videotoolbox -alpha_quality 0.75 -vtag hvc1) for Safari, and list the hvc1 source first in HTML.

- **Canonical URL:** https://framesfield.com/fixes/ffmpeg-alpha-channel-webm-vp9-hevc-transparent-video-fix
- **Category:** FFmpeg & Delivery
- **Error Signature:** `Visual defect: Transparent ProRes 4444 / RGBA PNG sequence renders with a solid black background in <video> | Safari refuses WebM VP9 alpha | ffprobe: pix_fmt=yuv420p (missing alpha plane)`
- **Last Verified:** 2026-12-01

## Observed Symptom

Your transparent 3D product spin, animated UI badge, or ProRes 4444 motion overlay loses its transparency and renders inside a solid black or white rectangle once encoded for the web—or plays transparently in desktop Chrome while breaking completely in macOS and iOS Safari.

## Technical Root Cause

Standard H.264 MP4 has zero alpha-channel support, and desktop/mobile browsers remain split across two incompatible alpha video codecs: Chromium and Firefox require VP9 WebM with yuva420p alpha, while Apple Safari and iOS strictly require HEVC with Alpha tagged hvc1 inside an MOV/MP4 container.

## Under the Hood

Creators routinely render a pristine transparent RGBA PNG sequence from Blender, Remotion, or After Effects—or a ProRes 4444 (`yuva444p10le`) master—and run standard `libx264` to create an `.mp4`. Because the H.264 specification contains no alpha plane, FFmpeg immediately flattens transparency against solid black (`#000000`) during pixel conversion to `yuv420p`.

Switching to VP9 WebM (`-c:v libvpx-vp9 -pix_fmt yuva420p`) restores crisp transparency across Chrome, Edge, Android, and Firefox, but introduces two sneaky pitfalls. First, omitting `-auto-alt-ref 0` on certain libvpx builds causes ghosted or dropped alpha frames. Second, Apple Safari on macOS and iOS does not render VP9 alpha transparency reliably and instead implements Apple’s **HEVC with Alpha** specification—encoded on macOS via `hevc_videotoolbox -alpha_quality 0.75 -vtag hvc1`.

A third trap catches developers during verification and HTML deployment. When you inspect or re-process a VP9 alpha WebM with `ffprobe` or `ffmpeg`, FFmpeg’s default built-in `vp9` decoder silently ignores the Matroska `BlockAdditional` alpha side-data unless you explicitly force `-c:v libvpx-vp9` *before* `-i input.webm`. On the frontend, your HTML5 `<video>` tag MUST list the HEVC `.mov` source first with `type='video/mp4; codecs="hvc1"'` followed by the VP9 `.webm` source so Safari picks HEVC Alpha while Chrome and Firefox skip straight to WebM.

## Before vs. After

### Broken (Broken Single-File Export (H.264 Strips Alpha; Solo WebM Breaks Safari))

```
# H.264 has zero alpha support -> solid black background everywhere:
ffmpeg -i prores4444_alpha.mov -c:v libx264 -pix_fmt yuv420p broken_black_box.mp4
```

### Verified Fix (Verified Dual-Codec Browser Stack (HEVC Alpha for Safari + VP9 Alpha for Chrome))

```
# 1. Chrome / Firefox / Edge: VP9 WebM with explicit yuva420p alpha plane
ffmpeg -y -i prores4444_alpha.mov \
  -c:v libvpx-vp9 -pix_fmt yuva420p -b:v 0 -crf 30 -auto-alt-ref 0 -an hero_alpha.webm

# 2. Safari / iOS (macOS): Hardware HEVC with Alpha + hvc1 tag
ffmpeg -y -i prores4444_alpha.mov \
  -c:v hevc_videotoolbox -allow_sw 1 -alpha_quality 0.75 -vtag hvc1 -pix_fmt bgra -an hero_alpha.mov
```

Combining `libvpx-vp9 -pix_fmt yuva420p` and `hevc_videotoolbox -alpha_quality 0.75 -vtag hvc1` covers 100% of modern desktop and mobile browsers with hardware-accelerated transparency.

## Copy-Paste Fix (build-transparent-web-video.sh)

```bash
#!/usr/bin/env bash
set -euo pipefail

# Usage: ./build-transparent-web-video.sh source_rgba_or_prores4444.mov output_prefix
SRC="$1"
PREFIX="$2"

# 1. Build VP9 WebM with alpha (Chrome, Edge, Firefox, Android)
# Ensures even dimensions while preserving RGBA alpha before yuva420p conversion
ffmpeg -y -i "$SRC" \
  -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2,format=yuva420p" \
  -c:v libvpx-vp9 -pix_fmt yuva420p -b:v 0 -crf 30 -row-mt 1 -auto-alt-ref 0 \
  -an "${PREFIX}.webm"

# 2. Build HEVC with Alpha MOV (macOS Safari & iOS Safari — requires macOS VideoToolbox)
if ffmpeg -hide_banner -encoders | grep -q "hevc_videotoolbox"; then
  ffmpeg -y -i "$SRC" \
    -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" \
    -c:v hevc_videotoolbox -allow_sw 1 -alpha_quality 0.75 -vtag hvc1 -pix_fmt bgra \
    -an "${PREFIX}.mov"
else
  echo "NOTE: hevc_videotoolbox requires macOS; encode Safari .mov on a Mac runner or Apple Compressor."
fi

cat <<EOF

Paste this exact source order into HTML5 <video> (hvc1 MUST come before webm):
<video autoplay loop muted playsinline width="800" height="800">
  <source src="/video/${PREFIX}.mov" type='video/mp4; codecs="hvc1"' />
  <source src="/video/${PREFIX}.webm" type="video/webm" />
</video>
EOF
```

## Step-by-Step Resolution

1. **Verify your source asset truly contains an alpha channel before encoding:** Probe your source ProRes 4444 MOV or PNG sequence with ffprobe and confirm pix_fmt reads rgba, bgra, or yuva444p10le—if the master is already yuv420p, transparency was lost upstream in Blender or After Effects.
2. **Encode both the VP9 yuva420p WebM and the macOS HEVC hvc1 Alpha MOV:** Run libvpx-vp9 with -pix_fmt yuva420p -auto-alt-ref 0 for Chrome/Firefox, and encode the Safari asset on macOS with hevc_videotoolbox -alpha_quality 0.75 -vtag hvc1 -pix_fmt bgra.
3. **Place the hvc1 <source> first in HTML5 <video> and verify on Chrome plus Safari:** Use type='video/mp4; codecs="hvc1"' on the first <source> tag and type="video/webm" on the second, include muted playsinline for iOS autoplay, and test against a colored CSS div in both browsers.

## Verification Check (Confirm Alpha Plane Exists in Both WebM (via libvpx-vp9 Decoder) and HEVC MOV)

```bash
ffprobe -v error -c:v libvpx-vp9 -select_streams v:0 -show_entries stream=codec_name,pix_fmt:stream_tags=alpha_mode -of default=nw=1 hero_alpha.webm && ffprobe -v error -select_streams v:0 -show_entries stream=codec_name,codec_tag_string,profile -of default=nw=1 hero_alpha.mov
```

**Expected healthy output:**

```text
codec_name=vp9
pix_fmt=yuva420p
TAG:alpha_mode=1
codec_name=hevc
profile=Main
codec_tag_string=hvc1
```

## Prevention Guardrails

1. **Always pass -c:v libvpx-vp9 BEFORE -i when reading WebM alpha back into FFmpeg:** FFmpeg’s native vp9 decoder drops the alpha plane by default, falsely making valid transparent WebM files appear opaque when you composite or inspect them later.
2. **Export straight (unmatted) alpha instead of black-premultiplied alpha:** Rendering straight alpha out of Blender, Remotion, or After Effects avoids dark gray fringe halos around soft glows and translucent shadows on light landing pages.
3. **Set a lightweight transparent WebP or PNG poster frame on hero <video> tags:** Adding poster="/img/hero-frame0.webp" prevents layout flicker before frame 0 decodes and gives Low Power Mode iOS devices a crisp transparent fallback.

## FAQs

### Why does the HTML <source> tag use type='video/mp4; codecs="hvc1"' for a .mov file?

WebKit checks the codecs="hvc1" hint to confirm HEVC Alpha support and opens the .mov cleanly, whereas Chrome and Firefox recognize they lack hvc1 alpha support (or reject the codec hint) and reliably fall through to the VP9 WebM source listed second.

### Can I encode Safari HEVC with Alpha on a Linux CI server without macOS?

Not with open-source libx265 directly, because Apple’s HEVC with Alpha auxiliary layer is currently implemented in Apple VideoToolbox (hevc_videotoolbox on macOS) and Apple Compressor. Teams on Linux CI either run a macOS GitHub Actions runner (`macos-14`) for the HEVC step or use stacked alpha-matte canvases in WebGL.

### Why did ffprobe say pix_fmt=yuv420p on my transparent WebM file?

You ran ffprobe without specifying -c:v libvpx-vp9 before the input filename. Adding ffprobe -c:v libvpx-vp9 -i hero_alpha.webm forces the libvpx decoder and reveals pix_fmt=yuva420p and TAG:alpha_mode=1.

### What does -alpha_quality 0.75 control in hevc_videotoolbox?

It sets the compression quality of the auxiliary monochrome alpha mask layer from 0.0 (disabled) to 1.0 (near-lossless). Values between 0.70 and 0.85 preserve smooth anti-aliased edges and drop shadows while keeping file sizes small.

### How do I turn an RGBA PNG image sequence directly into both transparent video formats?

Pass -framerate 30 -i frames_%04d.png as the input to the exact same commands above; FFmpeg preserves the RGBA alpha channel directly into both yuva420p (WebM) and bgra (hevc_videotoolbox) without needing an intermediate ProRes 4444 file.
