Submit reasons: I have enabled concat and async protocol,but ffmpeg will flush async buffer when doing seek. I don't want flush async buffer when doing seek within the same segment file. I found, the concatdev will call open_file everytime I try to do seek, which will cause call async_open,and then flush async buffer.
Solution: I will judge if seek range in the same segment file, if so, I‘ll only call try_seek. 2016-09-20 12:31 GMT+08:00 raymond <raymondzheng1...@gmail.com>: > --- > libavformat/concatdec.c | 27 ++++++++++++++++++++------- > 1 file changed, 20 insertions(+), 7 deletions(-) > > diff --git a/libavformat/concatdec.c b/libavformat/concatdec.c > index b3a430e..1cd9ec1 100644 > --- a/libavformat/concatdec.c > +++ b/libavformat/concatdec.c > @@ -64,6 +64,8 @@ typedef struct { > ConcatMatchMode stream_match_mode; > unsigned auto_convert; > int segment_time_metadata; > + int cur_fileno; > + AVFormatContext *cur_avf_saved; > } ConcatContext; > > static int concat_probe(AVProbeData *probe) > @@ -333,6 +335,8 @@ static int open_file(AVFormatContext *avf, unsigned > fileno) > avformat_close_input(&cat->avf); > return ret; > } > + > + cat->cur_fileno = fileno; > cat->cur_file = file; > if (file->start_time == AV_NOPTS_VALUE) > file->start_time = !fileno ? 0 : > @@ -711,13 +715,18 @@ static int real_seek(AVFormatContext *avf, int > stream, > left = mid; > } > > - if ((ret = open_file(avf, left)) < 0) > - return ret; > + if (cat->cur_fileno != left) { > + if ((ret = open_file(avf, left)) < 0) > + return ret; > + } else { > + cat->avf = cat->cur_avf_saved; > + } > > ret = try_seek(avf, stream, min_ts, ts, max_ts, flags); > if (ret < 0 && > left < cat->nb_files - 1 && > cat->files[left + 1].start_time < max_ts) { > + cat->avf = NULL; > if ((ret = open_file(avf, left + 1)) < 0) > return ret; > ret = try_seek(avf, stream, min_ts, ts, max_ts, flags); > @@ -730,7 +739,7 @@ static int concat_seek(AVFormatContext *avf, int > stream, > { > ConcatContext *cat = avf->priv_data; > ConcatFile *cur_file_saved = cat->cur_file; > - AVFormatContext *cur_avf_saved = cat->avf; > + cat->cur_avf_saved = cat->avf; > int ret; > > if (!cat->seekable) > @@ -739,12 +748,16 @@ static int concat_seek(AVFormatContext *avf, int > stream, > return AVERROR(ENOSYS); > cat->avf = NULL; > if ((ret = real_seek(avf, stream, min_ts, ts, max_ts, flags)) < 0) { > - if (cat->avf) > - avformat_close_input(&cat->avf); > - cat->avf = cur_avf_saved; > + if (cat->cur_file != cur_file_saved) { > + if (cat->avf) > + avformat_close_input(&cat->avf); > + } > + cat->avf = cat->cur_avf_saved; > cat->cur_file = cur_file_saved; > } else { > - avformat_close_input(&cur_avf_saved); > + if (cat->cur_file != cur_file_saved) { > + avformat_close_input(&cat->cur_avf_saved); > + } > cat->eof = 0; > } > return ret; > -- > 2.7.4 > > _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel