diff options
author | Anton Khirnov <anton@khirnov.net> | 2023-05-07 18:01:19 +0200 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2023-05-15 13:32:01 +0200 |
commit | f9657b7443f674c159f305a6033b985d034d0f3b (patch) | |
tree | ce85e60655c16d202a9b52e0fc2c4f70203ea10c | |
parent | 6b0c984f0dfe632ec0d59fb12c8880240c5208c0 (diff) | |
download | ffmpeg-f9657b7443f674c159f305a6033b985d034d0f3b.tar.gz |
fftools/ffmpeg: simplify tracking -readrate start time
There is no point in having a per-stream wallclock start time, since
they are all computed at the same instant. Keep a per-file start time
instead, initialized when the demuxer thread starts.
-rw-r--r-- | fftools/ffmpeg.c | 8 | ||||
-rw-r--r-- | fftools/ffmpeg.h | 2 | ||||
-rw-r--r-- | fftools/ffmpeg_demux.c | 6 |
3 files changed, 5 insertions, 11 deletions
diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 9cf94f2a22..40e97ad486 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -1498,14 +1498,6 @@ static int transcode_init(void) { int ret = 0; - /* init framerate emulation */ - for (int i = 0; i < nb_input_files; i++) { - InputFile *ifile = input_files[i]; - if (ifile->readrate) - for (int j = 0; j < ifile->nb_streams; j++) - ifile->streams[j]->start = av_gettime_relative(); - } - /* discard unused programs */ for (int i = 0; i < nb_input_files; i++) { InputFile *ifile = input_files[i]; diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 7eb6301c74..d1af94590d 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -362,8 +362,6 @@ typedef struct InputStream { AVRational framerate_guessed; - int64_t start; /* time when read started */ - // pts/estimated duration of the last decoded frame // * in decoder timebase for video, // * in last_frame_tb (may change during decoding) for audio diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c index ccf1a70d5e..aff80b1cd3 100644 --- a/fftools/ffmpeg_demux.c +++ b/fftools/ffmpeg_demux.c @@ -88,6 +88,8 @@ typedef struct Demuxer { // name used for logging char log_name[32]; + int64_t wallclock_start; + /* number of times input stream should be looped */ int loop; /* actual duration of the longest stream in a file at the moment when @@ -517,7 +519,7 @@ static void readrate_sleep(Demuxer *d) int64_t stream_ts_offset, pts, now; stream_ts_offset = FFMAX(ds->first_dts != AV_NOPTS_VALUE ? ds->first_dts : 0, file_start); pts = av_rescale(ds->dts, 1000000, AV_TIME_BASE); - now = (av_gettime_relative() - ist->start) * f->readrate + stream_ts_offset; + now = (av_gettime_relative() - d->wallclock_start) * f->readrate + stream_ts_offset; if (pts - burst_until > now) av_usleep(pts - burst_until - now); } @@ -546,6 +548,8 @@ static void *input_thread(void *arg) thread_set_name(f); + d->wallclock_start = av_gettime_relative(); + while (1) { DemuxMsg msg = { NULL }; |