[opus] How to get started with opus and C++/JavaScript/WebAsm

Emily Bowman silverbacknet at gmail.com
Thu Dec 3 10:10:13 UTC 2020


Small correction, I just realized while re-reading this that where I said
raw Opus packets, I should have said Ogg-encapsulated Opus packets, which
is at least a much simpler format than MP4. Raw packets are useful in some
contexts but more awkward to work with.

- Em

On Thu, Dec 3, 2020 at 12:15 AM Emily Bowman <silverbacknet at gmail.com>
wrote:

> Since everything goes back to the C library anyway (or a variant of it, if
> you use, say, emscripten), you're free to use any language you want to
> interface with the API. Third-parties have created wrappers for a number of
> other languages, like Python, since C is a simple and universal binding.
>
> While most web streams use chunking via DASH these days, which involves
> encapsulating packets in ISO-BMFF (MP4), you're perfectly free to just send
> raw Opus packets sliced up and the decoder will handle them gracefully.
> Even if packets are lost and you have no error correction, the decoding
> will resynchronize within one packet, and sound a lot less ugly than the
> chirps you get with many other codecs. That was a specific design goal of
> the format. The format on disk is exactly identical to the streamed format,
> so just concatenating the received packets is a valid and simple way to
> save to disk.
>
> For a basic example of using the API from C/C++, check out
> https://opus-codec.org/docs/opus_api-1.3.1/group__opus__encoder.html .
> There's a bit of boilerplate to initialize it, but not too much, and from
> there you can broadcast the encoded packets however you like. DASH is much
> more complex, though if you have a library for your platforms of choice
> it'll either support Opus natively or be fairly simple to retrofit in.
>
> -Em
>
> On Wed, Dec 2, 2020 at 5:36 PM Juan Gerardo Ruelas Jr <jruel006 at ucr.edu>
> wrote:
>
>> I am interested in using the opus codec to stream audio files to a mobile
>> app.
>>
>> I have a couple of questions about how to get started?
>>
>>    1. How do I generate opus files programmatically with C++? What
>>    inputs does it need? Is there a special file format because all the
>>    examples I see only have .wav files as inputs.
>>    2. Does opus support chunking? For example, breaking a 24 hour long
>>    audio into a series of sequential smaller files (say 5 seconds long) to
>>    stream them down to a user?
>>    3. Does opus support stitching together opus files? Say, after a user
>>    receives the 5 second long stream, can I programmatically stitch the files
>>    together as they come so as to save the entire 24 hour long audio file for
>>    offline use at a later time?
>>    4. How do you stream these files programmatically? What is the
>>    general approach. Can you do it with node.js? C++? Python? What is most
>>    efficient?
>>
>>    p.s. (when I say audio files I generally mean just voice audio like
>>    in audio books)
>>
>>
>> Thank you for your help, I am honestly confused as to how to get started.
>>
>> - Juan Gerardo Ruelas Jr.
>> _______________________________________________
>> opus mailing list
>> opus at xiph.org
>> http://lists.xiph.org/mailman/listinfo/opus
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.xiph.org/pipermail/opus/attachments/20201203/b509cb03/attachment.html>


More information about the opus mailing list