38 lines
2.2 KiB
Diff
38 lines
2.2 KiB
Diff
diff --git a/modules/videoio/src/cap_ffmpeg_hw.hpp b/modules/videoio/src/cap_ffmpeg_hw.hpp
|
|
index 65045a2bc7..3ed33d32a3 100644
|
|
--- a/modules/videoio/src/cap_ffmpeg_hw.hpp
|
|
+++ b/modules/videoio/src/cap_ffmpeg_hw.hpp
|
|
@@ -757,9 +757,12 @@ AVCodec *hw_find_codec(AVCodecID id, AVHWDeviceType hw_type, int (*check_categor
|
|
#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) {
|
|
+ const AVPixelFormat* c_pix_fmts = nullptr;
|
|
+ avcodec_get_supported_config(nullptr, c, AV_CODEC_CONFIG_PIX_FORMAT, 0,
|
|
+ (const void**)&c_pix_fmts, nullptr);
|
|
+ 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;
|
|
diff --git a/modules/videoio/src/cap_ffmpeg_impl.hpp b/modules/videoio/src/cap_ffmpeg_impl.hpp
|
|
index 3dd42ecfd1..005d048d95 100644
|
|
--- a/modules/videoio/src/cap_ffmpeg_impl.hpp
|
|
+++ b/modules/videoio/src/cap_ffmpeg_impl.hpp
|
|
@@ -2629,8 +2629,10 @@ static AVCodecContext * icv_configure_video_stream_FFMPEG(AVFormatContext *oc,
|
|
c->time_base.den = frame_rate;
|
|
c->time_base.num = frame_rate_base;
|
|
/* adjust time base for supported framerates */
|
|
- if(codec && codec->supported_framerates){
|
|
- const AVRational *p= codec->supported_framerates;
|
|
+ const AVRational *p = nullptr;
|
|
+ avcodec_get_supported_config(nullptr, codec, AV_CODEC_CONFIG_FRAME_RATE, 0,
|
|
+ (const void**)&p, nullptr);
|
|
+ if(codec && p){
|
|
AVRational req = {frame_rate, frame_rate_base};
|
|
const AVRational *best=NULL;
|
|
AVRational best_error= {INT_MAX, 1};
|