[opus] How to wrap Opus data in an Ogg stream?

Mark Harris mark.hsj at gmail.com
Wed Oct 14 10:17:59 PDT 2015


On Wed, Oct 14, 2015 at 9:11 AM, Daniel Armyr <daniel at armyr.se> wrote:
> Thanks for a very quick and very good answer. Let me just double-check one thing:
>
>> To put multiple Ogg Opus packets in an Ogg page, all you need to do is
>> start a new segment for each Ogg Opus packet.  There can be up to 255
>> segments per page.  For details, see the Ogg specification:
>> https://tools.ietf.org/html/rfc3533
>
> So do I understand it correctly that a decoder will interpret a page that contains multiple segments, each less than 255 bytes as a set of opus packages, each with the length determined by the specified segment length?

Yes, although the first two packets in the stream are header packets
(id header and comment header), which must be alone on the page.  All
packets after that are Ogg Opus audio packets which can be packed up
to 255 per page if they are each less than 255 bytes.

>
> And just to be absolutely certain: If I happen to have opus packets that are more than 255 bytes long, will a decoder stitch together any segment that is of length 255 with whatever comes next and then decode this as a single opus packet?

Yes.

If you use the ogg library then it will take care of all of that for you.

 - Mark


More information about the opus mailing list