From 5901cd6236d97b34fe59a47ba0fd6da8f647d1f1 Mon Sep 17 00:00:00 2001 From: jan gerber Date: Sat, 7 May 2011 15:31:04 +0200 Subject: [PATCH] =?UTF-8?q?oggdec:Correct=20duration=20Based=20on=20a=20pa?= =?UTF-8?q?tch=20by=20Reimar=20D=C3=B6ffinger.=20Signed-off-by:=20Michael?= =?UTF-8?q?=20Niedermayer=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libavformat/oggdec.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c index 29e4907e86..43af23d284 100644 --- a/libavformat/oggdec.c +++ b/libavformat/oggdec.c @@ -490,6 +490,18 @@ ogg_get_length (AVFormatContext * s) ogg_restore (s, 0); + ogg_save (s); + url_fseek (s->pb, 0, SEEK_SET); + while (!ogg_read_page (s, &i)){ + if (ogg->streams[i].granule != -1 && ogg->streams[i].granule != 0 && + ogg->streams[i].codec) { + s->streams[i]->duration -= + ogg_gptopts (s, i, ogg->streams[i].granule, NULL); + break; + } + } + ogg_restore (s, 0); + return 0; }