encoders/ffmpeg: Support for FFmpeg versions older than 58.x

This commit is contained in:
Michael Fabian 'Xaymar' Dirks 2020-08-10 16:23:50 +02:00
parent 012027578a
commit c445865111

View file

@ -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<ffmpeg_factory>(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::handler> handler)