Skip to main content

Red Screen Video

The simplest possible example - encode 1 second of red frames:

Rainbow Gradient

Encode a colorful gradient animation:

Text Frame

Encode a frame with text (using Canvas):

Multiple Colors

Encode frames with different colors:

Checkerboard Pattern

Encode an animated checkerboard:

Tips for Beginners

Forgetting to close frames causes memory leaks.
WebCodecs uses microseconds, not milliseconds.
Closing before flush loses frames.
First frame should always be a keyframe.

Next Steps

First Decode

Learn to decode video

HDR Examples

High dynamic range video

Alpha Examples

Transparent video

Real-World

Production examples