[FFmpeg-cvslog] oggdec: subtract time of first packet only from duration when it is significant

Michael Niedermayer git at videolan.org
Wed Aug 24 23:35:42 CEST 2011


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Wed Aug 24 23:20:09 2011 +0200| [7e7012d0b491453b8de8ca34846f9d48501dc6c5] | committer: Michael Niedermayer

oggdec: subtract time of first packet only from duration when it is significant
this fixes accuracy with normal ogg files while keeping support for ogg files
starting at times different from 0

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=7e7012d0b491453b8de8ca34846f9d48501dc6c5
---

 libavformat/oggdec.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c
index 3d7c87f..e8d4fc5 100644
--- a/libavformat/oggdec.c
+++ b/libavformat/oggdec.c
@@ -493,8 +493,9 @@ static int ogg_get_length(AVFormatContext *s)
         if (ogg->streams[i].granule != -1 && ogg->streams[i].granule != 0 &&
             ogg->streams[i].codec) {
             if(s->streams[i]->duration && s->streams[i]->start_time == AV_NOPTS_VALUE && !ogg->streams[i].got_start){
-                s->streams[i]->duration -=
-                    ogg_gptopts (s, i, ogg->streams[i].granule, NULL);
+                int64_t start= ogg_gptopts (s, i, ogg->streams[i].granule, NULL);
+                if(av_rescale_q(start, s->streams[i]->time_base, AV_TIME_BASE_Q) > AV_TIME_BASE)
+                    s->streams[i]->duration -= start;
                 ogg->streams[i].got_start= 1;
                 streams_left--;
             }



More information about the ffmpeg-cvslog mailing list