1

Starting off I have this gif from google images:

enter image description here

Then I convert the blue to transparency:

convert octopus.gif -transparent "#00AEFF" octopus-transparent.gif

Now I have this (note glitchiness has already started to appear)

enter image description here

Now for the grand finale, I convert it to webm:

convert octopus-transparent.gif tmp%03d.png

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

See the following screenshot. It is still transparent, but the sizing is no longer steady, and frankly it's starting to look a little creepy:

enter image description here

I don't really know much about video codecs and I've just got this far with others' help. I'd appreciate advice as to how I can change these commands to avoid the glitches.

max pleaner
  • 26,189
  • 9
  • 66
  • 118
  • 1
    Your problem is that you use GIF disposal mode 1 you should force/use 2 or 3 instead see duplicate: [How to fix .gif with corrupted alpha channel (stuck pixels) collected with Graphicsmagick?](http://stackoverflow.com/a/43316830/2521214) the `-dispose background` in the accepted answer here does exactly that however :) – Spektre Apr 11 '17 at 07:42

1 Answers1

3

Your problem may be due to unequal sized frames from an optimization, so add -coalesce to your command, so that it is

convert octopus.gif -coalesce -fuzz 25% -transparent "#00AEEF" miff:- | convert -dispose background - octopus-transparent.gif

If you just want to save as gif again, you can add -layer optimize before saving. But if you want to output to webm, you may need to avoid the -layers optimize.

Also you do not have constant blue color, so you need -fuzz.

The pipe to convert allows one to set the dispose method. It won't work inline in the first convert, since it needs be be set right after reading the input and thus will pickup the blue background rather than the transparent.

What is your IM version? Perhaps you need an upgrade. I get this using IM 6.9.8.3 Q16:

enter image description here

fmw42
  • 46,825
  • 10
  • 62
  • 80