w3c / webcodecs

WebCodecs is a flexible web API for encoding and decoding audio and video.
https://w3c.github.io/webcodecs/
Other
987 stars 136 forks source link

Encode VideoFrame with alpha #672

Closed akre54 closed 1 year ago

akre54 commented 1 year ago

Hi there - I'm trying to encode / mux a video with alpha (the inverse of #377). I can get an RGBA VideoFrame but the resulting video file doesn't have transparency.

See my renderer code here: https://gist.github.com/akre54/e93ab2ce27999aecb109e38085f2e7a7

I've also tried using the examples from these repos:

https://github.com/w3c/webcodecs/tree/main/samples/video-decode-display https://github.com/tidoust/media-tests/tree/main

Do I understand correctly that encoding with alpha isn't supported in any current browsers? Or is there something I'm missing. Thanks!

Djuffin commented 1 year ago

Chromium doesn't support encoding frames with alpha yet.

akre54 commented 1 year ago

Okay thank you for the fast response. Am I understanding correctly that this is an implementation question rather than a required change to the spec?

Are there any workarounds available, or is this a wontfix?

Djuffin commented 1 year ago

Correct. The spec seems to have all the parts needed, but nobody's implemented yet. https://www.w3.org/TR/webcodecs/#dom-encodedvideochunkmetadata-alphasidedata https://www.w3.org/TR/webcodecs/#dom-videoencoderconfig-alpha

Are there any workarounds available, or is this a wontfix?

I can't think of any workarounds other than manually encoding alpha channel with a separate encoder.

akre54 commented 1 year ago

Okay I'll give that a shot and possibly open a crbug. Thanks for your help