mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-01-24 13:56:33 +02:00
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>
This commit is contained in:
parent
03ef89faf2
commit
09f4822e4e
@ -57,6 +57,7 @@ typedef struct FLVContext {
|
|||||||
} validate_index[2];
|
} validate_index[2];
|
||||||
int validate_next;
|
int validate_next;
|
||||||
int validate_count;
|
int validate_count;
|
||||||
|
int searched_for_end;
|
||||||
} FLVContext;
|
} FLVContext;
|
||||||
|
|
||||||
static int flv_probe(AVProbeData *p)
|
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
|
// if not streamed and no duration from metadata then seek to end to find
|
||||||
// the duration from the timestamps
|
// 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;
|
int size;
|
||||||
const int64_t pos = avio_tell(s->pb);
|
const int64_t pos = avio_tell(s->pb);
|
||||||
// Read the last 4 bytes of the file, this should be the size of the
|
// 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;
|
s->duration = ts * (int64_t)AV_TIME_BASE / 1000;
|
||||||
}
|
}
|
||||||
avio_seek(s->pb, pos, SEEK_SET);
|
avio_seek(s->pb, pos, SEEK_SET);
|
||||||
|
flv->searched_for_end = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_audio) {
|
if (is_audio) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user