diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2013-03-19 13:06:08 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2013-03-19 13:09:52 +0100 |
commit | 8d0da20ca6c7bee4f4029d2a3449fb707c9446ef (patch) | |
tree | 51d8d6f7e1fc90a0913efc4cc5650b88fa052599 /libavformat/avidec.c | |
parent | 4d16ba2dd87868bdf02b4c4d35719fb551685b22 (diff) | |
download | ffmpeg-8d0da20ca6c7bee4f4029d2a3449fb707c9446ef.tar.gz |
avidec: fix duration and bitrate of truncated files
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/avidec.c')
-rw-r--r-- | libavformat/avidec.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/libavformat/avidec.c b/libavformat/avidec.c index f648f4f019..f6eb71ec0f 100644 --- a/libavformat/avidec.c +++ b/libavformat/avidec.c @@ -62,6 +62,7 @@ typedef struct { int64_t riff_end; int64_t movi_end; int64_t fsize; + int64_t io_fsize; int64_t movi_list; int64_t last_pkt_pos; int index_loaded; @@ -373,7 +374,7 @@ static int avi_read_header(AVFormatContext *s) av_log(avi, AV_LOG_DEBUG, "use odml:%d\n", avi->use_odml); - avi->fsize = avio_size(pb); + avi->io_fsize = avi->fsize = avio_size(pb); if(avi->fsize<=0 || avi->fsize < avi->riff_end) avi->fsize= avi->riff_end == 8 ? INT64_MAX : avi->riff_end; @@ -569,8 +570,13 @@ static int avi_read_header(AVFormatContext *s) default: av_log(s, AV_LOG_INFO, "unknown stream type %X\n", tag1); } - if(ast->sample_size == 0) + if(ast->sample_size == 0) { st->duration = st->nb_frames; + if (st->duration > 0 && avi->io_fsize > 0 && avi->riff_end > avi->io_fsize) { + av_log(s, AV_LOG_DEBUG, "File is truncated adjusting duration\n"); + st->duration = av_rescale(st->duration, avi->io_fsize, avi->riff_end); + } + } ast->frame_offset= ast->cum_len; avio_skip(pb, size - 12 * 4); break; |