hackclub / sinerider

💖 A game about love and graphing, built by teenagers.
https://sinerider.com
GNU Affero General Public License v3.0
548 stars 46 forks source link

Example conversion of mp3 -> ogg #544

Closed maxwofford closed 11 months ago

maxwofford commented 1 year ago

This shows an example of converting our mp3 files to ogg. In Chrome, FF, Edge, & Opera, this will shrink the load of media assets from ~30MB to ~12MB. With a throttled download this reduced page load from 30s to 12 sec.

Screenshot 2023-05-08 at 17 52 13 Screenshot 2023-05-08 at 18 02 17

It also documents the process of converting audio so future assets can be compressed the same way.

vercel[bot] commented 1 year ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
sinerider ✅ Ready (Inspect) Visit Preview May 8, 2023 10:08pm
maxwofford commented 1 year ago

Ah, i just remembered https://github.com/hackclub/sinerider/pull/482 is a thing. @JosiasAurel – want to make a combined PR that includes all the audio files with graceful fallback? This PR doesn't include everything. I'd also love to see documentation on how the current assets were created. It's funny to me that the source files are in mp3, which is lossy.

polytroper commented 11 months ago

Closing for now since Safari does not support OGG. Currently, MP3 is the only universally-accepted compressed audio format. In a perfect world we would detect browser and load OGG on anything non-Safari but right now we are but simple folk of humble means.

maxwofford commented 11 months ago

@polytroper check out the code! This already checks to see if we're in a browser that doesn't support it and falls back to mp3. Nothing custom either, Howler.js, the library we're using for audio has this detection built in!