diff options
author | Paul B Mahol <onemda@gmail.com> | 2021-10-13 12:12:35 +0200 |
---|---|---|
committer | Paul B Mahol <onemda@gmail.com> | 2021-10-13 12:14:39 +0200 |
commit | 13141339c1df58b92976e509396a265e7262000c (patch) | |
tree | 7eecc37a72fee3744fe0ed5a770df69fc00f3ea1 | |
parent | 6384175d8c33989814f3a5ec9aeb54f1025044b6 (diff) | |
download | ffmpeg-13141339c1df58b92976e509396a265e7262000c.tar.gz |
avformat/dhav: make duration extraction more robust
-rw-r--r-- | libavformat/dhav.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/libavformat/dhav.c b/libavformat/dhav.c index 4d45a258d8..b6bb25204c 100644 --- a/libavformat/dhav.c +++ b/libavformat/dhav.c @@ -239,16 +239,18 @@ static int64_t get_duration(AVFormatContext *s) return 0; avio_seek(s->pb, avio_size(s->pb) - 8, SEEK_SET); - if (avio_rl32(s->pb) == MKTAG('d','h','a','v')) { - int seek_back = avio_rl32(s->pb); - - avio_seek(s->pb, -seek_back, SEEK_CUR); - read_chunk(s); - get_timeinfo(dhav->date, &timeinfo); - end = av_timegm(&timeinfo) * 1000LL; - } else { - avio_seek(s->pb, start_pos, SEEK_SET); - return 0; + while (avio_tell(s->pb) > 12) { + if (avio_rl32(s->pb) == MKTAG('d','h','a','v')) { + int seek_back = avio_rl32(s->pb); + + avio_seek(s->pb, -seek_back, SEEK_CUR); + read_chunk(s); + get_timeinfo(dhav->date, &timeinfo); + end = av_timegm(&timeinfo) * 1000LL; + break; + } else { + avio_seek(s->pb, -12, SEEK_CUR); + } } avio_seek(s->pb, start_pos, SEEK_SET); |