AnimGIF is a medium
Short, looped silent video clips have become a medium. They're a way to quote, remix and comment on longer videos. They're a way to share jokes and cats' mishaps. AnimGIFs are to videos what Twitter is to blogs.
BTW: I've implemented a more advanced GIF encoder that halves file sizes of GIF videos, but that's still not enough.
The problem is that the video codec powering this medium is horribly outdated and inefficient. Browsers already support better video codecs natively, but due to historical reasons, they're not allowing animGIFs to take advantage of the better technology.
The divide between "animations" and "proper videos" is a false dichotomy and creates needless complexity. Plenty of GIFs are conversions from YouTube and other videos. Websites like gfycat, Twitter and imgur convert GIFs back to H.264 or WebM to save bandwidth. The savings are so huge, that they do it despite the significant complexity and loss of quality caused by the double conversion.
RealPlayer is gone, codecs are not a pain any more
Annoying plug-ins from the '90s have left a long-lasting impression that video codecs must be slow, clunky and could not be played without a special ceremony. It's not true any more.
The latest codecs are not only much more bandwidth-efficient, they can be cheaper to decode as well (thanks to hardware acceleration and ability to seek). There is no reason to keep GIF as the only video codec with special privileges and force faster codecs to have limited usefulness.
What needs to be fixed:
<img src="video">
needs to allow video codecs other than GIF. To preserve characteristics of the medium, it should play the file just like GIFs are played: automatically, looped, without playback controls and without sound.
- Same goes for
background: url(video)
. Websites use "cinemagraph" type of backgrounds increasingly often, but due to shortcomings of GIF and CSS, they have to resort to faking backgrounds using the<video>
element.
- When user opens a URL of a short silent video, the video should start playing automatically, in a loop, and without playback controls obscuring the video.
Popular excuses
But what if people abuse it!?
It doesn't allow anything stupid that isn't allowed already. GIFs can already be obnoxious, cause epilepsy, slow down the browser and waste enormous amounts of bandwidth.
Ads already work around video element limitations by using JavaScript or CSS transitions to animate filmstrips of JPEGs, which looks the same as autoplaying video, but uses much more bandwidth and excessive amounts of memory.
If any limits need to be put in place, they should be enforced using more sensible method than by a threat of wasted bandwidth.
New codecs don't work in all browsers!
We have the <picture>
element now, which allows sources to be selected similarly to <video>
. This way sites can embed H.264, WebM and animGIF with perfect backward compatibility.
If <img>
supports better codecs then websites and optimization proxies will also be able to use HTTP content negotiation to serve the best codec to each browser, while keeping HTML/CSS markup simple and backwards compatible.
What about MNG, APNG and AnimWebP?
They're a faster horse in the world of automobiles. They focus on emulating GIF's primitive approach to video compression with all its downsides, as if GIF was popular because it was inefficient.
GIF format is popular because it works everywhere and has a no-fuss UI. We can easily give good codecs the same no-fuss UI, and they're already far ahead in terms of support than any new "animation" format.
Isn't "proper video" too expensive to use?
There has been a lot of work put into using dedicated hardware, GPUs and SIMD CPU instructions to make decoding of modern codecs fast and energy-efficient. On the other hand GIF is designed for 1980's CPU-bound single-threaded decoding and can't take advantage of any of these techniques.
The result is that your cell phone is likely to be able to play a full-HD H.264 video effortlessly, but will struggle to process the enormous amount of data required to play lower-resolution GIF.
AnimGIFs tend not to have keyframes, which forces browsers to cache decoded frames to be able to seek in the animation (needed to resume animation that was off-screen or in a background tab). This is a significant waste of memory, and that's on top of a 10—fold increase of memory needed to store the (poorly) compressed source data.
On modern hardware GIF is the slowest and most expensive video codec. Can we please allow it to be obsoleted?