[Ffmpeg-cvslog] CVS: ffmpeg/libavformat flvdec.c,1.25,1.26

Michael Niedermayer CVS michael
Thu Mar 16 18:04:33 CET 2006


Update of /cvsroot/ffmpeg/ffmpeg/libavformat
In directory mail:/var2/tmp/cvs-serv10323

Modified Files:
	flvdec.c 
Log Message:
extract duration


Index: flvdec.c
===================================================================
RCS file: /cvsroot/ffmpeg/ffmpeg/libavformat/flvdec.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- flvdec.c	12 Jan 2006 22:43:22 -0000	1.25
+++ flvdec.c	16 Mar 2006 17:04:31 -0000	1.26
@@ -34,7 +34,7 @@
 static int flv_read_header(AVFormatContext *s,
                            AVFormatParameters *ap)
 {
-    int offset, flags;
+    int offset, flags, size;
 
     s->ctx_flags |= AVFMTCTX_NOHEADER; //ok we have a header but theres no fps, codec type, sample_rate, ...
 
@@ -42,6 +42,17 @@
     flags = get_byte(&s->pb);
 
     offset = get_be32(&s->pb);
+
+    if(!url_is_streamed(&s->pb)){
+        const int fsize= url_fsize(&s->pb);
+        url_fseek(&s->pb, fsize-4, SEEK_SET);
+        size= get_be32(&s->pb);
+        url_fseek(&s->pb, fsize-3-size, SEEK_SET);
+        if(size == get_be24(&s->pb) + 11){
+            s->duration= get_be24(&s->pb) * (int64_t)AV_TIME_BASE / 1000;
+        }
+    }
+
     url_fseek(&s->pb, offset, SEEK_SET);
 
     return 0;





More information about the ffmpeg-cvslog mailing list