Oggz use

Paul BOUTIN <[email protected]>
Newsgroups gmane.comp.multimedia.ogg.vorbis.devel
Message-ID <[email protected]>
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

_______________________________________________
Vorbis-dev mailing list
[email protected]
http://lists.xiph.org/mailman/listinfo/vorbis-dev
final.ogg (application/octet-stream, 300 B) - not displayed
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.