aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2006-03-16 17:04:31 +0000
committerMichael Niedermayer <michaelni@gmx.at>2006-03-16 17:04:31 +0000
commitdbdaebe28dac218c965f3cd37a2bc3ad517a7019 (patch)
treedd037e2e1a6a9e73c5d751b29dadf9a9ac497794
parent60a9cc5879696adf46a267f4b5c1508f6d713b39 (diff)
downloadffmpeg-dbdaebe28dac218c965f3cd37a2bc3ad517a7019.tar.gz
extract duration
Originally committed as revision 5171 to svn://svn.ffmpeg.org/ffmpeg/trunk
-rw-r--r--libavformat/flvdec.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
index 5fa3678628..953be09c50 100644
--- a/libavformat/flvdec.c
+++ b/libavformat/flvdec.c
@@ -34,7 +34,7 @@ static int flv_probe(AVProbeData *p)
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 @@ static int flv_read_header(AVFormatContext *s,
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;