[FFmpeg-devel] [PATCH v2] avcodec/mediacodecenc: enable B frames only with -strict experimental
Tomas Härdin
git at haerdin.se
Fri Jan 6 17:41:48 EET 2023
lör 2023-01-07 klockan 00:07 +0800 skrev Zhao Zhili:
> From: Zhao Zhili <zhilizhao at tencent.com>
>
> Signed-off-by: Zhao Zhili <zhilizhao at tencent.com>
> ---
> v2: Enable -> Enabling
>
> libavcodec/mediacodecenc.c | 10 +++++++++-
> 1 file changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/libavcodec/mediacodecenc.c b/libavcodec/mediacodecenc.c
> index 4c1809093c..a92a8dc5a9 100644
> --- a/libavcodec/mediacodecenc.c
> +++ b/libavcodec/mediacodecenc.c
> @@ -276,8 +276,16 @@ static av_cold int
> mediacodec_init(AVCodecContext *avctx)
> av_log(avctx, AV_LOG_DEBUG, "set level to 0x%x\n", s-
> >level);
> ff_AMediaFormat_setInt32(format, "level", s->level);
> }
> - if (avctx->max_b_frames > 0)
> + if (avctx->max_b_frames > 0) {
> + if (avctx->strict_std_compliance >
> FF_COMPLIANCE_EXPERIMENTAL) {
> + av_log(avctx, AV_LOG_ERROR,
> + "Enabling B frames will produce packets with no
> DTS. "
> + "Use -strict experimental to use it anyway.\n");
> + ret = AVERROR(EINVAL);
> + goto bailout;
> + }
> ff_AMediaFormat_setInt32(format, "max-bframes", avctx-
> >max_b_frames);
> + }
> if (s->pts_as_dts == -1)
> s->pts_as_dts = avctx->max_b_frames <= 0;
>
Looks OK since all packets should get dts and pts = dts by pts_as_dts
/Tomas
More information about the ffmpeg-devel
mailing list