[FFmpeg-devel] [PATCH 5/7] fftools/ffplay: use AV_BUFFERSINK_FLAG_PARAMS
Anton Khirnov
anton at khirnov.net
Mon Sep 23 18:01:43 EEST 2024
---
fftools/ffplay.c | 20 +++++++++++++++++---
1 file changed, 17 insertions(+), 3 deletions(-)
diff --git a/fftools/ffplay.c b/fftools/ffplay.c
index 4ea48e11bb..ef45f12906 100644
--- a/fftools/ffplay.c
+++ b/fftools/ffplay.c
@@ -2702,6 +2702,7 @@ static int stream_component_open(VideoState *is, int stream_index)
case AVMEDIA_TYPE_AUDIO:
{
AVFilterContext *sink;
+ AVFrame *params = NULL;
is->audio_filter_src.freq = avctx->sample_rate;
ret = av_channel_layout_copy(&is->audio_filter_src.ch_layout, &avctx->ch_layout);
@@ -2711,10 +2712,23 @@ static int stream_component_open(VideoState *is, int stream_index)
if ((ret = configure_audio_filters(is, afilters, 0)) < 0)
goto fail;
sink = is->out_audio_filter;
- sample_rate = av_buffersink_get_sample_rate(sink);
- ret = av_buffersink_get_ch_layout(sink, &ch_layout);
- if (ret < 0)
+
+ params = av_frame_alloc();
+ if (!params) {
+ ret = AVERROR(ENOMEM);
goto fail;
+ }
+
+ ret = av_buffersink_get_frame_flags(sink, params, AV_BUFFERSINK_FLAG_PARAMS);
+ if (ret < 0) {
+ av_frame_free(¶ms);
+ goto fail;
+ }
+
+ sample_rate = params->sample_rate;
+ FFSWAP(AVChannelLayout, ch_layout, params->ch_layout);
+
+ av_frame_free(¶ms);
}
/* prepare audio output */
--
2.43.0
More information about the ffmpeg-devel
mailing list