适配FFmpeg7.1 (#4102)

ffmpeg中FF_API_OLD_CHANNEL_LAYOUT系列API在2024年3月的提交中已经正式移除了,对应release7.0,使用ffmpeg7.0及以上版本编译zlm会报错。
This commit is contained in:
Dary
2025-01-12 10:16:45 +08:00
committed by GitHub
parent ac6bb9b332
commit f3026f5df0
3 changed files with 62 additions and 4 deletions

View File

@@ -97,7 +97,13 @@ int main(int argc, char *argv[]) {
decoder->setOnDecode([audio_player, swr](const FFmpegFrame::Ptr &frame) mutable {
if (!swr) {
# if LIBAVCODEC_VERSION_INT >= FF_CODEC_VER_7_1
swr = std::make_shared<FFmpegSwr>(AV_SAMPLE_FMT_S16, &(frame->get()->ch_layout), frame->get()->sample_rate);
#else
swr = std::make_shared<FFmpegSwr>(AV_SAMPLE_FMT_S16, frame->get()->channels, frame->get()->channel_layout, frame->get()->sample_rate);
#endif
}
auto pcm = swr->inputFrame(frame);
auto len = pcm->get()->nb_samples * pcm->get()->channels * av_get_bytes_per_sample((enum AVSampleFormat)pcm->get()->format);