decoder: add more fallbacks if fps is 0

Change-Id: I59f25e4537c393674f1b62b0e12deb143d9fc108
Reviewed-by: Hugo Lefeuvre <hugo.lefeuvre@savoirfairelinux.com>
This commit is contained in:
philippegorley
2018-08-13 16:21:06 -04:00
committed by Hugo Lefeuvre
parent e4ba16d1b1
commit c49c89a666

View File

@ -193,9 +193,14 @@ MediaDecoder::setupStream(AVMediaType mediaType)
}
avcodec_parameters_to_context(decoderCtx_, avStream_->codecpar);
decoderCtx_->framerate = avStream_->avg_frame_rate;
// in case FFmpeg could not find a framerate, fall back to the ones found in openInput
if (mediaType == AVMEDIA_TYPE_VIDEO && (decoderCtx_->framerate.num == 0 || decoderCtx_->framerate.den == 0))
decoderCtx_->framerate = inputParams_.framerate;
if (mediaType == AVMEDIA_TYPE_VIDEO) {
if (decoderCtx_->framerate.num == 0 || decoderCtx_->framerate.den == 0)
decoderCtx_->framerate = inputParams_.framerate;
if (decoderCtx_->framerate.num == 0 || decoderCtx_->framerate.den == 0)
decoderCtx_->framerate = av_inv_q(decoderCtx_->time_base);
if (decoderCtx_->framerate.num == 0 || decoderCtx_->framerate.den == 0)
decoderCtx_->framerate = {30, 1};
}
decoderCtx_->thread_count = std::max(1u, std::min(8u, std::thread::hardware_concurrency()/2));