oggdec:Correct duration
authorjan gerber <j@v2v.cc>
Sat, 7 May 2011 13:31:04 +0000 (15:31 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Sat, 7 May 2011 14:21:55 +0000 (16:21 +0200)
Based on a patch by Reimar Döffinger.
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavformat/oggdec.c

index 29e4907..43af23d 100644 (file)
@@ -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;
 }