v136 · multimedia

Add support for video frame orientation metadata to WebCodecs

Introduces "rotation: int" and "flip: bool" values to various video related interfaces in WebCodecs so that developers can work with frame sources that have orientation (E.g., Android cameras, certain media). The VideoFrame interface grows the ability to create VideoFrames with arbitrary rotation and flip as well as accessors for this information on the V

concepts

  1. Video Orientation

    VideoFrame carries rotation + flip metadata through the codec pipeline.

  2. Encoder round-trip

    Encode a rotated VideoFrame, decode the chunk back, and assert the orientation survived. Demonstrates the "encoding may silently encode incorrectly" failure mode the explainer warns about.

  3. Orientation Mixer

    All eight EXIF orientations on one screen: rotation × flip matrix, with each cell built as a real new VideoFrame(canvas, { rotation, flip }). Read the resulting render side by side.

  4. Canvas renderer

    Side-by-side comparison: naive ctx.drawImage(frame) that ignores orientation metadata vs the correct approach that reads frame.rotation and frame.flip and applies the canvas transform first. Toggle rotation and flip to see the wrong vs right result.

why it shipped

Currently developers have no way of knowing when they receive frames with a non-default orientation. Containers may contain orientation information that developers have no way of telling decoded frames about. Encoding may silently encode incorrectly.

references