]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/flvdec.c
Merge commit '4fd7e63c87226584e60200b82630a6057c0a6663'
[ffmpeg] / libavformat / flvdec.c
index 1c70a72dec1a372d90ade55ba9d7fe955cbefe48..17d1313d60860471f7ebc08d849607564ffd3fcd 100644 (file)
@@ -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);