aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/flvdec.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-08-03 14:39:46 +0200
committerMartin Storsjö <martin@martin.st>2016-01-19 14:24:34 +0200
commit09f4822e4eaf61513b9092414450f3ae920ccd9d (patch)
treedf77e244cb94285a5df20c7ea29b3f50917b05c6 /libavformat/flvdec.c
parent03ef89faf23c4851848208c9fe004cd9ef690cec (diff)
downloadffmpeg-09f4822e4eaf61513b9092414450f3ae920ccd9d.tar.gz
flvdec: perform duration search just once
When loading a truncated flv file, it would previously try to do a seek to the end of every packet read. For some input protocols (such as http), such repeated seek attempts are cripple the reading performance. Signed-off-by: Martin Storsjö <martin@martin.st>
Diffstat (limited to 'libavformat/flvdec.c')
-rw-r--r--libavformat/flvdec.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
index 96504e704d..cf9769a439 100644
--- a/libavformat/flvdec.c
+++ b/libavformat/flvdec.c
@@ -57,6 +57,7 @@ typedef struct FLVContext {
} validate_index[2];
int validate_next;
int validate_count;
+ int searched_for_end;
} FLVContext;
static int flv_probe(AVProbeData *p)
@@ -836,7 +837,8 @@ skip:
// if not streamed and no duration from metadata then seek to end to find
// the duration from the timestamps
- if (s->pb->seekable && (!s->duration || s->duration == AV_NOPTS_VALUE)) {
+ if (s->pb->seekable && (!s->duration || s->duration == AV_NOPTS_VALUE) &&
+ !flv->searched_for_end) {
int size;
const int64_t pos = avio_tell(s->pb);
// Read the last 4 bytes of the file, this should be the size of the
@@ -853,6 +855,7 @@ skip:
s->duration = ts * (int64_t)AV_TIME_BASE / 1000;
}
avio_seek(s->pb, pos, SEEK_SET);
+ flv->searched_for_end = 1;
}
if (is_audio) {