[FFmpeg-devel] [PATCH 3/4] lavf/concat: compute duration if possible.

Stefano Sabatini stefasab at gmail.com
Fri Feb 22 15:16:53 CET 2013


On date Thursday 2013-02-14 16:30:58 +0100, Nicolas George encoded:
> 
> Signed-off-by: Nicolas George <nicolas.george at normalesup.org>
> ---
>  libavformat/concatdec.c |   13 +++++++++++++
>  1 file changed, 13 insertions(+)
> 
> diff --git a/libavformat/concatdec.c b/libavformat/concatdec.c
> index 2858bef..a9fcc76 100644
> --- a/libavformat/concatdec.c
> +++ b/libavformat/concatdec.cPTS
> @@ -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;

What if duration is NOPTS_VALUE?

And BTW I'm not sure about the assumed semantics of duration, if it
is:
max time in file
or
max time in file - start time

(where start time is assumed the first time in the file), and I
suspect it is treated inconsistently in the codebase. Fixing the
documentation would really help.

Also duration is very unreliable in a lot of cases (e.g. when it is
computed from bitrate and file size).

[...]
-- 
FFmpeg = Foolish and Fascinating Multimedia Pitiless Enlightened Gymnast


More information about the ffmpeg-devel mailing list