[Ffmpeg-devel] Bugreport: TS demuxer reports wrong pts for AC3 audio

Wolfram Gloger wmglo
Tue Mar 27 16:38:51 CEST 2007


Hi,

> When playing Transport Stream files with one AC3 audio stream in it, the
> reported PTS values for Audio start at 0, and not where they should
> according to the TS/PES packets.
> libavformat reports one Audio/Video frame with PTS=0 each, then
> A_pts=2880 and V_pts=1882151760 on that particular test stream.

That looks to me like the timestamp problem which I reported on
Sunday.  Please try the appended patch, which I consider a workaround
and not really a solution..

Regards,
Wolfram.

diff -Nur -x .svn trunk/libavformat/utils.c ffmpeg-wg/libavformat/utils.c
--- trunk/libavformat/utils.c	2007-03-23 12:25:32.000000000 +0100
+++ ffmpeg-wg/libavformat/utils.c	2007-03-25 15:03:43.000000000 +0200
@@ -1452,7 +1452,7 @@
 #define DURATION_MAX_READ_SIZE 250000
 
 /* only usable for MPEG-PS streams */
-static void av_estimate_timings_from_pts(AVFormatContext *ic, offset_t old_offset)
+static void av_estimate_timings_from_pts(AVFormatContext *ic, offset_t old_offset, const int64_t old_dts[])
 {
     AVPacket pkt1, *pkt = &pkt1;
     AVStream *st;
@@ -1531,9 +1531,11 @@
     fill_all_stream_timings(ic);
 
     url_fseek(&ic->pb, old_offset, SEEK_SET);
+    for(i=0; i<ic->nb_streams; i++)
+        ic->streams[i]->cur_dts = old_dts[i];
 }
 
-static void av_estimate_timings(AVFormatContext *ic, offset_t old_offset)
+static void av_estimate_timings(AVFormatContext *ic, offset_t old_offset, const int64_t old_dts[])
 {
     int64_t file_size;
 
@@ -1551,7 +1553,7 @@
          !strcmp(ic->iformat->name, "mpegts")) &&
         file_size && !ic->pb.is_streamed) {
         /* get accurate estimate from the PTSes */
-        av_estimate_timings_from_pts(ic, old_offset);
+        av_estimate_timings_from_pts(ic, old_offset, old_dts);
     } else if (av_has_timings(ic)) {
         /* at least one components has timings - we use them for all
            the components */
@@ -1652,6 +1654,7 @@
     AVPacket pkt1, *pkt;
     AVPacketList *pktl=NULL, **ppktl;
     int64_t last_dts[MAX_STREAMS];
+    int64_t first_dts[MAX_STREAMS];
     int duration_count[MAX_STREAMS]={0};
     double (*duration_error)[MAX_STD_TIMEBASES];
     offset_t old_offset = url_ftell(&ic->pb);
@@ -1679,7 +1682,7 @@
     }
 
     for(i=0;i<MAX_STREAMS;i++){
-        last_dts[i]= AV_NOPTS_VALUE;
+        first_dts[i]= last_dts[i]= AV_NOPTS_VALUE;
     }
 
     count = 0;
@@ -1781,7 +1784,9 @@
                 duration_count[index]++;
             }
             if(last == AV_NOPTS_VALUE || duration_count[index]<=1)
-                last_dts[pkt->stream_index]= pkt->dts;
+                last_dts[index]= pkt->dts;
+            if(first_dts[index] == AV_NOPTS_VALUE)
+                first_dts[index]= pkt->dts;
         }
         if(st->parser && st->parser->parser->split && !st->codec->extradata){
             int i= st->parser->parser->split(st->codec, pkt->data, pkt->size);




More information about the ffmpeg-devel mailing list