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)