[Ffmpeg-devel] ogg vorbis encode?
Rich Felker
dalias
Tue Aug 16 00:52:03 CEST 2005
On Mon, Aug 15, 2005 at 06:08:23PM -0400, Justin Ruggles wrote:
> hello,
>
> small fix for vorbis pts. after playing around with trying to set the
> time_base to the sample_rate, i found that doing this was much easier
> and more in line with how ogg2.c and the vorbis decoder do things.
> vorbis still has to have the analysis buffer fill up before sending any
> data through, but now it gives the correct time/bitrate once the ogg
> writing starts. one oddity, it always gives a "non monotone timestamp"
> error on the 3rd to last ogg packet, but I can't figure out why...
>
> -justin
> Index: libavcodec/oggvorbis.c
> ===================================================================
> RCS file: /cvsroot/ffmpeg/ffmpeg/libavcodec/oggvorbis.c,v
> retrieving revision 1.19
> diff -u -r1.19 oggvorbis.c
> --- libavcodec/oggvorbis.c 19 May 2005 11:45:10 -0000 1.19
> +++ libavcodec/oggvorbis.c 15 Aug 2005 22:00:20 -0000
> @@ -90,6 +90,7 @@
>
> avccontext->coded_frame= avcodec_alloc_frame();
> avccontext->coded_frame->key_frame= 1;
> + avccontext->time_base= (AVRational){1, AV_TIME_BASE};
>
> return 0 ;
> }
> @@ -140,7 +141,7 @@
> op2->packet = context->buffer + sizeof(ogg_packet);
>
> l= op2->bytes;
> - avccontext->coded_frame->pts= op2->granulepos;
> + avccontext->coded_frame->pts= op2->granulepos * 1000000LL / avccontext->sample_rate;
>
> memcpy(packets, op2->packet, l);
> context->buffer_index -= l + sizeof(ogg_packet);
This is totally wrong. Vorbis has a time base, you just need to
extract it based on the samplerate.
Rich
More information about the ffmpeg-devel
mailing list