compatibility with ffmpeg 9.0

Index: modules/videoio/src/cap_ffmpeg_hw.hpp
--- modules/videoio/src/cap_ffmpeg_hw.hpp.orig
+++ modules/videoio/src/cap_ffmpeg_hw.hpp
@@ -739,7 +739,9 @@ bool hw_check_codec(AVCodec* codec, AVHWDeviceType hw_
 static
 AVCodec *hw_find_codec(AVCodecID id, AVHWDeviceType hw_type, int (*check_category)(const AVCodec *), const char *disabled_codecs, AVPixelFormat *hw_pix_fmt) {
     AVCodec *c = 0;
+    const enum AVPixelFormat *pix_fmts;
     void *opaque = 0;
+    int ret, num_pix_fmts;
 
     while (NULL != (c = (AVCodec*)av_codec_iterate(&opaque)))
     {
@@ -757,12 +759,16 @@ AVCodec *hw_find_codec(AVCodecID id, AVHWDeviceType hw
 #endif
             if (hw_type == AV_HWDEVICE_TYPE_CUDA) // CUDA encoders don't support avcodec_get_hw_config()
                 hw_native_fmt = AV_PIX_FMT_CUDA;
-            if (av_codec_is_encoder(c) && hw_native_fmt != AV_PIX_FMT_NONE && c->pix_fmts) {
-                for (int i = 0; c->pix_fmts[i] != AV_PIX_FMT_NONE; i++) {
-                    if (c->pix_fmts[i] == hw_native_fmt) {
-                        *hw_pix_fmt = hw_native_fmt;
-                        if (hw_check_codec(c, hw_type, disabled_codecs))
-                            return c;
+            if (av_codec_is_encoder(c) && hw_native_fmt != AV_PIX_FMT_NONE) {
+                ret = avcodec_get_supported_config(NULL, c, AV_CODEC_CONFIG_PIX_FORMAT,
+                                                   0, (const void **) &pix_fmts, &num_pix_fmts);
+                if (ret >= 0 && pix_fmts) {
+                    for (int i = 0; i < num_pix_fmts; i++) {
+                        if (pix_fmts[i] == hw_native_fmt) {
+                            *hw_pix_fmt = hw_native_fmt;
+                            if (hw_check_codec(c, hw_type, disabled_codecs))
+                                return c;
+                        }
                     }
                 }
             }
