elliotttate / beatsaver-laravel

Rewrite of beatsaver.com (https://github.com/beatsaver/beatsaver) using the laravel framework
https://discord.gg/8B44zqM
MIT License
39 stars 19 forks source link

On upload, convert audio file to AAC and store at https://beatsaver.com/storage/songs/{ID}/preview/{songname}.aac to support Beatsaver Viewer on Safari. #66

Open ngokevin opened 5 years ago

ngokevin commented 5 years ago

The BeatSaver Viewer allows previewing of BeatSaver songs in browser. This works for the most part.

However for iOS / MacOS, Safari does not support OGGs so we need to convert and upload an AAC as an alternative.

https://beatsaver.com/storage/songs/{ID}/preview/{songname}.aac

This issue is for doing this upon upload. Another script will be written separately for retroactively converting songs.

jetbalsa commented 5 years ago

There are OGG decoders in pure JavaScript we can use for Safari

ngokevin commented 5 years ago

It could work (https://github.com/brion/ogv.js/), but we'd rather not have to have another codepath just for Safari since we're running all through Web Audio right now. Easiest and most robust for us would be official support. Alternatively, we could have a one-off server / endpoint convert OGG to AAC/MP3 on the fly, would just have to worry about uptime and pay for the instance.

ngokevin commented 5 years ago

That path would be at https://github.com/elliotttate/beatsaver-laravel/blob/e3202c3c87a19bdff4ba24626ab6b1c5ca94e858/app/SongComposer.php#L156

  1. Extract audio file from ZIP
  2. Saving the audio file to a tmp path
  3. Calling ffmpeg -i tmp/song.ext storagePath/song.aac

I think that would also help the official BeatSaver site to preview audio file without pulling an emscripten library.

ngokevin commented 5 years ago

Considering doing MP3 since Firefox does not support AAC outside an MP4 container. It will be nice to have a preview format that works across all browsers.

sinfuljosh commented 4 years ago

https://github.com/brion/ogv.js/

Wikipedia is able to play ogg using the above. Perhaps it can be used to bypass native iOS browser inability to play ogg