Message ID | 20170602145530.26342-1-daniel.kucera@gmail.com |
---|---|
State | Superseded |
Headers | show |
On Fri, Jun 02, 2017 at 04:55:30PM +0200, Daniel Kucera wrote: > Signed-off-by: Daniel Kucera <daniel.kucera@gmail.com> > --- > libavformat/avio.c | 2 +- > libavformat/aviobuf.c | 18 ++++++++++-------- > libavformat/cache.c | 2 +- > libavformat/file.c | 2 ++ > libavformat/wtvdec.c | 4 ++-- > 5 files changed, 16 insertions(+), 12 deletions(-) breaks: ffmpeg -i subfile,,start,10000,end,400000,,:matrixbench_mpeg2.mpg subfile.avi (infnite loop) [...]
> > breaks: > ffmpeg -i subfile,,start,10000,end,400000,,:matrixbench_mpeg2.mpg subfile.avi > > (infnite loop) > > Where can I get that matrixbench_mpeg2.mpg test file? If I run it against fate-suite/mpeg2/matrixbench_mpeg2.lq1.mpg it works: ./ffmpeg -i subfile,,start,10000,end,400000,,:fate-suite/mpeg2/matrixbench_mpeg2.lq1.mpg subfile.avi ffmpeg version N-86331-gec2a3962af Copyright (c) 2000-2017 the FFmpeg developers built with gcc 6.3.0 (Ubuntu 6.3.0-12ubuntu2) 20170406 configuration: --enable-debug=3 --enable-gpl --enable-libx264 libavutil 55. 63.100 / 55. 63.100 libavcodec 57. 96.101 / 57. 96.101 libavformat 57. 72.101 / 57. 72.101 libavdevice 57. 7.100 / 57. 7.100 libavfilter 6. 90.100 / 6. 90.100 libswscale 4. 7.101 / 4. 7.101 libswresample 2. 8.100 / 2. 8.100 libpostproc 54. 6.100 / 54. 6.100 [mpeg2video @ 0x55a3295e43a0] Invalid frame dimensions 0x0. Last message repeated 9 times Input #0, mpeg, from 'subfile,,start,10000,end,400000,,:fate-suite/mpeg2/matrixbench_mpeg2.lq1.mpg': Duration: 00:00:00.88, start: 0.620000, bitrate: 3545 kb/s Stream #0:0[0x1e0]: Video: mpeg2video (Main), yuv420p(tv, bottom first), 716x236 [SAR 1:1 DAR 179:59], 25 fps, 25 tbr, 90k tbn, 50 tbc Stream mapping: Stream #0:0 -> #0:0 (mpeg2video (native) -> mpeg4 (native)) Press [q] to stop, [?] for help Output #0, avi, to 'subfile.avi': Metadata: ISFT : Lavf57.72.101 Stream #0:0: Video: mpeg4 (FMP4 / 0x34504D46), yuv420p, 716x236 [SAR 1:1 DAR 179:59], q=2-31, 200 kb/s, 25 fps, 25 tbn, 25 tbc Metadata: encoder : Lavc57.96.101 mpeg4 Side data: cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: -1 frame= 13 fps=0.0 q=10.7 Lsize= 73kB time=00:00:00.92 bitrate= 650.1kbits/s speed=33.9x video:67kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 9.237288% S pozdravom / Best regards Daniel Kucera.
2017-06-03 8:58 GMT+02:00 Daniel Kučera <daniel.kucera@gmail.com>: >> >> breaks: >> ffmpeg -i subfile,,start,10000,end,400000,,:matrixbench_mpeg2.mpg subfile.avi >> >> (infnite loop) >> >> > > Where can I get that matrixbench_mpeg2.mpg test file? If I run it > against fate-suite/mpeg2/matrixbench_mpeg2.lq1.mpg it works: > Ok, I've found it, sending updated patch in new email.
diff --git a/libavformat/avio.c b/libavformat/avio.c index 1e79c9dd5c..bf803016b7 100644 --- a/libavformat/avio.c +++ b/libavformat/avio.c @@ -394,7 +394,7 @@ static inline int retry_transfer_wrapper(URLContext *h, uint8_t *buf, av_usleep(1000); } } else if (ret < 1) - return (ret < 0 && ret != AVERROR_EOF) ? ret : len; + return (ret < 0) ? ret : len; if (ret) { fast_retries = FFMAX(fast_retries, 2); wait_since = 0; diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c index 1667e9f08b..40cff4dc56 100644 --- a/libavformat/aviobuf.c +++ b/libavformat/aviobuf.c @@ -556,13 +556,14 @@ static void fill_buffer(AVIOContext *s) if (s->read_packet) len = s->read_packet(s->opaque, dst, len); else - len = 0; - if (len <= 0) { + len = AVERROR_EOF; + if (len == AVERROR_EOF) { /* do not modify buffer if EOF reached so that a seek back can be done without rereading data */ s->eof_reached = 1; - if (len < 0) - s->error = len; + } else if (len < 0) { + s->eof_reached = 1; + s->error= len; } else { s->pos += len; s->buf_ptr = dst; @@ -630,13 +631,14 @@ int avio_read(AVIOContext *s, unsigned char *buf, int size) // bypass the buffer and read data directly into buf if(s->read_packet) len = s->read_packet(s->opaque, buf, size); - - if (len <= 0) { + if (len == AVERROR_EOF) { /* do not modify buffer if EOF reached so that a seek back can be done without rereading data */ s->eof_reached = 1; - if(len<0) - s->error= len; + break; + } else if (len < 0) { + s->eof_reached = 1; + s->error= len; break; } else { s->pos += len; diff --git a/libavformat/cache.c b/libavformat/cache.c index 6aabca2e78..54a40d018b 100644 --- a/libavformat/cache.c +++ b/libavformat/cache.c @@ -201,7 +201,7 @@ static int cache_read(URLContext *h, unsigned char *buf, int size) } r = ffurl_read(c->inner, buf, size); - if (r == 0 && size>0) { + if (r == AVERROR_EOF && size>0) { c->is_true_eof = 1; av_assert0(c->end >= c->logical_pos); } diff --git a/libavformat/file.c b/libavformat/file.c index 264542a36a..1fb83851c0 100644 --- a/libavformat/file.c +++ b/libavformat/file.c @@ -112,6 +112,8 @@ static int file_read(URLContext *h, unsigned char *buf, int size) ret = read(c->fd, buf, size); if (ret == 0 && c->follow) return AVERROR(EAGAIN); + if (ret == 0) + return AVERROR_EOF; return (ret == -1) ? AVERROR(errno) : ret; } diff --git a/libavformat/wtvdec.c b/libavformat/wtvdec.c index 3ac4501306..ee19fd84da 100644 --- a/libavformat/wtvdec.c +++ b/libavformat/wtvdec.c @@ -65,7 +65,7 @@ static int64_t seek_by_sector(AVIOContext *pb, int64_t sector, int64_t offset) } /** - * @return bytes read, 0 on end of file, or <0 on error + * @return bytes read, AVERROR_EOF on end of file, or <0 on error */ static int wtvfile_read_packet(void *opaque, uint8_t *buf, int buf_size) { @@ -76,7 +76,7 @@ static int wtvfile_read_packet(void *opaque, uint8_t *buf, int buf_size) if (wf->error || pb->error) return -1; if (wf->position >= wf->length || avio_feof(pb)) - return 0; + return AVERROR_EOF; buf_size = FFMIN(buf_size, wf->length - wf->position); while(nread < buf_size) {
Signed-off-by: Daniel Kucera <daniel.kucera@gmail.com> --- libavformat/avio.c | 2 +- libavformat/aviobuf.c | 18 ++++++++++-------- libavformat/cache.c | 2 +- libavformat/file.c | 2 ++ libavformat/wtvdec.c | 4 ++-- 5 files changed, 16 insertions(+), 12 deletions(-)