beatsaver-laravel
beatsaver-laravel copied to clipboard
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.
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.
There are OGG decoders in pure JavaScript we can use for Safari
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.
That path would be at https://github.com/elliotttate/beatsaver-laravel/blob/e3202c3c87a19bdff4ba24626ab6b1c5ca94e858/app/SongComposer.php#L156
- Extract audio file from ZIP
- Saving the audio file to a tmp path
- 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.
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.
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