- avccontext = &avfcontext->streams[n]->codec ;
-
- /* begin vorbis specific code */
-
- vorbis_info_init(&vi) ;
-
- /* code copied from libavcodec/oggvorbis.c */
-
- if(oggvorbis_init_encoder(&vi, avccontext) < 0) {
- fprintf(stderr, "ogg_write_header: init_encoder failed") ;
- return -1 ;
- }
-
- vorbis_analysis_init(&vd, &vi) ;
- vorbis_block_init(&vd, &vb) ;
-
- vorbis_comment_init(&vc) ;
- vorbis_comment_add_tag(&vc, "encoder", LIBAVFORMAT_IDENT) ;
- if(*avfcontext->title)
- vorbis_comment_add_tag(&vc, "title", avfcontext->title) ;
-
- vorbis_analysis_headerout(&vd, &vc, &header,
- &header_comm, &header_code) ;
- ogg_stream_packetin(&context->os, &header) ;
- ogg_stream_packetin(&context->os, &header_comm) ;
- ogg_stream_packetin(&context->os, &header_code) ;
-
- vorbis_block_clear(&vb) ;
- vorbis_dsp_clear(&vd) ;
- vorbis_info_clear(&vi) ;
- vorbis_comment_clear(&vc) ;
-
- /* end of vorbis specific code */
-
- context->header_handled = 0 ;
+ AVCodecContext *codec = avfcontext->streams[n]->codec;
+ uint8_t *headers = codec->extradata;
+ int headers_len = codec->extradata_size;
+ uint8_t *header_start[3];
+ int header_len[3];
+ int i, j;
+
+ av_set_pts_info(avfcontext->streams[n], 60, 1, AV_TIME_BASE);
+
+ for(j=1,i=0;i<2;++i, ++j) {
+ header_len[i]=0;
+ while(j<headers_len && headers[j]==0xff) {
+ header_len[i]+=0xff;
+ ++j;
+ }
+ header_len[i]+=headers[j];
+ }
+ header_len[2]=headers_len-header_len[0]-header_len[1]-j;
+ headers+=j;
+ header_start[0] = headers;
+ header_start[1] = header_start[0] + header_len[0];
+ header_start[2] = header_start[1] + header_len[1];
+
+ for(i=0; i < 3; ++i){
+ op->bytes = header_len[i];
+
+ op->packet= header_start[i];
+ op->b_o_s= op->packetno==0;
+
+ ogg_stream_packetin(&context->os, op);
+
+ op->packetno++; //FIXME multiple streams
+ }
+
+ context->header_handled = 0 ;