[Vorbis-dev] Oggz use

Paul BOUTIN p.boutin at logosapience.fr
Wed Aug 12 03:53:41 PDT 2009


Hi there,

First of all, sorry for my English I'm not a native english speaker.

I need to develop and application witch does 3 tasks with oggs files :
 1/ chain 2 ogg files
 2/ extract a part from an ogg file
 3/ add silence between two chained oggs files.

Basically,
  - For the 1st task, I think that the best way to chain ogg files is to 
use the "cat" (on linux) or "copy /b" (on windows) command.
  - For the 2nd one I found the tools oggz and "oggz-chop" command does it.
  - For the last task I'm trying to use the liboggz 0.9.9 Write API.

Here is the code of my application to write silence in an ogg file :

------------------------------------------------------------------------------------------------
/static long serialno;
static ogg_int64_t granulepos = 0;
static ogg_int64_t packetno = 0;/
------------------------------------------------------------------------------------------------
/static int oggzHungry(OGGZ * oggz, int empty, void * user_data)
{
  ogg_packet op;
  //unsigned char buf[1];
  //buf[0] = 'A' + (int)packetno;
  unsigned char buf[2];
  buf[0] = 0;
  buf[1] = 0;
  memset(&op, 0, sizeof(ogg_packet));

  op.packet = buf;
  op.bytes = 2;
  //op.bytes = 1;
  op.granulepos = granulepos;
  op.packetno = packetno;

  if (packetno == 0) op.b_o_s = 1;
  else op.b_o_s = 0;

  if (packetno == 9) op.e_o_s = 1;
  else op.e_o_s = 0;

  int ret = oggz_write_feed (oggz, &op, serialno, OGGZ_FLUSH_AFTER, NULL);

  switch (ret){
    castatic long serialno;
static ogg_int64_t granulepos = 0;
static ogg_int64_t packetno = 0;

static int oggzHungry(OGGZ * oggz, int empty, void * user_data)
{
  /*   Create a fake packet */
  ogg_packet op;
  unsigned char buf[2];
  buf[0] = 0;
  buf[1] = 0;
  memset(&op, 0, sizeof(ogg_packet));

  op.packet = buf;
  op.bytes = 2;
  op.granulepos = granulepos;
  op.packetno = packetno;

  if (packetno == 0) op.b_o_s = 1;
  else op.b_o_s = 0;

  if (packetno == 9) op.e_o_s = 1;
  else op.e_o_s = 0;

  int ret = oggz_write_feed (oggz, &op, serialno, OGGZ_FLUSH_BEFORE | 
OGGZ_FLUSH_AFTER, NULL);

  switch (ret){
    ...LOG ERRORS...
 }

  granulepos += 100;
  packetno++;

  return 0;
}

  granulepos += 100;
  packetno++;

  return 0;
}/
------------------------------------------------------------------------------------------------
/int
main (int argc, char * argv[])
{
  int ret;
  long n;
  OGGZ* _fOggz;//
 
  _fOggz = oggz_open("./fic/final.ogg", OGGZ_WRITE);
  if (!_fOggz)
    //...LOG ERRORS...

  serialno = oggz_serialno_new (_fOggz);
  ogg_int64_t granulepos = 0;
  ogg_int64_t packetno = 0;

  if (oggz_write_set_hungry_callback (_fOggz, oggzHungry, 1, NULL) == -1)
    //...LOG ERRORS...

  while ((n = oggz_write (_fOggz, 32)) > 0);

oggz_close(_fOggz);
}/
------------------------------------------------------------------------------------------------

I retrieve a new ogg file final.ogg but I can't read it.
If I do an ogg-z validate I have : Terminal header page has non-zero 
granulepos/
/
I got 2 questions :
1. Am I doing something wrong about the 1st 2 tasks
2. any help about task 3 would be appreciated ! (Explanations, solution 
or lead)

if you need further informations, just ask.

Regards, Paul
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.xiph.org/pipermail/vorbis-dev/attachments/20090812/d1b99216/attachment.htm 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: final.ogg
Type: application/octet-stream
Size: 300 bytes
Desc: not available
Url : http://lists.xiph.org/pipermail/vorbis-dev/attachments/20090812/d1b99216/attachment.obj 


More information about the Vorbis-dev mailing list