diff --git a/DOCS/man/options.rst b/DOCS/man/options.rst index 3c2a404189..83ef901eed 100644 --- a/DOCS/man/options.rst +++ b/DOCS/man/options.rst @@ -779,6 +779,8 @@ Video the given hardware. ``nv12``, the default, works better on modern hardware, while ``uyvy422`` appears to be better for old hardware. ``yuv420p`` also works. + Since mpv 0.25.0, ``no`` is an accepted value, which lets the decoder pick + the format on newer FFmpeg versions (will use ``nv12`` on older versions). ``--panscan=<0.0-1.0>`` Enables pan-and-scan functionality (cropping the sides of e.g. a 16:9 diff --git a/options/options.c b/options/options.c index 7723ddec50..012707cb2c 100644 --- a/options/options.c +++ b/options/options.c @@ -448,7 +448,7 @@ const m_option_t mp_opts[] = { OPT_CHOICE_C("hwdec", hwdec_api, 0, mp_hwdec_names), OPT_STRING("hwdec-codecs", hwdec_codecs, 0), #if HAVE_VIDEOTOOLBOX_HWACCEL - OPT_IMAGEFORMAT("videotoolbox-format", videotoolbox_format, 0), + OPT_IMAGEFORMAT("videotoolbox-format", videotoolbox_format, 0, .min = -1), #endif // -1 means auto aspect (prefer container size until aspect change) diff --git a/video/decode/hw_videotoolbox.c b/video/decode/hw_videotoolbox.c index 8d8c165a84..b343b1de0e 100644 --- a/video/decode/hw_videotoolbox.c +++ b/video/decode/hw_videotoolbox.c @@ -105,8 +105,14 @@ static int init_decoder(struct lavc_ctx *ctx, int w, int h) if (!vtctx) return -1; - vtctx->cv_pix_fmt_type = - mp_imgfmt_to_cvpixelformat(ctx->opts->videotoolbox_format); + int imgfmt = ctx->opts->videotoolbox_format; +#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(57, 81, 103) + if (!imgfmt) + imgfmt = IMGFMT_NV12; +#endif + vtctx->cv_pix_fmt_type = mp_imgfmt_to_cvpixelformat(imgfmt); + MP_VERBOSE(ctx, "Requesting cv_pix_fmt_type=0x%x\n", + (unsigned)vtctx->cv_pix_fmt_type); int err = av_videotoolbox_default_init2(ctx->avctx, vtctx); if (err < 0) {