0
votes

I have this example of getting the initial header information from Vorbis for Ogg Stream:

ogg_packet header;
ogg_packet header_comm;
ogg_packet header_code;

vorbis_analysis_headerout(&vd,&vc,&header,&header_comm,&header_code);

How can I get this header information from Opus with libopus? There's some information HERE, but I can't figure out how work with it.

1

1 Answers

4
votes

Ogg Opus has only two header packets: the ID header and comment header. See the specification for details on their contents.

If you are reading an Ogg Opus file with the opusfile library, it processes the packets for you (including the header packets). The various functions that you linked to are used to get information from the headers that were processed.

If you are writing an Ogg Opus file, you can use the libopusenc library and it will take care of writing the headers for you. As of version 0.2, the opusenc program in the opus-tools package uses libopusenc. If for some reason you want to format and write the packets yourself using the ogg library directly, you could take a look at the older 0.1.10 version of opusenc, when it did this itself; look for the comment /* Write header */ in opusenc.c and the call to opus_header_to_packet() to format the ID header.