bluesky-social / social-app

The Bluesky Social application for Web, iOS, and Android
https://bsky.app
MIT License
8.29k stars 1.11k forks source link

Animated WebP support (not WebM) like Tumblr #5519

Open TheShankar opened 5 days ago

TheShankar commented 5 days ago

Is your feature request related to a problem? Please describe. When uploading Gifs to Bluesky, they get converted to video files (MP4). This leads to usually an increase in file-size and a loss of quality. This is specially significant in Low-Frame-Rate/Low-Resolution scenarios, like Pixel Art, Flat-Style Presentations, Small Meme Loops.

Describe the solution you'd like 1) Shorter gifs upload to Bluesky get converted to WebP animations, not MP4 videos. 2) Animated WebP files uploaded to Bluesky reproduce correctly.

Context WebP files can be animated in a similar style as GIFs: Individual images/frames are packed into the same WebP, and can be played at different durations. Like GIFs.

(these are not WebM files, by the way, here is a sample... Right Click to Save as and see the format): https://mathiasbynens.be/demo/animated-webp https://www.tumblr.com/soulspark/735088620300599297

All Browsers (that matter) fully support it now: https://caniuse.com/?search=webp

Describe alternatives you've considered Other than pure Gif support, which is not hot for the Web anymore. There is no other similar solution that can deal with Low-Resolution, Low-FrameRate animations. Converting them to MP4 videos is a bad solution for all involved: Bigger file-size, loss of image quality

Additional context This is a similar request to this one: https://github.com/bluesky-social/social-app/issues/1047#issuecomment-1648972795

But decided to make it's own thread so it doesn't get lost in all the Gif discussion.

surfdude29 commented 5 days ago

It might make more sense to skip WebP and go straight to supporting one of the next-gen image formats like AVIF.

The first example WebP animated image, for instance, can be shrunk by more than 50% by converting it to AVIF: e.g. https://ezgif.com/webp-to-avif?url=https://mathiasbynens.be/demo/animated-webp-supported.webp

mary-ext commented 4 days ago

Are there any examples where GIFs are being converted to larger MP4 files?

mary-ext commented 4 days ago

It might make more sense to skip WebP and go straight to supporting one of the next-gen image formats like AVIF.

AVIF only got supported last year for iOS so it doesn't seem feasible for it to be done now.

surfdude29 commented 4 days ago

It might make more sense to skip WebP and go straight to supporting one of the next-gen image formats like AVIF.

AVIF only got supported last year for iOS so it doesn't seem feasible for it to be done now.

(edited)

It's true that support for animated AVIF was only added in iOS 16.4 (released March 2023).

However, given how (relatively) quickly many iPhone and iPad users update, according to the latest statistics published by Apple, 91% of iPhone users are on iOS 16 or later, and 85% of all iPad users. And those numbers will only have increased since June.

So it's reasonable to assume that 18 months on, the vast majority of iPhone and iPad users are by now on iOS 16.4 or later and would be able to see animated AVIF files. Perhaps an MP4 fallback option could be provided for those who are on devices earlier than 16.4.

surfdude29 commented 4 days ago

I was reading some more about this and stumbled on this GitHub comment which seems relevant:

As someone who works for CDN with animation conversion feature: animated WebP is bad. We would prefer not to use it.

The animated WebP format has been designed to be conceptually similar to GIF, and work for the same use-cases that GIF does, but this made it inherit GIF's weaknesses. Content that makes GIF sizes balloon typically also compresses poorly in WebP. Both are especially inefficient for short video clips with camera motion — a use-case handled better even by ancient codecs like MPEG-1. WebP often fails to meaningfully reduce GIF file sizes, and can even end up making files larger than GIF.