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
-
Video Orientation
VideoFrame carries rotation + flip metadata through the codec pipeline.
-
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. -
Orientation Mixer
All eight EXIF orientations on one screen:
rotation×flipmatrix, with each cell built as a realnew VideoFrame(canvas, { rotation, flip }). Read the resulting render side by side. -
Canvas renderer
Side-by-side comparison: naive
ctx.drawImage(frame)that ignores orientation metadata vs the correct approach that readsframe.rotationandframe.flipand 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.