multimedia/mlt7: compatibility with ffmpeg 9.0

Kirill A. Korinsky <[email protected]>
Newsgroups gmane.os.openbsd.ports
Message-ID <[email protected]>
ports@,

I'd like to commit a backport of a fix for multimedia/mlt7 which switches it
away from deprecated API in ffmpeg which prevents it to build against ffmpeg
9.0 from
https://github.com/mltframework/mlt/commit/06c4785f951c087c700de942362d1d1c68ffe500

Build tested against ffmpeg-9.0 and ffmpeg-8.1.2

Tests? Ok?

Index: Makefile
===================================================================
RCS file: /cvs/ports/multimedia/mlt7/Makefile,v
diff -u -p -r1.25 Makefile
--- Makefile	30 Jun 2026 14:43:02 -0000	1.25
+++ Makefile	10 Aug 2026 21:42:53 -0000
@@ -1,6 +1,7 @@
 COMMENT-main =	multimedia transformations framework
 COMMENT-gpl2 =	GPLv2-licensed modules for mlt
 V =		7.38.0
+REVISION =	0
 DISTNAME =	mlt-${V}
 PKGNAME-main =	mlt7-${V}
 PKGNAME-gpl2 =	mlt7-gpl2-${V}
Index: patches/patch-src_modules_avformat_consumer_avformat_c
===================================================================
RCS file: patches/patch-src_modules_avformat_consumer_avformat_c
diff -N patches/patch-src_modules_avformat_consumer_avformat_c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_modules_avformat_consumer_avformat_c	10 Aug 2026 21:42:53 -0000
@@ -0,0 +1,125 @@
+https://github.com/mltframework/mlt/commit/06c4785f951c087c700de942362d1d1c68ffe500
+
+Index: src/modules/avformat/consumer_avformat.c
+--- src/modules/avformat/consumer_avformat.c.orig
++++ src/modules/avformat/consumer_avformat.c
+@@ -629,7 +629,8 @@ static void apply_properties(void *obj, mlt_properties
+                 || (opt_name[0] == 'a' && (flags & AV_OPT_FLAG_AUDIO_PARAM))))
+             opt = av_opt_find(obj, ++opt_name, NULL, flags, search_flags);
+         // Apply option if found
+-        if (opt && strcmp(opt_name, "channel_layout"))
++        if (opt && strcmp(opt_name, "channel_layout") && strcmp(opt_name, "frame_duration")
++            && strcmp(opt_name, "dc"))
+             av_opt_set(obj, opt_name, mlt_properties_get_value(properties, i), search_flags);
+     }
+ }
+@@ -680,7 +681,6 @@ static int pick_sample_fmt(mlt_properties properties, 
+ {
+     int sample_fmt = AV_SAMPLE_FMT_S16;
+     const char *format = mlt_properties_get(properties, "mlt_audio_format");
+-    const int *p = codec->sample_fmts;
+     const char *sample_fmt_str = mlt_properties_get(properties, "sample_fmt");
+ 
+     if (sample_fmt_str)
+@@ -699,13 +699,29 @@ static int pick_sample_fmt(mlt_properties properties, 
+         else if (!strcmp(format, "float"))
+             sample_fmt = AV_SAMPLE_FMT_FLTP;
+     }
++#if LIBAVCODEC_VERSION_INT >= ((61 << 16) + (13 << 8) + 100)
++    const enum AVSampleFormat *sample_fmts = NULL;
++    avcodec_get_supported_config(NULL,
++                                 codec,
++                                 AV_CODEC_CONFIG_SAMPLE_FORMAT,
++                                 0,
++                                 (const void **) &sample_fmts,
++                                 NULL);
++    const int *p = (const int *) sample_fmts;
++#else
++    const int *p = codec->sample_fmts;
++#endif
+     // check if codec supports our mlt_audio_format
+-    for (; *p != -1; p++) {
++    for (; p && *p != -1; p++) {
+         if (*p == sample_fmt)
+             return sample_fmt;
+     }
+     // no match - pick first one we support
++#if LIBAVCODEC_VERSION_INT >= ((61 << 16) + (13 << 8) + 100)
++    for (p = (const int *) sample_fmts; p && *p != -1; p++) {
++#else
+     for (p = codec->sample_fmts; *p != -1; p++) {
++#endif
+         switch (*p) {
+         case AV_SAMPLE_FMT_U8:
+         case AV_SAMPLE_FMT_S16:
+@@ -980,9 +996,25 @@ static AVStream *add_video_stream(mlt_consumer consume
+         c->framerate = av_inv_q(c->time_base);
+ 
+         // Default to the codec's first pix_fmt if possible.
++#if LIBAVCODEC_VERSION_INT >= ((61 << 16) + (13 << 8) + 100)
++        {
++            const enum AVPixelFormat *video_pix_fmts = NULL;
++            if (codec)
++                avcodec_get_supported_config(NULL,
++                                             codec,
++                                             AV_CODEC_CONFIG_PIX_FORMAT,
++                                             0,
++                                             (const void **) &video_pix_fmts,
++                                             NULL);
++            c->pix_fmt = pix_fmt ? av_get_pix_fmt(pix_fmt)
++                         : codec ? (video_pix_fmts ? video_pix_fmts[0] : AV_PIX_FMT_YUV422P)
++                                 : AV_PIX_FMT_YUV420P;
++        }
++#else
+         c->pix_fmt = pix_fmt ? av_get_pix_fmt(pix_fmt)
+                      : codec ? (codec->pix_fmts ? codec->pix_fmts[0] : AV_PIX_FMT_YUV422P)
+                              : AV_PIX_FMT_YUV420P;
++#endif
+ 
+         if (AV_PIX_FMT_VAAPI == c->pix_fmt) {
+             int result = init_vaapi(properties, c);
+@@ -1082,7 +1114,9 @@ static AVStream *add_video_stream(mlt_consumer consume
+         c->rc_override_count = i;
+         if (!c->rc_initial_buffer_occupancy)
+             c->rc_initial_buffer_occupancy = c->rc_buffer_size * 3 / 4;
++#if LIBAVCODEC_VERSION_INT < ((62 << 16) + (25 << 8) + 100)
+         c->intra_dc_precision = mlt_properties_get_int(properties, "dc") - 8;
++#endif
+ 
+         // Setup dual-pass
+         i = mlt_properties_get_int(properties, "pass");
+@@ -1199,6 +1233,26 @@ static int open_video(mlt_properties properties,
+                          AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM);
+     }
+ 
++#if LIBAVCODEC_VERSION_INT >= ((61 << 16) + (13 << 8) + 100)
++    if (codec) {
++        const enum AVPixelFormat *pix_fmts = NULL;
++        avcodec_get_supported_config(NULL,
++                                     codec,
++                                     AV_CODEC_CONFIG_PIX_FORMAT,
++                                     0,
++                                     (const void **) &pix_fmts,
++                                     NULL);
++        if (pix_fmts) {
++            const enum AVPixelFormat *p = pix_fmts;
++            for (; *p != -1; p++) {
++                if (*p == video_enc->pix_fmt)
++                    break;
++            }
++            if (*p == -1)
++                video_enc->pix_fmt = pix_fmts[0];
++        }
++    }
++#else
+     if (codec && codec->pix_fmts) {
+         const enum AVPixelFormat *p = codec->pix_fmts;
+         for (; *p != -1; p++) {
+@@ -1208,6 +1262,7 @@ static int open_video(mlt_properties properties,
+         if (*p == -1)
+             video_enc->pix_fmt = codec->pix_fmts[0];
+     }
++#endif
+ 
+     const AVPixFmtDescriptor *srcDesc = av_pix_fmt_desc_get(video_enc->pix_fmt);
+     if (srcDesc->flags & AV_PIX_FMT_FLAG_RGB) {


-- 
wbr, Kirill
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.