changeset 454:7fa377b2f533 libavformat

export pts if available
author michael
date Tue, 27 Apr 2004 03:35:14 +0000
parents a699cf5c703d
children e5174af0f52f
files ogg.c
diffstat 1 files changed, 4 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/ogg.c	Tue Apr 27 02:55:05 2004 +0000
+++ b/ogg.c	Tue Apr 27 03:35:14 2004 +0000
@@ -172,6 +172,7 @@
     int i;
      
     avfcontext->ctx_flags |= AVFMTCTX_NOHEADER;
+    av_set_pts_info(avfcontext, 60, 1, AV_TIME_BASE);
      
     ogg_sync_init(&context->oy) ;
     buf = ogg_sync_buffer(&context->oy, DECODER_BUFFER_SIZE) ;
@@ -218,6 +219,9 @@
 	return -EIO ;
     pkt->stream_index = 0 ;
     memcpy(pkt->data, op.packet, op.bytes);
+    if(avfcontext->streams[0]->codec.sample_rate && op.granulepos!=-1)
+        pkt->pts= av_rescale(op.granulepos, AV_TIME_BASE, avfcontext->streams[0]->codec.sample_rate);
+//    printf("%lld %d %d\n", pkt->pts, (int)op.granulepos, avfcontext->streams[0]->codec.sample_rate);
 
     return op.bytes;
 }