diff options
author | Baptiste Coudurier <baptiste.coudurier@gmail.com> | 2006-07-08 12:58:50 +0000 |
---|---|---|
committer | Baptiste Coudurier <baptiste.coudurier@gmail.com> | 2006-07-08 12:58:50 +0000 |
commit | 1f1890c7543064db40e00a770921d5b080c91685 (patch) | |
tree | a26573f4d19df084601b7313239864f62aa0ef03 /libavformat | |
parent | b72708f8f3af8ed41ce89a6c14f953cf59cac413 (diff) | |
download | ffmpeg-1f1890c7543064db40e00a770921d5b080c91685.tar.gz |
better handling of partial files
Originally committed as revision 5668 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat')
-rw-r--r-- | libavformat/mov.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/libavformat/mov.c b/libavformat/mov.c index 0df006e8f0..7987a5fc51 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -1750,9 +1750,9 @@ static void mov_build_index(MOVContext *mov, AVStream *st) assert(chunk_duration % sc->time_rate == 0); current_dts += chunk_duration / sc->time_rate; } - /* adjust sample count to chunk count */ - sc->sample_count = sc->chunk_count; } + /* adjust sample count to avindex entries */ + sc->sample_count = st->nb_index_entries; } static int mov_read_header(AVFormatContext *s, AVFormatParameters *ap) @@ -1842,11 +1842,12 @@ static int mov_read_packet(AVFormatContext *s, AVPacket *pkt) return -1; /* must be done just before reading, to avoid infinite loop on sample */ sc->current_sample++; - url_fseek(&s->pb, sample->pos, SEEK_SET); - if (av_get_packet(&s->pb, pkt, sample->size) <= 0) { - av_log(s, AV_LOG_ERROR, "stream %d, error reading packet at offset 0x%llx, maybe partial file\n", sc->ffindex, sample->pos); + if (sample->pos >= url_fsize(&s->pb)) { + av_log(mov->fc, AV_LOG_ERROR, "stream %d, offset 0x%llx: partial file\n", sc->ffindex, sample->pos); return -1; } + url_fseek(&s->pb, sample->pos, SEEK_SET); + av_get_packet(&s->pb, pkt, sample->size); pkt->stream_index = sc->ffindex; pkt->dts = sample->timestamp; if (sc->ctts_data) { |