1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-21 10:55:51 +02:00

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.
This commit is contained in:
Anton Khirnov 2023-05-07 18:01:19 +02:00
parent 6b0c984f0d
commit f9657b7443
3 changed files with 5 additions and 11 deletions

View File

@ -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];

View File

@ -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

View File

@ -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 };