filter/ffmpeg: fix FFmpeg 5.1 deprecation warnings

This commit is contained in:
Max Kellermann
2022-08-08 21:31:49 +02:00
parent bbc088ae4e
commit 7c920ddebe
3 changed files with 27 additions and 2 deletions

View File

@@ -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