ffmpeg: delay readrate enforcement for decoded streams

Read rate enforcement delayed till first decoded frame is obtained, to
speed up init of output streams.

Thanks to Linjie Fu <linjie.justin.fu@gmail.com> for the initial patch.
This commit is contained in:
Gyan Doshi 2021-07-19 12:54:55 +05:30
parent 981d49e373
commit 6f20685228

View File

@ -4237,7 +4237,7 @@ static int get_input_packet(InputFile *f, AVPacket **pkt)
for (i = 0; i < f->nb_streams; i++) { for (i = 0; i < f->nb_streams; i++) {
InputStream *ist = input_streams[f->ist_index + i]; InputStream *ist = input_streams[f->ist_index + i];
int64_t stream_ts_offset, pts, now; int64_t stream_ts_offset, pts, now;
if (!ist->nb_packets) continue; if (!ist->nb_packets || (ist->decoding_needed && !ist->got_output)) continue;
stream_ts_offset = FFMAX(ist->first_dts != AV_NOPTS_VALUE ? ist->first_dts : 0, file_start); 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); pts = av_rescale(ist->dts, 1000000, AV_TIME_BASE);
now = (av_gettime_relative() - ist->start) * scale + stream_ts_offset; now = (av_gettime_relative() - ist->start) * scale + stream_ts_offset;