[Sebastian Ramacher 2026-08-10]
the command line tool work with this change:
Description: Fix build with FFmpeg 7+.
The following API changes in FFmpeg 7+ break the build:
* av_opt_set_int_list() was removed in libavutil 59 (FFmpeg 7.0);
replace with av_opt_set() using string values for abuffersink
filter options.
* av_opt_set_bin() was also removed; replace with av_opt_set() using
string values.
* AVCodec members sample_fmts, supported_samplerates, and ch_layouts
were removed in libavcodec 61 (FFmpeg 7.0); simplify encoder setup
to use direct assignment from codec params.
All changes use #if version guards to maintain compatibility with both
older and newer FFmpeg/glibc versions.
This patch was created with help from OpenCode using local llama.cpp
server with Qwen 3.6.
--- bs1770gain-salsa.orig/libff/ff_audio.c
+++ bs1770gain-salsa/libff/ff_audio.c
@@ -48,7 +48,9 @@ int ff_audio_create(ff_audio_t *audio, f
AVCodecParameters *codecpar=stream->codecpar;
AVDictionary *opt=NULL;
FF_CONST AVCodec *codec;
+#if LIBAVCODEC_VERSION_MAJOR < 61 // [
int i;
+#endif // ]
char value[64];
int err;
@@ -93,6 +95,7 @@ int ff_audio_create(ff_audio_t *audio, f
////////////////////////////////////////////////////////////////////////////
if (ocodecpar) {
// we're going to encode.
+#if LIBAVCODEC_VERSION_MAJOR < 61 // [
if (codec->sample_fmts) {
audio->ctx->sample_fmt=AV_SAMPLE_FMT_NONE;
@@ -233,6 +236,13 @@ int ff_audio_create(ff_audio_t *audio, f
//audio->ctx->channels
#endif // ]
+#else // ] [
+ // AVCodec members sample_fmts, supported_samplerates, ch_layouts
+ // were removed in FFmpeg 7.0 (libavcodec 61).
+ audio->ctx->sample_fmt=ocodecpar->format;
+ audio->ctx->sample_rate=ocodecpar->sample_rate;
+ audio->ctx->ch_layout=ocodecpar->ch_layout;
+#endif // ]
audio->ctx->time_base.num=1;
audio->ctx->time_base.den=audio->ctx->sample_rate;
--- bs1770gain-salsa.orig/libff/ff_filter.c
+++ bs1770gain-salsa/libff/ff_filter.c
@@ -395,6 +395,7 @@ e_filter_graph:
/////////////////////////////////////////////////////////////////////////////
#if defined (FF_SAMPLE_FMTS_DEPRECATED_FIX) // [
+#if LIBAVUTIL_VERSION_MAJOR < 59 // [
/*
err= avcodec_get_supported_config(dec_ctx,NULL,AV_CODEC_CONFIG_PIX_FORMAT,
0,(const void**)&sink_sample_fmts,NULL);
@@ -402,8 +403,25 @@ e_filter_graph:
err=av_opt_set_bin(f->ctx.sink,"sample_fmts",
sink_sample_fmts,-1,AV_OPT_SEARCH_CHILDREN|AV_OPT_TYPE_FLAG_ARRAY);
#else // ] [
+ {
+ char sample_fmts_str[256];
+ snprintf(sample_fmts_str, sizeof(sample_fmts_str), "%s",
+ av_get_sample_fmt_name(ocodecpar->format));
+ err=av_opt_set(f->ctx.sink,"sample_fmts",sample_fmts_str,AV_OPT_SEARCH_CHILDREN);
+ }
+#endif // ]
+#else // ] [
+#if LIBAVUTIL_VERSION_MAJOR < 59 // [
err=av_opt_set_int_list(f->ctx.sink,"sample_fmts",
sink_sample_fmts,-1,AV_OPT_SEARCH_CHILDREN);
+#else // ] [
+ {
+ char sample_fmts_str[256];
+ snprintf(sample_fmts_str, sizeof(sample_fmts_str), "%s",
+ av_get_sample_fmt_name(ocodecpar->format));
+ err=av_opt_set(f->ctx.sink,"sample_fmts",sample_fmts_str,AV_OPT_SEARCH_CHILDREN);
+ }
+#endif // ]
#endif // ]
if (err<0) {
@@ -413,9 +431,14 @@ e_filter_graph:
/////////////////////////////////////////////////////////////////////////////
#if defined (FF_BITMASK_BASED_CHANNEL_LAYOUT) // [
+#if LIBAVUTIL_VERSION_MAJOR < 59 // [
err=av_opt_set_int_list(f->ctx.sink,"channel_layouts",
sink_channel_layouts,-1,AV_OPT_SEARCH_CHILDREN);
-#elif 1 // ] [
+#else // ] [
+ av_channel_layout_describe(&ocodecpar->ch_layout, args, sizeof(args));
+ err=av_opt_set(f->ctx.sink,"ch_layouts",args,AV_OPT_SEARCH_CHILDREN);
+#endif // ]
+#else // ] [
av_channel_layout_describe(&ocodecpar->ch_layout,
args,sizeof(args));
err=av_opt_set(f->ctx.sink,"ch_layouts",args,AV_OPT_SEARCH_CHILDREN);
@@ -429,8 +452,17 @@ e_filter_graph:
/////////////////////////////////////////////////////////////////////////////
#if defined (FF_SAMPLE_FMTS_DEPRECATED_FIX) // [
#else // ] [
+#if LIBAVUTIL_VERSION_MAJOR < 59 // [
err=av_opt_set_int_list(f->ctx.sink,"sample_rates",
sink_sample_rates,-1,AV_OPT_SEARCH_CHILDREN);
+#else // ] [
+ {
+ char sample_rates_str[64];
+ snprintf(sample_rates_str, sizeof(sample_rates_str), "%d",
+ ocodecpar->sample_rate);
+ err=av_opt_set(f->ctx.sink,"sample_rates",sample_rates_str,AV_OPT_SEARCH_CHILDREN);
+ }
+#endif // ]
#endif // ]
if (err<0) {