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.
Unified · Split
| @@ -637,11 +637,19 @@ static int64_t mf_encv_output_score(AVCodecContext *avctx, IMFMediaType *type) · 636 unmodified lines | |||
| 637 | static int mf_encv_output_adjust(AVCodecContext *avctx, IMFMediaType *type) | 637 | static int mf_encv_output_adjust(AVCodecContext *avctx, IMFMediaType *type) |
| 638 | { | 638 | { |
| 639 | MFContext *c = avctx->priv_data; | 639 | MFContext *c = avctx->priv_data; |
| 640 | AVRational framerate; | ||
| 640 | 641 | ||
| 641 | ff_MFSetAttributeSize((IMFAttributes *)type, &MF_MT_FRAME_SIZE, avctx->width, avctx->height); | 642 | ff_MFSetAttributeSize((IMFAttributes *)type, &MF_MT_FRAME_SIZE, avctx->width, avctx->height); |
| 642 | IMFAttributes_SetUINT32(type, &MF_MT_INTERLACE_MODE, MFVideoInterlace_Progressive); | 643 | IMFAttributes_SetUINT32(type, &MF_MT_INTERLACE_MODE, MFVideoInterlace_Progressive); |
| 643 | 644 | ||
| 644 | ff_MFSetAttributeRatio((IMFAttributes *)type, &MF_MT_FRAME_RATE, avctx->framerate.num, avctx->framerate.den); | 645 | if (avctx->framerate.num > 0 && avctx->framerate.den > 0) { |
| 646 | framerate = avctx->framerate; | ||
| 647 | } else { | ||
| 648 | framerate = av_inv_q(avctx->time_base); | ||
| 649 | framerate.den *= avctx->ticks_per_frame; | ||
| 650 | } | ||
| 651 | |||
| 652 | ff_MFSetAttributeRatio((IMFAttributes *)type, &MF_MT_FRAME_RATE, framerate.num, framerate.den); | ||
| 645 | 653 | ||
| 646 | // (MS HEVC supports eAVEncH265VProfile_Main_420_8 only.) | 654 | // (MS HEVC supports eAVEncH265VProfile_Main_420_8 only.) |
| 647 | if (avctx->codec_id == AV_CODEC_ID_H264) { | 655 | if (avctx->codec_id == AV_CODEC_ID_H264) { |