diff --git a/src/modules/avformat/consumer_avformat.c b/src/modules/avformat/consumer_avformat.c index d5ab5f1c..33e2db10 100644 --- a/src/modules/avformat/consumer_avformat.c +++ b/src/modules/avformat/consumer_avformat.c @@ -680,7 +680,9 @@ static int pick_sample_fmt(mlt_properties properties, const AVCodec *codec) { int sample_fmt = AV_SAMPLE_FMT_S16; const char *format = mlt_properties_get(properties, "mlt_audio_format"); - const int *p = codec->sample_fmts; + const enum AVSampleFormat *p = NULL; + avcodec_get_supported_config(NULL, codec, AV_CODEC_CONFIG_SAMPLE_FORMAT, 0, + (const void**)&p, NULL); const char *sample_fmt_str = mlt_properties_get(properties, "sample_fmt"); if (sample_fmt_str) @@ -705,7 +707,9 @@ static int pick_sample_fmt(mlt_properties properties, const AVCodec *codec) return sample_fmt; } // no match - pick first one we support - for (p = codec->sample_fmts; *p != -1; p++) { + avcodec_get_supported_config(NULL, codec, AV_CODEC_CONFIG_SAMPLE_FORMAT, 0, + (const void**)&p, NULL); + for (; *p != -1; p++) { switch (*p) { case AV_SAMPLE_FMT_U8: case AV_SAMPLE_FMT_S16: @@ -980,8 +984,11 @@ static AVStream *add_video_stream(mlt_consumer consumer, c->framerate = av_inv_q(c->time_base); // Default to the codec's first pix_fmt if possible. + const enum AVPixelFormat* codec_pix_fmts = NULL; + avcodec_get_supported_config(NULL, codec, AV_CODEC_CONFIG_PIX_FORMAT, 0, + (const void**)&codec_pix_fmts, NULL); c->pix_fmt = pix_fmt ? av_get_pix_fmt(pix_fmt) - : codec ? (codec->pix_fmts ? codec->pix_fmts[0] : AV_PIX_FMT_YUV422P) + : codec ? (codec_pix_fmts ? codec_pix_fmts[0] : AV_PIX_FMT_YUV422P) : AV_PIX_FMT_YUV420P; if (AV_PIX_FMT_VAAPI == c->pix_fmt) { @@ -1199,14 +1206,19 @@ static int open_video(mlt_properties properties, AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM); } - if (codec && codec->pix_fmts) { - const enum AVPixelFormat *p = codec->pix_fmts; - for (; *p != -1; p++) { - if (*p == video_enc->pix_fmt) - break; + if (codec) { + const enum AVPixelFormat* codec_pix_fmts = NULL; + avcodec_get_supported_config(NULL, codec, AV_CODEC_CONFIG_PIX_FORMAT, 0, + (const void**)&codec_pix_fmts, NULL); + if (codec_pix_fmts) { + const enum AVPixelFormat *p = codec_pix_fmts; + for (; *p != -1; p++) { + if (*p == video_enc->pix_fmt) + break; + } + if (*p == -1) + video_enc->pix_fmt = codec_pix_fmts[0]; } - if (*p == -1) - video_enc->pix_fmt = codec->pix_fmts[0]; } const AVPixFmtDescriptor *srcDesc = av_pix_fmt_desc_get(video_enc->pix_fmt);