Commit c31458c3 authored by Nicolas George's avatar Nicolas George

lavf/concat: compute duration if possible.

parent 9b211c43
...@@ -157,6 +157,7 @@ static int concat_read_header(AVFormatContext *avf) ...@@ -157,6 +157,7 @@ static int concat_read_header(AVFormatContext *avf)
unsigned nb_files_alloc = 0; unsigned nb_files_alloc = 0;
ConcatFile *file = NULL; ConcatFile *file = NULL;
AVStream *st, *source_st; AVStream *st, *source_st;
int64_t time = 0;
while (1) { while (1) {
if ((ret = ff_get_line(avf->pb, buf, sizeof(buf))) <= 0) if ((ret = ff_get_line(avf->pb, buf, sizeof(buf))) <= 0)
...@@ -207,6 +208,18 @@ static int concat_read_header(AVFormatContext *avf) ...@@ -207,6 +208,18 @@ static int concat_read_header(AVFormatContext *avf)
if (ret < 0) if (ret < 0)
FAIL(ret); 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) if ((ret = open_file(avf, 0)) < 0)
FAIL(ret); FAIL(ret);
for (i = 0; i < cat->avf->nb_streams; i++) { for (i = 0; i < cat->avf->nb_streams; i++) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment