diff options
author | Davy Durham <ddurham@davyandbeth.com> | 2023-05-02 13:35:34 +0200 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2023-05-07 15:48:15 +0200 |
commit | 2ae16b05d62f50ba3719af3c279db1109240a74b (patch) | |
tree | 5e607c91d5b17cb850f0fa56a8f458572dd01ac9 /fftools/ffmpeg_demux.c | |
parent | 6deaf1e40949b1daa2dfe23e9643e1758f52d29c (diff) | |
download | ffmpeg-2ae16b05d62f50ba3719af3c279db1109240a74b.tar.gz |
fftools/ffmpeg: add ability to set a input burst time before readrate is enforced
Signed-off-by: Anton Khirnov <anton@khirnov.net>
Diffstat (limited to 'fftools/ffmpeg_demux.c')
-rw-r--r-- | fftools/ffmpeg_demux.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c index 26426c7ac1..37d7649da9 100644 --- a/fftools/ffmpeg_demux.c +++ b/fftools/ffmpeg_demux.c @@ -81,6 +81,8 @@ typedef struct Demuxer { /* number of streams that the user was warned of */ int nb_streams_warn; + double readrate_initial_burst; + AVThreadMessageQueue *in_thread_queue; int thread_queue_size; pthread_t thread; @@ -455,6 +457,7 @@ int ifile_get_packet(InputFile *f, AVPacket **pkt) (f->start_time != AV_NOPTS_VALUE ? f->start_time : 0) ); float scale = f->rate_emu ? 1.0 : f->readrate; + int64_t burst_until = AV_TIME_BASE * d->readrate_initial_burst; for (i = 0; i < f->nb_streams; i++) { InputStream *ist = f->streams[i]; int64_t stream_ts_offset, pts, now; @@ -462,7 +465,7 @@ int ifile_get_packet(InputFile *f, AVPacket **pkt) stream_ts_offset = FFMAX(ist->first_dts != AV_NOPTS_VALUE ? ist->first_dts : 0, file_start); pts = av_rescale(ist->dts, 1000000, AV_TIME_BASE); now = (av_gettime_relative() - ist->start) * scale + stream_ts_offset; - if (pts > now) + if (pts - burst_until > now) return AVERROR(EAGAIN); } } @@ -1236,6 +1239,19 @@ int ifile_open(const OptionsContext *o, const char *filename) f->rate_emu = 0; } + if (f->readrate || f->rate_emu) { + d->readrate_initial_burst = o->readrate_initial_burst ? o->readrate_initial_burst : 0.0; + if (d->readrate_initial_burst < 0.0) { + av_log(d, AV_LOG_ERROR, + "Option -readrate_initial_burst is %0.3f; it must be non-negative.\n", + d->readrate_initial_burst); + exit_program(1); + } + } else if (o->readrate_initial_burst) { + av_log(d, AV_LOG_WARNING, "Option -readrate_initial_burst ignored " + "since neither -readrate nor -re were given\n"); + } + d->thread_queue_size = o->thread_queue_size; /* update the current parameters so that they match the one of the input stream */ |