Skip to content
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

Support transparency / alpha by encoding stream #19

Closed
akre54 opened this issue May 16, 2023 · 8 comments
Closed

Support transparency / alpha by encoding stream #19

akre54 opened this issue May 16, 2023 · 8 comments
Labels
enhancement New feature or request

Comments

@akre54
Copy link

akre54 commented May 16, 2023

Hi there - I'm trying to use this library to encode a VideoFrame sequence with alpha to the container (ref #9). I see that it should be possible to write an alpha channel to VP8 because WebMWriter does it, using BlockAdditions / BlockAdditional. Would it be feasible to add to this library?

Thanks for the great work!

@Vanilagy
Copy link
Owner

Vanilagy commented May 16, 2023

This library already has alpha support! Look at the muxer config definition. The problem is that VideoEncoder, at least in Chromium, doesn't support alpha video encoding. Or was that not what you were asking?

I have yet to test this library's alpha capability, even though I added it, since VideoEncoder is holding me back.

@Vanilagy Vanilagy added the enhancement New feature or request label May 16, 2023
@akre54
Copy link
Author

akre54 commented May 16, 2023

I guess I'm not familiar enough with what parts live where, but yes that does seem to be what I'm asking. It looks like WebMWriter doesn't use VideoEncoder but is able to get alpha channel output. Is there a hackaround for this, or would it be possible to shim the webcodecs api? (say, with an emscripten port of vp9) or is this a pipe dream? Thanks for your help here

@akre54
Copy link
Author

akre54 commented May 16, 2023

Could I, say, pass a Uint8Array to muxer.addVideoChunk, or is VideoEncoder doing something very complicated here?

@Vanilagy
Copy link
Owner

Vanilagy commented May 16, 2023

I see! Yes, if you encode the frames yourself, you could use a WASM port of VP9 to encode with an alpha channel. This library has the .addVideoChunkRaw method for this usecase! You simply pass it a Uint8Array and some metadata.

@akre54
Copy link
Author

akre54 commented May 16, 2023

Oh amazing. Let me give that a shot

@Vanilagy
Copy link
Owner

Any updates? Can I close this issue, or do you still need help with something?

@akre54
Copy link
Author

akre54 commented May 24, 2023

Nope! I ended up using WebM Writer directly, but hoping they'll add alpha support to the codecs soon.

Thanks for your help

@akre54 akre54 closed this as completed May 24, 2023
@galipmedia
Copy link

I am trying to do the same thing. In webm-muxer it didn't fail but the file didn't work. When I tried WebM Writer it rendered my pixi text animations really terribly with a lot of artifacts. I also can't wait for webcodecs to support alpha :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants