[opus] library for creating Opus files?

Tony yellowjacketlite at gmail.com
Mon Feb 23 12:39:40 PST 2015

It appears as though liboggz could be useful, as I think I only need to

// rough code, some details and error checking removed brevity

oggz = oggz_open (outputFilename, OGGZ_WRITE);
serialno = oggz_serialno_new (oggz);

// build/write Opus header 'frame' here...

// TODO: not quite sure how to do this yet, but I
// TODO: should be able to use openenc's code for help

// now write the opus frames to ogg file...

ogg_packet op;

while (GetNextOpusFrame(&myData, ...))
  op.packet = myData;
  op.bytes = myDataLength;
  op.granulepos = ???; // TODO: need to investigate this one a bit more
  op.packetno = packetno++;

  // TODO:  add code to set op.b_o_s or op.e_o_s as needed

  oggz_write_feed (oggz, &op, serialno, OGGZ_FLUSH_AFTER, NULL);

 while ((n = oggz_write (oggz, /* TODO: add code to determine length */
length)) > 0);

oggz_close (oggz);

FWIW, in my scenario it might make a bit more sense to use the 'hungry
mode' (callbacks) of liboggz rather than the brute force method shown above.

On Mon, Feb 23, 2015 at 3:05 PM, Ralph Giles <giles at thaumas.net> wrote:

> On 23/02/15 10:30 AM, Tony wrote:
> > I __think__ opus-tools' opusenc has code which can be used as a
> > template/sample for how to create an .Ogg file with Opus content.  As
> > expected, it makes use of libopus and libogg.
> Sadly that's the best option currently. As you say it's a bit
> complicated, although oggenc has a lot of extra support for controlling
> encoder options you wouldn't need if you've already got compressed frames.
> I keep hoping someone will contribute write support to libopusfile, but
> until then copying that code is your best bet. You might also check
> https://tools.ietf.org/html/draft-ietf-codec-oggopus which describes the
> file format. Feedback on the draft from implementors is welcome.
>  -r

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.xiph.org/pipermail/opus/attachments/20150223/32534c0d/attachment.htm 

More information about the opus mailing list