diff --git a/src/filter/plugins/FfmpegFilter.cxx b/src/filter/plugins/FfmpegFilter.cxx index 7786407fe..324b88ec2 100644 --- a/src/filter/plugins/FfmpegFilter.cxx +++ b/src/filter/plugins/FfmpegFilter.cxx @@ -40,10 +40,15 @@ FfmpegFilter::FfmpegFilter(const AudioFormat &in_audio_format, buffer_sink(_buffer_sink), in_format(Ffmpeg::ToFfmpegSampleFormat(in_audio_format.format)), in_sample_rate(in_audio_format.sample_rate), +#if LIBAVUTIL_VERSION_INT < AV_VERSION_INT(57, 25, 100) in_channels(in_audio_format.channels), +#endif in_audio_frame_size(in_audio_format.GetFrameSize()), out_audio_frame_size(_out_audio_format.GetFrameSize()) { +#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(57, 25, 100) + av_channel_layout_default(&in_ch_layout, in_audio_format.channels); +#endif } ConstBuffer @@ -54,7 +59,11 @@ FfmpegFilter::FilterPCM(ConstBuffer src) frame.Unref(); frame->format = in_format; frame->sample_rate = in_sample_rate; +#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(57, 25, 100) + frame->ch_layout = in_ch_layout; +#else frame->channels = in_channels; +#endif frame->nb_samples = src.size / in_audio_frame_size; frame.GetBuffer(); diff --git a/src/filter/plugins/FfmpegFilter.hxx b/src/filter/plugins/FfmpegFilter.hxx index e889eb672..6f7c3773c 100644 --- a/src/filter/plugins/FfmpegFilter.hxx +++ b/src/filter/plugins/FfmpegFilter.hxx @@ -35,7 +35,13 @@ class FfmpegFilter final : public Filter { FfmpegBuffer interleave_buffer; - const int in_format, in_sample_rate, in_channels; + const int in_format, in_sample_rate; + +#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(57, 25, 100) + AVChannelLayout in_ch_layout; +#else + const int in_channels; +#endif const size_t in_audio_frame_size; const size_t out_audio_frame_size; diff --git a/src/lib/ffmpeg/DetectFilterFormat.cxx b/src/lib/ffmpeg/DetectFilterFormat.cxx index 7b44eabb4..650394b9f 100644 --- a/src/lib/ffmpeg/DetectFilterFormat.cxx +++ b/src/lib/ffmpeg/DetectFilterFormat.cxx @@ -48,7 +48,11 @@ DetectFilterOutputFormat(const AudioFormat &in_audio_format, Frame frame; frame->format = ToFfmpegSampleFormat(in_audio_format.format); frame->sample_rate = in_audio_format.sample_rate; +#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(57, 25, 100) + av_channel_layout_default(&frame->ch_layout, in_audio_format.channels); +#else frame->channels = in_audio_format.channels; +#endif frame->nb_samples = 1; frame.GetBuffer(); @@ -75,8 +79,14 @@ DetectFilterOutputFormat(const AudioFormat &in_audio_format, if (sample_format == SampleFormat::UNDEFINED) throw std::runtime_error("Unsupported FFmpeg sample format"); +#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(57, 25, 100) + const unsigned out_channels = frame->ch_layout.nb_channels; +#else + const unsigned out_channels = frame->channels; +#endif + return CheckAudioFormat(frame->sample_rate, sample_format, - frame->channels); + out_channels); } } // namespace Ffmpeg