diff options
author | Marton Balint | 2018-11-22 00:59:45 +0100 |
---|---|---|
committer | Marton Balint | 2019-01-22 20:14:11 +0100 |
commit | 1b126ec4087ab5d87d413116bee666495b0d2d3e (patch) | |
tree | be795a137ff26f20278233f2ce5010256fec4616 /libavformat/concatdec.c | |
parent | 679cbd8f18719f470f7107ed0a7fbef1905ee85a (diff) |
avformat/concatdec: always re-calculate start time and duration
This allows the underlying files to change their duration on subsequent
avformat context opens.
An example use case where this matters:
ffconcat version 1.0
file dummy.mxf
file dummy.mxf
ffmpeg -re -stream_loop -1 -i dummy.ffconcat -f sdl2 none
The user can seamlessly change the input by atomically replacing dummy.mxf.
v2: Set ConcatFile duration in read_header for all segments with known
durations because from now on we always recalculate the start time in
open_file, and an instant seek could have caused unset ConcatFile durations.
Signed-off-by: Marton Balint <cus@passwd.hu>
Diffstat (limited to 'libavformat/concatdec.c')
-rw-r--r-- | libavformat/concatdec.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/libavformat/concatdec.c b/libavformat/concatdec.c index 890a220a89..d65da553e1 100644 --- a/libavformat/concatdec.c +++ b/libavformat/concatdec.c @@ -355,14 +355,12 @@ static int open_file(AVFormatContext *avf, unsigned fileno) return ret; } cat->cur_file = file; - if (file->start_time == AV_NOPTS_VALUE) - file->start_time = !fileno ? 0 : - cat->files[fileno - 1].start_time + - cat->files[fileno - 1].duration; + file->start_time = !fileno ? 0 : + cat->files[fileno - 1].start_time + + cat->files[fileno - 1].duration; file->file_start_time = (cat->avf->start_time == AV_NOPTS_VALUE) ? 0 : cat->avf->start_time; file->file_inpoint = (file->inpoint == AV_NOPTS_VALUE) ? file->file_start_time : file->inpoint; - if (file->duration == AV_NOPTS_VALUE) - file->duration = get_best_effort_duration(file, cat->avf); + file->duration = get_best_effort_duration(file, cat->avf); if (cat->segment_time_metadata) { av_dict_set_int(&file->metadata, "lavf.concatdec.start_time", file->start_time, 0); @@ -504,6 +502,7 @@ static int concat_read_header(AVFormatContext *avf) break; cat->files[i].user_duration = cat->files[i].outpoint - cat->files[i].inpoint; } + cat->files[i].duration = cat->files[i].user_duration; time += cat->files[i].user_duration; } if (i == cat->nb_files) { @@ -529,8 +528,7 @@ static int open_next_file(AVFormatContext *avf) ConcatContext *cat = avf->priv_data; unsigned fileno = cat->cur_file - cat->files; - if (cat->cur_file->duration == AV_NOPTS_VALUE) - cat->cur_file->duration = get_best_effort_duration(cat->cur_file, cat->avf); + cat->cur_file->duration = get_best_effort_duration(cat->cur_file, cat->avf); if (++fileno >= cat->nb_files) { cat->eof = 1; |