<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
</head>
<body bgcolor="#ffffff" text="#000000">
Hi there,<br>
<br>
First of all, sorry for my English I'm not a native english speaker.<br>
<br>
I need to develop and application witch does 3 tasks with oggs files :<br>
1/ chain 2 ogg files <br>
2/ extract a part from an ogg file<br>
3/ add silence between two chained oggs files. <br>
<br>
Basically, <br>
- 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.<br>
- For the 2nd one I found the tools oggz and "oggz-chop" command does
it. <br>
- For the last task I'm trying to use the liboggz 0.9.9 Write API. <br>
<br>
Here is the code of my application to write silence in an ogg file : <br>
<br>
------------------------------------------------------------------------------------------------<br>
<i>static long serialno;<br>
static ogg_int64_t granulepos = 0;<br>
static ogg_int64_t packetno = 0;</i><br>
------------------------------------------------------------------------------------------------<br>
<i>static int oggzHungry(OGGZ * oggz, int empty, void * user_data)<br>
{<br>
ogg_packet op;<br>
//unsigned char buf[1];<br>
//buf[0] = 'A' + (int)packetno;<br>
unsigned char buf[2];<br>
buf[0] = 0;<br>
buf[1] = 0;<br>
memset(&op, 0, sizeof(ogg_packet));<br>
<br>
op.packet = buf;<br>
op.bytes = 2;<br>
//op.bytes = 1;<br>
op.granulepos = granulepos;<br>
op.packetno = packetno;<br>
<br>
if (packetno == 0) op.b_o_s = 1;<br>
else op.b_o_s = 0;<br>
<br>
if (packetno == 9) op.e_o_s = 1;<br>
else op.e_o_s = 0;<br>
<br>
int ret = oggz_write_feed (oggz, &op, serialno, OGGZ_FLUSH_AFTER,
NULL);<br>
<br>
switch (ret){<br>
castatic long serialno;<br>
static ogg_int64_t granulepos = 0;<br>
static ogg_int64_t packetno = 0;<br>
<br>
static int oggzHungry(OGGZ * oggz, int empty, void * user_data)<br>
{<br>
/* Create a fake packet */ <br>
ogg_packet op;<br>
unsigned char buf[2];<br>
buf[0] = 0;<br>
buf[1] = 0;<br>
memset(&op, 0, sizeof(ogg_packet));<br>
<br>
op.packet = buf;<br>
op.bytes = 2;<br>
op.granulepos = granulepos;<br>
op.packetno = packetno;<br>
<br>
if (packetno == 0) op.b_o_s = 1;<br>
else op.b_o_s = 0;<br>
<br>
if (packetno == 9) op.e_o_s = 1;<br>
else op.e_o_s = 0;<br>
<br>
int ret = oggz_write_feed (oggz, &op, serialno, OGGZ_FLUSH_BEFORE
| OGGZ_FLUSH_AFTER, NULL);<br>
<br>
switch (ret){<br>
...LOG ERRORS...<br>
}<br>
<br>
granulepos += 100;<br>
packetno++;<br>
<br>
return 0;<br>
}<br>
<br>
granulepos += 100;<br>
packetno++;<br>
<br>
return 0;<br>
}</i><br>
------------------------------------------------------------------------------------------------<br>
<i>int<br>
main (int argc, char * argv[])<br>
{<br>
int ret;<br>
long n;<br>
OGGZ* _fOggz;</i><i><br>
<br>
_fOggz = oggz_open("./fic/final.ogg", OGGZ_WRITE);<br>
if (!_fOggz)<br>
</i><i>...LOG ERRORS...<br>
<br>
serialno = oggz_serialno_new (_fOggz);<br>
ogg_int64_t granulepos = 0;<br>
ogg_int64_t packetno = 0;<br>
<br>
if (oggz_write_set_hungry_callback (_fOggz, oggzHungry, 1, NULL) ==
-1) <br>
</i><i>...LOG ERRORS...<br>
<br>
while ((n = oggz_write (_fOggz, 32)) > 0);<br>
<br>
oggz_close(_fOggz);<br>
}</i><br>
------------------------------------------------------------------------------------------------<br>
<br>
I retrieve a new ogg file final.ogg but I can't read it. <br>
If I do an ogg-z validate I have : Terminal header page has non-zero
granulepos<i><br>
</i><br>
I got 2 questions :<br>
1. Am I doing something wrong about the 1st 2 tasks<br>
2. any help about task 3 would be appreciated ! (Explanations, solution
or lead) <br>
<br>
if you need further informations, just ask.<br>
<br>
Regards, Paul
</body>
</html>