diff options
author | Uwe L. Korn <uwelk@xhochy.com> | 2014-11-23 19:36:14 +0100 |
---|---|---|
committer | Martin Storsjö <martin@martin.st> | 2014-11-24 23:34:30 +0200 |
commit | 40665d27e38e6a2f65037878202bd1a398c7683e (patch) | |
tree | adf6f5470985de009269c10342899b698e5b7d91 /libavformat/flvdec.c | |
parent | fe42f94ce1023f9c2f7e86404c60afcee5b078a9 (diff) | |
download | ffmpeg-40665d27e38e6a2f65037878202bd1a398c7683e.tar.gz |
flvdec: Document how the duration is retrieved at the end of the file
Signed-off-by: Martin Storsjö <martin@martin.st>
Diffstat (limited to 'libavformat/flvdec.c')
-rw-r--r-- | libavformat/flvdec.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c index 2d5e50e257..0167d17c70 100644 --- a/libavformat/flvdec.c +++ b/libavformat/flvdec.c @@ -845,9 +845,13 @@ skip: if (s->pb->seekable && (!s->duration || s->duration == AV_NOPTS_VALUE)) { 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. const int64_t fsize = avio_size(s->pb); 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); |