diff options
author | Nicolas George <nicolas.george@normalesup.org> | 2013-02-13 19:25:26 +0100 |
---|---|---|
committer | Nicolas George <nicolas.george@normalesup.org> | 2013-03-05 16:44:51 +0100 |
commit | c31458c334b6328899d9ebe83150a55609784dfd (patch) | |
tree | 5490a1fcd84b7fda9d3781aa83bc6845bf0815fe /libavformat/concatdec.c | |
parent | 9b211c43dc5f2e618f204c4a7fd184eb2ea51f02 (diff) | |
download | ffmpeg-c31458c334b6328899d9ebe83150a55609784dfd.tar.gz |
lavf/concat: compute duration if possible.
Diffstat (limited to 'libavformat/concatdec.c')
-rw-r--r-- | libavformat/concatdec.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/libavformat/concatdec.c b/libavformat/concatdec.c index 2858befa3d..a9fcc76a03 100644 --- a/libavformat/concatdec.c +++ b/libavformat/concatdec.c @@ -157,6 +157,7 @@ static int concat_read_header(AVFormatContext *avf) unsigned nb_files_alloc = 0; ConcatFile *file = NULL; AVStream *st, *source_st; + int64_t time = 0; while (1) { if ((ret = ff_get_line(avf->pb, buf, sizeof(buf))) <= 0) @@ -207,6 +208,18 @@ static int concat_read_header(AVFormatContext *avf) if (ret < 0) FAIL(ret); + for (i = 0; i < cat->nb_files; i++) { + if (cat->files[i].start_time == AV_NOPTS_VALUE) + cat->files[i].start_time = time; + else + time = cat->files[i].start_time; + if (cat->files[i].duration == AV_NOPTS_VALUE) + break; + time += cat->files[i].duration; + } + if (i == cat->nb_files) + avf->duration = time; + if ((ret = open_file(avf, 0)) < 0) FAIL(ret); for (i = 0; i < cat->avf->nb_streams; i++) { |