You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-15 14:13:16 +02:00
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>
This commit is contained in:
@@ -355,13 +355,11 @@ static int open_file(AVFormatContext *avf, unsigned fileno)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
cat->cur_file = file;
|
cat->cur_file = file;
|
||||||
if (file->start_time == AV_NOPTS_VALUE)
|
|
||||||
file->start_time = !fileno ? 0 :
|
file->start_time = !fileno ? 0 :
|
||||||
cat->files[fileno - 1].start_time +
|
cat->files[fileno - 1].start_time +
|
||||||
cat->files[fileno - 1].duration;
|
cat->files[fileno - 1].duration;
|
||||||
file->file_start_time = (cat->avf->start_time == AV_NOPTS_VALUE) ? 0 : cat->avf->start_time;
|
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;
|
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) {
|
if (cat->segment_time_metadata) {
|
||||||
@@ -504,6 +502,7 @@ static int concat_read_header(AVFormatContext *avf)
|
|||||||
break;
|
break;
|
||||||
cat->files[i].user_duration = cat->files[i].outpoint - cat->files[i].inpoint;
|
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;
|
time += cat->files[i].user_duration;
|
||||||
}
|
}
|
||||||
if (i == cat->nb_files) {
|
if (i == cat->nb_files) {
|
||||||
@@ -529,7 +528,6 @@ static int open_next_file(AVFormatContext *avf)
|
|||||||
ConcatContext *cat = avf->priv_data;
|
ConcatContext *cat = avf->priv_data;
|
||||||
unsigned fileno = cat->cur_file - cat->files;
|
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) {
|
if (++fileno >= cat->nb_files) {
|
||||||
|
Reference in New Issue
Block a user