aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2014-11-25 01:56:05 +0100
committerMichael Niedermayer <michaelni@gmx.at>2014-11-25 01:56:05 +0100
commitb83beb131f0d3fdb2d472665f5325f02aeac7d7e (patch)
tree98b6ff4a93d05a92d97c416ed2796c03616d4497
parent172d22a071b5ba932d365ec5e133bf387f5076ed (diff)
parent40665d27e38e6a2f65037878202bd1a398c7683e (diff)
downloadffmpeg-b83beb131f0d3fdb2d472665f5325f02aeac7d7e.tar.gz
Merge commit '40665d27e38e6a2f65037878202bd1a398c7683e'
* commit '40665d27e38e6a2f65037878202bd1a398c7683e': flvdec: Document how the duration is retrieved at the end of the file Conflicts: libavformat/flvdec.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--libavformat/flvdec.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
index 1c70a72dec..17d1313d60 100644
--- a/libavformat/flvdec.c
+++ b/libavformat/flvdec.c
@@ -885,10 +885,14 @@ skip:
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
+ // previous FLV tag. Use the timestamp of its payload as duration.
int64_t fsize = avio_size(s->pb);
retry_duration:
avio_seek(s->pb, fsize - 4, SEEK_SET);
size = avio_rb32(s->pb);
+ // Seek to the start of the last FLV tag at position (fsize - 4 - size)
+ // but skip the byte indicating the type.
avio_seek(s->pb, fsize - 3 - size, SEEK_SET);
if (size == avio_rb24(s->pb) + 11) {
uint32_t ts = avio_rb24(s->pb);