@@ -207,8 +207,7 @@ struct Stream
207207 }
208208
209209 if (codec->type == AVMEDIA_TYPE_VIDEO) {
210- FF (avfilter_graph_create_filter (
211- &sink, avfilter_get_by_name (" buffersink" ), " out" , nullptr , nullptr , graph.get ()));
210+ sink = FFMEM (avfilter_graph_alloc_filter (graph.get (), avfilter_get_by_name (" buffersink" ), " out" ));
212211
213212#ifdef _MSC_VER
214213#pragma warning(push)
@@ -217,20 +216,49 @@ struct Stream
217216 // TODO codec->profiles
218217 // TODO FF(av_opt_set_int_list(sink, "framerates", codec->supported_framerates, { 0, 0 },
219218 // AV_OPT_SEARCH_CHILDREN));
219+ #if LIBAVUTIL_VERSION_MAJOR >= 60 // FFmpeg 8
220+ const void * pix_fmts;
221+ int nb_pix_fmts = 0 ;
222+ FF (avcodec_get_supported_config (nullptr , codec, AV_CODEC_CONFIG_PIX_FORMAT, 0 , &pix_fmts, &nb_pix_fmts));
223+
224+ FF (av_opt_set_array (sink, " pixel_formats" , AV_OPT_SEARCH_CHILDREN | AV_OPT_ARRAY_REPLACE,
225+ 0 , nb_pix_fmts, AV_OPT_TYPE_PIXEL_FMT, pix_fmts)
226+ );
227+ #else
220228 FF (av_opt_set_int_list (sink, " pix_fmts" , codec->pix_fmts , -1 , AV_OPT_SEARCH_CHILDREN));
229+ #endif
230+
221231#ifdef _MSC_VER
222232#pragma warning(pop)
223233#endif
224234 } else if (codec->type == AVMEDIA_TYPE_AUDIO) {
225- FF (avfilter_graph_create_filter (
226- &sink, avfilter_get_by_name (" abuffersink" ), " out" , nullptr , nullptr , graph.get ()));
235+ sink = FFMEM (avfilter_graph_alloc_filter (graph.get (), avfilter_get_by_name (" abuffersink" ), " out" ));
227236#ifdef _MSC_VER
228237#pragma warning(push)
229238#pragma warning(disable : 4245)
230239#endif
231240 // TODO codec->profiles
241+
242+ #if LIBAVUTIL_VERSION_MAJOR >= 60 // FFmpeg 8
243+ const void * sample_fmts;
244+ int nb_sample_fmts = 0 ;
245+ FF (avcodec_get_supported_config (nullptr , codec, AV_CODEC_CONFIG_SAMPLE_FORMAT, 0 , &sample_fmts, &nb_sample_fmts));
246+
247+ FF (av_opt_set_array (sink, " sample_formats" , AV_OPT_SEARCH_CHILDREN | AV_OPT_ARRAY_REPLACE,
248+ 0 , nb_sample_fmts, AV_OPT_TYPE_SAMPLE_FMT, sample_fmts)
249+ );
250+
251+ const void * sample_rates;
252+ int nb_sample_rates = 0 ;
253+ FF (avcodec_get_supported_config (nullptr , codec, AV_CODEC_CONFIG_SAMPLE_RATE, 0 , &sample_rates, &nb_sample_rates));
254+
255+ FF (av_opt_set_array (sink, " samplerates" , AV_OPT_SEARCH_CHILDREN | AV_OPT_ARRAY_REPLACE,
256+ 0 , nb_sample_rates, AV_OPT_TYPE_INT, sample_rates)
257+ );
258+ #else
232259 FF (av_opt_set_int_list (sink, " sample_fmts" , codec->sample_fmts , -1 , AV_OPT_SEARCH_CHILDREN));
233260 FF (av_opt_set_int_list (sink, " sample_rates" , codec->supported_samplerates , 0 , AV_OPT_SEARCH_CHILDREN));
261+ #endif
234262
235263#if FFMPEG_NEW_CHANNEL_LAYOUT
236264 // TODO: need to translate codec->ch_layouts into something that can be passed via av_opt_set_*
@@ -247,6 +275,8 @@ struct Stream
247275 << boost::errinfo_errno (EINVAL) << msg_info_t (" invalid output media type" ));
248276 }
249277
278+ FF (avfilter_init_str (sink, nullptr ));
279+
250280 {
251281 const auto cur = outputs;
252282
0 commit comments