[Vorbis-dev] Missing audio when converting PCM to Ogg

R.L. Horn lists at eastcheap.org
Wed Oct 23 20:04:49 PDT 2013


On Tue, 22 Oct 2013, Ilya Ganelin wrote:

> I still have a small issue in that a small amount of the audio is
> clipped at the start of the stream.

Be sure that you flush the stream after passing the headers and before 
the coding loop:

     vorbis_analysis_headerout(&vd,&vc,&header,&header_comm,&header_code);
     ogg_stream_packetin(&os,&header); /* automatically placed in its own
                                          page */
     ogg_stream_packetin(&os,&header_comm);
     ogg_stream_packetin(&os,&header_code);

     /* This ensures the actual
      * audio data will start on a new page, as per spec
      */
     for(;;) {
       int result=ogg_stream_flush(&os,&og);
       if(result==0)break;
       fwrite(og.header,1,og.header_len,stdout);
       fwrite(og.body,1,og.body_len,stdout);
     }

Note that encoder_example.c actually uses "while(!eos)" here, but that 
only works because eos was initialized to zero (i.e. !eos always evaluates 
as true).


More information about the Vorbis-dev mailing list