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

Add support for alpha channel (transparency) #177

Open
EliteMasterEric opened this issue Aug 6, 2022 · 4 comments
Open

Add support for alpha channel (transparency) #177

EliteMasterEric opened this issue Aug 6, 2022 · 4 comments
Labels
enhancement New feature or request
Projects

Comments

@EliteMasterEric
Copy link
Collaborator

Certain video file formats (such as WEBM) have support for an alpha color channel. This results in the channels with lower alpha values being rendered with transparency. This would allow any sprites underneath the video to be visible.

See here for more information: https://developer.chrome.com/blog/alpha-transparency-in-chrome-video/

The use case for this is evident and powerful: encoding and playing a transparent video would allow for efficient and performant rendering of elaborate character animations not suited to spritesheets.

There are problems with this, however. The implementation of libvlc currently exports 0xFF for the alpha value regardless of settings. I am investigating alternatives.

@polybiusproxy polybiusproxy added the enhancement New feature or request label Aug 6, 2022
@trayfellow
Copy link
Contributor

hi mastereric

@polybiusproxy polybiusproxy added this to To do in hxCodec via automation Sep 11, 2022
@EliteMasterEric
Copy link
Collaborator Author

Writing this down for posterity, but previous experimentation revealed that LibVLC 4.0 (currently an unstable version) has support for transparent decoding, but ONLY for the proprietary HAP codec. This has several downsides, notably poor compatibility with LibVLC 3.0 (currently in use) and very large file sizes (approximately 10x the size of an equivalent MP4 video).

For comparison, the other file formats which support transparency are:

  • GIF: Very high file sizes and poor color quality.
  • APNG: Doesn't play animation on LibVLC 3.

@EliteMasterEric
Copy link
Collaborator Author

Correction, HAP codec is compatible with LibVLC 3.0.

HAP creation script:

ffmpeg -framerate 24 -pattern_type sequence -i Week_7_cutscene_assets%04d.png -c:v hap -format hap_alpha output1.mov

@nanjizal
Copy link

Green screen is perfectly implementable in JS, by replacing a specific pixel color at run time. Jigsawx had webcam or video running in haxe flash reasonable well. There are certainly options using something similar to a double buffering to apply a mask ( perhaps composite with black and white image ), mask or greenscreen replace pixel options. Stuff like svg masks work well. In terms of old flash, we built a 3D website with papervision3D that had video people talking in 2D with transparent backgrounds within a 3D enviroment years ago. Therefore there must solutions even if the implementation is on the haxe not the hardware extern side. I am sure a shader could easily be used to achieve green screen or use a black and white video as a mask for a colour one.

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
hxCodec
To do
Development

No branches or pull requests

4 participants