Fixed compiling with FFmpeg 5.0

This commit is contained in:
Keith Bowes 2022-02-17 16:46:17 -05:00 committed by Simon Ser
parent 252b2348bd
commit 35b3d67e5f
1 changed files with 3 additions and 2 deletions

View File

@ -1,4 +1,5 @@
#define _POSIX_C_SOURCE 199309L #define _POSIX_C_SOURCE 199309L
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h> #include <libavformat/avformat.h>
#include <libavutil/display.h> #include <libavutil/display.h>
#include <libavutil/hwcontext_drm.h> #include <libavutil/hwcontext_drm.h>
@ -619,12 +620,12 @@ static int init_encoding(struct capture_context *ctx) {
} }
/* Find encoder */ /* Find encoder */
AVCodec *out_codec = avcodec_find_encoder_by_name(ctx->encoder_name); const AVCodec *out_codec = avcodec_find_encoder_by_name(ctx->encoder_name);
if (!out_codec) { if (!out_codec) {
av_log(ctx, AV_LOG_ERROR, "Codec not found (not compiled in lavc?)!\n"); av_log(ctx, AV_LOG_ERROR, "Codec not found (not compiled in lavc?)!\n");
return AVERROR(EINVAL); return AVERROR(EINVAL);
} }
ctx->avf->oformat->video_codec = out_codec->id; ctx->avf->oformat = av_guess_format(ctx->encoder_name, NULL, NULL);
ctx->is_software_encoder = !(out_codec->capabilities & AV_CODEC_CAP_HARDWARE); ctx->is_software_encoder = !(out_codec->capabilities & AV_CODEC_CAP_HARDWARE);
ctx->avctx = avcodec_alloc_context3(out_codec); ctx->avctx = avcodec_alloc_context3(out_codec);