PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0
Showing posts with label phaser-framework. Show all posts
Showing posts with label phaser-framework. Show all posts

Sunday, July 17, 2022

[FIXED] How can I convert gif to webm preserving alpha channel?

 July 17, 2022     alpha, gif, linux, phaser-framework, webm     No comments   

Issue

To start out with I have this gif I got from Google Images which has a transparent alpha channel.

Here is the original gif (open it in a new tab to see the transparency):

enter image description here

Here is a recording of it playing on my screen in case it doesn't display right in the browser:

enter image description here

Then I run the following script to convert it to webm, which is what I need for the game framework I'm using.

avconv -f gif img.gif img.webm

However it doesn't maintain the transparency. Here is with an overlay of a properly transparent webm (the water, taken from https://phaser.io/examples/v2/video/alpha-webm)

enter image description here

The white box shouldn't be appearing around the gem.


Solution

First convert the gif to png frames:

convert img.gif img%03d.png

Then combine them into a webm with this command (I had to get outside help on this):

ffmpeg -framerate 25 -f image2 -i ./img%03d.png -c:v libvpx -pix_fmt yuva420p img.webm

enter image description here



Answered By - max pleaner
Answer Checked By - Mildred Charles (PHPFixing Admin)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Older Posts Home

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
All Comments
Atom
All Comments

Copyright © PHPFixing