Open Bug 1995193 Opened 1 year ago Updated 2 months ago

Implement `rotation` and `flip` support in VideoEncoder

Categories

(Core :: Audio/Video: Web Codecs, task, P3)

task

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:

  1. Add the active orientation: VideoEncoder needs to memorize the flip and rotation values of the first VideoFrame given to encode() after configure().
  2. Update encode(frame, options) method:
    • If active orientation is not set (first frame), assign the given frame's rotation and flip to it.
    • Otherwise (following frames), if the given frame's rotation and flip mismatches the active orientation's values, throw a DataError.
  3. Update Output EncodedVideoChunks (with outputs) algorithm: As steps 1.5.6/7 - 1.6, the active orientation's rotation and flip values should be set to the VideoDecoderConfig if 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:

  1. Add Active Orientation: VideoEncoder should record the rotation and flip values of the first VideoFrame provided to encode() after configure().
  2. Update encode(frame, options) method
    • If no active orientation is set (first frame), assign the frame's rotation and flip values.
    • Otherwise (for subsequent frames), if the given frame's rotation or flip differs from the active orientation, throw a DataError.
  3. Update Output EncodedVideoChunks (with outputs) algorithm: Set the active orientation's rotation and flip values in the generated (metadata's) VideoDecoderConfig if 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.

See Also: → 2065659
See Also: → 2066951
You need to log in before you can comment on or make changes to this bug.