Skip to main content

Overview

Alpha channels add transparency support to video, enabling:
  • Transparent video overlays (logos, graphics, UI elements)
  • Green screen alternatives (pre-keyed footage)
  • Animated stickers and GIFs with transparency
  • Compositing workflows without chroma keying
node-webcodecs supports alpha channel encoding with VP8 and VP9 codecs.

Codec Support

VP9

Recommended for Alpha
  • Better compression than VP8
  • YUVA420P format
  • Widely supported
  • WebM container

VP8

Legacy Alpha Support
  • Good compression
  • YUVA420P format
  • Older browsers
  • WebM container

H.264

No Alpha Support
  • YUV only
  • No transparency

HEVC

Limited Alpha Support
  • Not widely supported
  • Proprietary extensions
Browser PlaybackAlpha video can be played in browsers using:
  • <video> tag with WebM container
  • Canvas API for compositing
  • WebGL for advanced effects

Quick Start

Alpha Modes

Keep Alpha (alpha: 'keep')

Preserves transparency in the encoded video:
Use cases:
  • Transparent overlays
  • UI elements
  • Animated stickers
  • Any content with transparency

Discard Alpha (alpha: 'discard')

Removes alpha channel, treats it as fully opaque:
Use cases:
  • Converting RGBA to RGB
  • When transparency isn’t needed
  • Smaller file sizes
Default BehaviorIf alpha is not specified, it defaults to 'discard'. Always set alpha: 'keep' explicitly for transparent video.

Complete Example

Output:

Creating Alpha Frames

From RGBA Data

Circular Gradient Alpha

Feathered Edge Alpha

VP8 vs VP9 for Alpha

Bitrate Recommendations

Alpha channels increase bitrate requirements:
Recommended Bitrates with Alpha:

Verifying Alpha in Output

Check if alpha channel is preserved:
Look for:

Browser Playback

HTML5 Video

Canvas Compositing

Common Use Cases

Logo Overlay

Animated Stickers

UI Elements

Performance Considerations

Alpha encoding is more demanding than RGB encoding:
Optimization tips:
  • Use lower resolution for alpha elements
  • Increase compression with lower bitrate
  • Consider pre-rendering static transparency

Common Issues

Issue: Alpha not preserved

Issue: Poor alpha quality (blocky edges)

Solution: Increase bitrate for alpha channel:

Issue: Large file sizes

Solution: Use VP9 instead of VP8, or reduce resolution:

Best Practices

The default is 'discard', which removes transparency.
VP9 provides 30-40% better compression than VP8 for alpha video.
Alpha channels need ~40% more bitrate for equivalent quality:
Always verify alpha quality on different backgrounds:
  • Solid colors
  • Gradients
  • Checkerboard patterns
  • Real footage

Next Steps

Alpha Examples

Complete alpha video examples

VP9 Encoding

VP9 encoder reference

Real-World Demo

Production alpha workflows

Troubleshooting

Common alpha issues