-
Notifications
You must be signed in to change notification settings - Fork 139
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Orientation metadata for VideoFrame #351
Comments
EC: Important gap to properly reimplement |
I'll prepare a PR that adds a new |
This feature is very useful for mediacapture-transform (MediaStreamTrack Insertable Media Processing using Streams) and bridges the feature gap between the native code and the browser. |
Which parts in particular? Is this simply being able to pass the orientation through a |
This is because mediacapture-transform allows us to process each video frame as WebCodec's VideoFrame and send them to WebRTC inputs. A simple example is as follows: example, code If the VideoFrame has orientation metadata, mediacapture-transform can rotate the video at no cost. (in terms of copying and assigning). I'm not sure about flip/mirroring. (WebRTC's VideoFrame has a rotation field, but nothing related to flip.) |
I've just gotten back to this issue, and my opinion of the best path forward has changed (I now prefer making orientation an unexposed implementation detail). I'll outline both proposals here for discussion. Proposal: Unexposed Implementation DetailIn this approach, frame orientation is considered to be an implementation detail. If the underlying frame resource has an orientation, the Pros
Cons
Future Extensions
Proposal: Exposed MetadataIn this approach, frame orientation is exposed on While the set of extensions is the same, it makes sense to prioritize them since average applications are likely to desire those features immediately. Pros
Cons
|
As an interested lurker, is the orientation information encoded in individual video chunks or only part of the container? If it's the latter, how would the "Unexposed Implementation Detail" approach work in VideoDecoder? It seems like you would at least need the configuration option in your first "future extension" bullet. |
There is variability here between codecs, but typically container metadata is the primary source. This is the first listed extension, adding orientation metadata to |
So how would it work before that extension is added? |
The same as right now, which is to say that you have to manage orientation metadata yourself and apply the rendering transformation yourself. |
This was discussed at the Media WG meeting on May 30 (minutes). In general the "Unexposed Implementation Detail" approach was supported, and there was also support for adding some extensions immediately. Some specific cases that came up for discussion:
|
This has been open for a long time, orientation metadata is needed, any solution? After the transformation |
I have realized a flaw in the proposal above: it's not possible to hide the underlying orientation of 4:2:2 content, since there is no pixel format that describes 4:2:2 rotated by 90 degrees. The alternatives seem to be exposing the underlying orientation or forcing implementations to convert rotated frames (eg. to 4:4:4). |
Given the above issue with the existing proposal, I have prepared a new proposal similar to the "Exposed Metadata" option. The main difference is that I no longer use Proposal: Exposed Metadata (Take 2)In this approach, the transformation from the output of
Where the output of Alternatives
VideoFrame Constructors
I would recommend using the same numeric handling as CSS specifies for I would not require that implementations produce frames that have exactly the specified orientation values. Instead it would also be valid to apply the transformation to the underlying frame resource (the same as how we handle cropping). Alternatives
VideoDecoderThe same VideoEncoderThe strictest option is to add Alternatives
|
I'll note in passing that all browser do things differently in the area: w3c/csswg-drafts#4666 It's possible to also disable the orientation on the thing "receiving" the frame, and it should be somewhat consistent. |
Note that if frames end up being sent by WebRTC, WebRTC needs access to the metadata indicating rotation in order to set the CVO header extension correctly. https://www.rfc-editor.org/rfc/rfc7742.html#section-4 is the place where support is required. |
This change implements `rotation` and `flip` options in `VideoFrameInit` and `VideoFrameBufferInit`, as described in w3c/webcodecs#351 (comment). Bug: 40243431 Change-Id: I9eae4f4f101df7a285abd6575f7271b7589a512c
This change implements `rotation` and `flip` options in `VideoFrameInit` and `VideoFrameBufferInit`, as described in w3c/webcodecs#351 (comment). Bug: 40243431 Change-Id: I9eae4f4f101df7a285abd6575f7271b7589a512c Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5939863 Reviewed-by: Eugene Zemtsov <[email protected]> Commit-Queue: Eugene Zemtsov <[email protected]> Cr-Commit-Position: refs/heads/main@{#1379353}
This change implements `rotation` and `flip` options in `VideoFrameInit` and `VideoFrameBufferInit`, as described in w3c/webcodecs#351 (comment). Bug: 40243431 Change-Id: I9eae4f4f101df7a285abd6575f7271b7589a512c Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5939863 Reviewed-by: Eugene Zemtsov <[email protected]> Commit-Queue: Eugene Zemtsov <[email protected]> Cr-Commit-Position: refs/heads/main@{#1379353}
This change implements `rotation` and `flip` options in `VideoFrameInit` and `VideoFrameBufferInit`, as described in w3c/webcodecs#351 (comment). Bug: 40243431 Change-Id: I9eae4f4f101df7a285abd6575f7271b7589a512c Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5939863 Reviewed-by: Eugene Zemtsov <[email protected]> Commit-Queue: Eugene Zemtsov <[email protected]> Cr-Commit-Position: refs/heads/main@{#1379353}
…ptions on VideoFrame, a=testonly Automatic update from web-platform-tests [webcodecs] Add rotation and flip init options on VideoFrame This change implements `rotation` and `flip` options in `VideoFrameInit` and `VideoFrameBufferInit`, as described in w3c/webcodecs#351 (comment). Bug: 40243431 Change-Id: I9eae4f4f101df7a285abd6575f7271b7589a512c Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5939863 Reviewed-by: Eugene Zemtsov <[email protected]> Commit-Queue: Eugene Zemtsov <[email protected]> Cr-Commit-Position: refs/heads/main@{#1379353} -- wpt-commits: a525424ff744bca3cb7e11c8aa19127c95a60cb0 wpt-pr: 49013
…ptions on VideoFrame, a=testonly Automatic update from web-platform-tests [webcodecs] Add rotation and flip init options on VideoFrame This change implements `rotation` and `flip` options in `VideoFrameInit` and `VideoFrameBufferInit`, as described in w3c/webcodecs#351 (comment). Bug: 40243431 Change-Id: I9eae4f4f101df7a285abd6575f7271b7589a512c Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5939863 Reviewed-by: Eugene Zemtsov <[email protected]> Commit-Queue: Eugene Zemtsov <[email protected]> Cr-Commit-Position: refs/heads/main@{#1379353} -- wpt-commits: a525424ff744bca3cb7e11c8aa19127c95a60cb0 wpt-pr: 49013
…ptions on VideoFrame, a=testonly Automatic update from web-platform-tests [webcodecs] Add rotation and flip init options on VideoFrame This change implements `rotation` and `flip` options in `VideoFrameInit` and `VideoFrameBufferInit`, as described in w3c/webcodecs#351 (comment). Bug: 40243431 Change-Id: I9eae4f4f101df7a285abd6575f7271b7589a512c Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5939863 Reviewed-by: Eugene Zemtsov <[email protected]> Commit-Queue: Eugene Zemtsov <[email protected]> Cr-Commit-Position: refs/heads/main@{#1379353} -- wpt-commits: a525424ff744bca3cb7e11c8aa19127c95a60cb0 wpt-pr: 49013
The first attempt at orientation metadata was paused due to a lack of agreement about the best way to represent it. This has been partly resolved now that a representation for color space (#47) has been selected.
Background:
VideoFrame
s have rotation and flip properties (together "orientation") that describe the transformation from the raw pixels produced fromreadTo()
to the intended rendering.flipY
/mirrored
flag, or equivalently the EXIF orientation tag which encodes a rotation and any flips in a single number. Some implementations don't consider flips at all (flips are rare except as a hardcoded parameter of texture upload).CanvasImageSource
representation (createImageBitmap(videoFrame) Semantics #159). Exposing these properties remains necessary for applications to correctly interpretreadTo()
and to configurenew VideoFrame(BufferSource)
frames. (In theory the implementation could reorient thereadTo()
data to avoid the problem, but Chrome's implementation does not currently do so.)visibleRect
, and display size.Open questions:
kOriginTopLeft
,kOriginLeftTop
, ..., which seems like a reasonable approach (perhaps we could use eg.origin = "left-top"
.) It is ambiguous about row vs column ordering but errors there are likely to be obvious.visibleRect
should be the same.CanvasImageSource
uses only care about the display size, so I think that should be the rotated version. (Note: this would require a tweak to our definition of the cropping constructor.)The text was updated successfully, but these errors were encountered: