git: 473426876567 - main - multimedia/mencoder: Fix build with FFmpeg9

From: Vladimir Druzenko <vvd_at_FreeBSD.org>
Date: Sat, 05 Sep 2026 19:42:33 UTC
The branch main has been updated by vvd:

URL: https://cgit.FreeBSD.org/ports/commit/?id=473426876567b06896d02d38e84eb74ff91654b7

commit 473426876567b06896d02d38e84eb74ff91654b7
Author:     Vladimir Druzenko <vvd@FreeBSD.org>
AuthorDate: 2026-09-05 19:40:13 +0000
Commit:     Vladimir Druzenko <vvd@FreeBSD.org>
CommitDate: 2026-09-05 19:42:29 +0000

    multimedia/mencoder: Fix build with FFmpeg9
    
    PR:             297355, 297361
    Approved by:    blanket
    Sponsored by:   UNIS Labs
---
 multimedia/mencoder/Makefile                       |  4 +---
 multimedia/mplayer/Makefile                        |  1 +
 .../mplayer/files/patch-libmpcodecs_ae__lavc.c     | 22 ++++++++++++++++++++++
 3 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/multimedia/mencoder/Makefile b/multimedia/mencoder/Makefile
index 427d6ce5f8eb..0199ba34d192 100644
--- a/multimedia/mencoder/Makefile
+++ b/multimedia/mencoder/Makefile
@@ -1,14 +1,12 @@
 PORTNAME=	mencoder
 PORTVERSION=	${MPLAYER_PORT_VERSION}.${MPLAYER_SNAPSHOT_DATE:S/-//g}
-PORTREVISION=	1
+PORTREVISION=	2
 CATEGORIES=	multimedia audio
 
 MAINTAINER=	riggs@FreeBSD.org
 COMMENT=	Convenient video file and movie encoder
 WWW=		http://www.mplayerhq.hu/
 
-BROKEN=		Fail to build with FFmpeg 9
-
 .include "${.CURDIR}/../mplayer/Makefile.common"
 
 OPTIONS_DEFINE=	AMR_NB AMR_WB ASS BLURAY CDIO DV DVDNAV FAAC FONTCONFIG \
diff --git a/multimedia/mplayer/Makefile b/multimedia/mplayer/Makefile
index 13f55d895652..7b307b1fc957 100644
--- a/multimedia/mplayer/Makefile
+++ b/multimedia/mplayer/Makefile
@@ -1,5 +1,6 @@
 PORTNAME=	mplayer
 PORTVERSION=	${MPLAYER_PORT_VERSION}.${MPLAYER_SNAPSHOT_DATE:S/-//g}
+PORTREVISION=	1
 CATEGORIES=	multimedia audio
 
 MAINTAINER=	riggs@FreeBSD.org
diff --git a/multimedia/mplayer/files/patch-libmpcodecs_ae__lavc.c b/multimedia/mplayer/files/patch-libmpcodecs_ae__lavc.c
new file mode 100644
index 000000000000..d8df8b2f4692
--- /dev/null
+++ b/multimedia/mplayer/files/patch-libmpcodecs_ae__lavc.c
@@ -0,0 +1,22 @@
+--- libmpcodecs/ae_lavc.c.orig	2024-04-14 12:12:16 UTC
++++ libmpcodecs/ae_lavc.c
+@@ -177,10 +177,16 @@ int mpae_init_lavc(audio_encoder_t *encoder)
+ 	lavc_actx->codec_id = lavc_acodec->id;
+ 	// put sample parameters
+ 	lavc_actx->sample_fmt = AV_SAMPLE_FMT_S16;
+-	if (lavc_acodec->sample_fmts) {
++	const enum AVSampleFormat *sample_fmts;
++#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(61, 3, 100) // FFmpeg 7.0+
++	avcodec_get_supported_config(lavc_actx, lavc_acodec, AV_CODEC_CONFIG_SAMPLE_FORMAT, 0, (const void **)&sample_fmts, NULL);
++#else
++	sample_fmts = lavc_acodec->sample_fmts;
++#endif
++	if (sample_fmts) {
+ 		const enum AVSampleFormat *fmts;
+-		lavc_actx->sample_fmt = lavc_acodec->sample_fmts[0]; // fallback to first format
+-		for (fmts = lavc_acodec->sample_fmts; *fmts != AV_SAMPLE_FMT_NONE; fmts++) {
++		lavc_actx->sample_fmt = sample_fmts[0]; // fallback to first format
++		for (fmts = sample_fmts; *fmts != AV_SAMPLE_FMT_NONE; fmts++) {
+ 			if (samplefmt2affmt(av_get_packed_sample_fmt(*fmts)) == encoder->params.sample_format) { // preferred format found
+ 				lavc_actx->sample_fmt = *fmts;
+ 				break;