aboutsummaryrefslogtreecommitdiffstats
path: root/fftools/ffmpeg_demux.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2023-05-07 18:01:19 +0200
committerAnton Khirnov <anton@khirnov.net>2023-05-15 13:32:01 +0200
commitf9657b7443f674c159f305a6033b985d034d0f3b (patch)
treece85e60655c16d202a9b52e0fc2c4f70203ea10c /fftools/ffmpeg_demux.c
parent6b0c984f0dfe632ec0d59fb12c8880240c5208c0 (diff)
downloadffmpeg-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.
Diffstat (limited to 'fftools/ffmpeg_demux.c')
-rw-r--r--fftools/ffmpeg_demux.c6
1 files changed, 5 insertions, 1 deletions
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 };