beatsaver-laravel icon indicating copy to clipboard operation
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.

Open ngokevin opened this issue 6 years ago • 5 comments

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.

ngokevin avatar Jan 14 '19 16:01 ngokevin

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

jetbalsa avatar Jan 14 '19 20:01 jetbalsa

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 avatar Jan 14 '19 21:01 ngokevin

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 avatar Jan 14 '19 22:01 ngokevin

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.

ngokevin avatar Jan 29 '19 23:01 ngokevin

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

sinfuljosh avatar Feb 14 '20 06:02 sinfuljosh