-->

Convert wav to ogg on app engine (or in javascript

2020-08-01 06:29发布

问题:

I've built a little app engine app that lets users upload short recordings. Some of the recordings are done in-browser with https://github.com/mattdiamond/Recorderjs, which creates wav files. To save space, I'd like to convert those to ogg before writing them to the app engine datastore, so that I use less of my outgoing bandwidth when I play the audio recordings back to users.

How can I do this? I googled around, and apparently there's a command line tool called oggenc that encodes to ogg -- but I'm pretty sure I can't install that (or, even if I could install it, make calls to it) on app engine.

I found a similar question at Encode audio from getUserMedia() to a .OGG in JavaScript -- this links to https://github.com/jpemartins/speex.js, a project that looks like it might eventually be able to convert from wav to ogg in javascript (which would be great), but, as far as I can tell, does not do so at the moment. At https://github.com/jpemartins/speex.js/issues/4 the authors mentions that WAV -> ... -> OGG is not yet possible.

What else should I try?

Edit: My app engine code is written in Python, so another possibility would be to do the conversion there, with a python module that can convert wav to ogg. I think http://pymedia.org/ can do this, but I'd have to somehow install it on app engine -- is that possible?

回答1:

Pymedia isn't pure python so you won't be able to use it on app engine.

You probably want to build something on Compute Engine to do this.



回答2:

Provided it's possible to replace Matt Diamond's recorderjs with its fork, chris-rudmin/Recorderjs (demo page) in AppEngine, this should be feasible. Or first encode to WAV and use opusenc.js (demo page), which is an Emscripten port of the Opusenc tool, to convert a temporary WAV file to Ogg-Opus client side.