aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorMartin Storsjö <martin@martin.st>2020-05-20 23:08:17 +0300
committerMartin Storsjö <martin@martin.st>2020-05-22 21:49:48 +0300
commitc116c127f9ccd18ff3cf038cfb65a284b01fe720 (patch)
tree8b93962d83ff3d70c86d7a4f1776578b4958a0fe /libavcodec
parentfea5f5bc64e02ab4f753aa55cc8eed4a893650a5 (diff)
downloadffmpeg-c116c127f9ccd18ff3cf038cfb65a284b01fe720.tar.gz
mfenc: Fall back to avctx->time_base if avctx->framerate isn't set
The framerate field is the one users are supposed to set, but not all users might be setting it, so it might be good to fall back time_base in that case. Signed-off-by: Martin Storsjö <martin@martin.st>
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/mfenc.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/libavcodec/mfenc.c b/libavcodec/mfenc.c
index edee0510b2..83f26b3cc6 100644
--- a/libavcodec/mfenc.c
+++ b/libavcodec/mfenc.c
@@ -637,11 +637,19 @@ static int64_t mf_encv_output_score(AVCodecContext *avctx, IMFMediaType *type)
static int mf_encv_output_adjust(AVCodecContext *avctx, IMFMediaType *type)
{
MFContext *c = avctx->priv_data;
+ AVRational framerate;
ff_MFSetAttributeSize((IMFAttributes *)type, &MF_MT_FRAME_SIZE, avctx->width, avctx->height);
IMFAttributes_SetUINT32(type, &MF_MT_INTERLACE_MODE, MFVideoInterlace_Progressive);
- ff_MFSetAttributeRatio((IMFAttributes *)type, &MF_MT_FRAME_RATE, avctx->framerate.num, avctx->framerate.den);
+ if (avctx->framerate.num > 0 && avctx->framerate.den > 0) {
+ framerate = avctx->framerate;
+ } else {
+ framerate = av_inv_q(avctx->time_base);
+ framerate.den *= avctx->ticks_per_frame;
+ }
+
+ ff_MFSetAttributeRatio((IMFAttributes *)type, &MF_MT_FRAME_RATE, framerate.num, framerate.den);
// (MS HEVC supports eAVEncH265VProfile_Main_420_8 only.)
if (avctx->codec_id == AV_CODEC_ID_H264) {