bluesky-social / social-app

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

Animated WebP support (not WebM) like Tumblr #5519

Open TheShankar opened 1 month ago

TheShankar commented 1 month 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 1 month 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 1 month ago

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

mary-ext commented 1 month 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 1 month 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 1 month 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.

HeyItsLollie commented 1 month ago

Shorter gifs upload to Bluesky get converted to WebP animations, not MP4 videos.

I have to admit, as an artist who would love to see wider animated WebP support, I see no inherent benefit to transcoding GIF to Web. The cleaner option would be to simply let animated GIFs and WebP images be served as-is. I would very much love to not see animated images be transcoded to video formats though — If I wanted to post a video, I would upload one.

Also a bit perplexed about the claim that Bluesky converts GIFs to MP4s, but only because Bluesky doesn't currently natively support uploading of GIFs. It does support GIFs via Tenor (which isn't the same!), but while there are GIFs that have been posted directly to Bluesky, AFAIK it's only been via third-party clients. Don't tell me Bluesky is already mushing GIFs before we even have a chance to post them!

mary-ext commented 1 month ago

the unfortunate problem with having native Animated WebP/GIF support that isn't turning it into an MP4 is that it would mean having yet another player just to account for the fact that the formats have to be played in an <img> element which doesn't exactly allow control over playback