From 315b996ab350f53efec10574ef84ebd4ebee7073 Mon Sep 17 00:00:00 2001 From: Michael Fabian 'Xaymar' Dirks Date: Mon, 10 Aug 2020 16:23:50 +0200 Subject: [PATCH] encoders/ffmpeg: Support for FFmpeg versions older than 58.x --- source/encoders/encoder-ffmpeg.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/source/encoders/encoder-ffmpeg.cpp b/source/encoders/encoder-ffmpeg.cpp index 2a6ce6d5..eb62c3be 100644 --- a/source/encoders/encoder-ffmpeg.cpp +++ b/source/encoders/encoder-ffmpeg.cpp @@ -1115,6 +1115,7 @@ ffmpeg_manager::~ffmpeg_manager() void ffmpeg_manager::register_encoders() { // Encoders +#if FF_API_NEXT void* iterator = nullptr; for (const AVCodec* codec = av_codec_iterate(&iterator); codec != nullptr; codec = av_codec_iterate(&iterator)) { // Only register encoders. @@ -1129,6 +1130,22 @@ void ffmpeg_manager::register_encoders() } } } +#else + AVCodec* codec = nullptr; + for (codec = av_codec_next(codec); codec != nullptr; codec = av_codec_next(codec)) { + // Only register encoders. + if (!av_codec_is_encoder(codec)) + continue; + + if ((codec->type == AVMediaType::AVMEDIA_TYPE_AUDIO) || (codec->type == AVMediaType::AVMEDIA_TYPE_VIDEO)) { + try { + _factories.emplace(codec, std::make_shared(codec)); + } catch (const std::exception& ex) { + DLOG_ERROR("Failed to register encoder '%s': %s", codec->id, ex.what()); + } + } + } +#endif } void ffmpeg_manager::register_handler(std::string codec, std::shared_ptr handler)