Implement `rotation` and `flip` support in VideoEncoder
Categories
(Core :: Audio/Video: Web Codecs, task, P3)
Tracking
()
People
(Reporter: chunmin, Unassigned)
References
(Depends on 2 open bugs, Blocks 1 open bug)
Details
As Bug 1995191, Once VideoFrame's rotation and flip support has been implemented (Bug 1995151), extending the these properties to VideoEncoder should be straightforward.
This work involves two main tasks:
- Add the
active orientation:VideoEncoderneeds to memorize theflipandrotationvalues of the firstVideoFramegiven toencode()afterconfigure(). - Update
encode(frame, options)method:- If
active orientationis not set (first frame), assign the given frame'srotationandflipto it. - Otherwise (following frames), if the given frame's
rotationandflipmismatches theactive orientation's values, throw aDataError.
- If
- Update Output EncodedVideoChunks (with outputs) algorithm: As steps 1.5.6/7 - 1.6, the
active orientation'srotationandflipvalues should be set to theVideoDecoderConfigif needed.
The simplest way to implement these is to track rotation and flip in VideoEncoderConfigInternal, which represents the internal version of VideoEncoderConfig stripped of unnecessary DOM elements. This makes it easy to create a VideoDecoderConfig from a VideoEncoderConfigInternal via VideoEncoderConfigInternal when needed.
The expected outcome for this work is to pass video-encoder-orientation.https.any.js
Similar to Bug 1995191, once VideoFrame's rotation and flip support is implemented (Bug 1995151), extending these properties to VideoEncoder should be straightforward.
This work involves three main tasks:
- Add Active Orientation:
VideoEncodershould record therotationandflipvalues of the firstVideoFrameprovided toencode()afterconfigure(). - Update encode(frame, options) method
- If no active orientation is set (first frame), assign the frame's
rotationandflipvalues. - Otherwise (for subsequent frames), if the given frame's
rotationorflipdiffers from the active orientation, throw aDataError.
- If no active orientation is set (first frame), assign the frame's
- Update Output EncodedVideoChunks (with outputs) algorithm: Set the active orientation's
rotationandflipvalues in the generated (metadata's)VideoDecoderConfigif needed, as steps 1.5.6 & 7 - 1.6
The simplest way to implement this is to track rotation and flip in VideoEncoderConfigInternal, which represents the internal version of VideoEncoderConfig stripped of unnecessary DOM elements. This design makes it straightforward to generate a VideoDecoderConfig from a VideoEncoderConfigInternal when needed (via VideoEncoder::EncoderConfigToDecoderConfig).
The expected outcome is to pass the video-encoder-orientation.https.any.js. Since this WPT uses the decoderConfig in the metadata generated from the VideoEncoder's output, this work depends on Bug 1995191.
Description
•