diff -up k3b-21.12.1/plugins/decoder/ffmpeg/k3bffmpegwrapper.cpp.omv~ k3b-21.12.1/plugins/decoder/ffmpeg/k3bffmpegwrapper.cpp
--- k3b-21.12.1/plugins/decoder/ffmpeg/k3bffmpegwrapper.cpp.omv~	2022-01-17 19:44:11.314744839 +0100
+++ k3b-21.12.1/plugins/decoder/ffmpeg/k3bffmpegwrapper.cpp	2022-01-17 19:55:07.045724184 +0100
@@ -38,7 +38,20 @@ extern "C" {
 #include <math.h>
 
 
+#if LIBAVCODEC_VERSION_MAJOR < 59
 #define FFMPEG_CODEC(s) (s->codec)
+#else
+static QMap<AVStream*,AVCodecContext*> k3b_codec_contexts;
+static inline AVCodecContext *FFMPEG_CODEC(AVStream *s) {
+	if(!k3b_codec_contexts.contains(s)) {
+		const AVCodec *codec = avcodec_find_decoder(s->codecpar->codec_id);
+		AVCodecContext *ctx = avcodec_alloc_context3(codec);
+		avcodec_parameters_to_context(ctx, s->codecpar);
+		k3b_codec_contexts.insert(s, ctx);
+	}
+	return k3b_codec_contexts.value(s);
+}
+#endif
 
 #ifndef HAVE_FFMPEG_AVFORMAT_OPEN_INPUT
 //      this works because the parameters/options are not used
@@ -70,7 +83,7 @@ class K3bFFMpegFile::Private
 {
 public:
     ::AVFormatContext* formatContext;
-    ::AVCodec* codec;
+    const ::AVCodec* codec;
     ::AVStream *audio_stream;
 
     K3b::Msf length;
@@ -320,11 +333,28 @@ int K3bFFMpegFile::fillOutputBuffer()
         }
 
         int gotFrame = 0;
+#if LIBAVCODEC_VERSION_MAJOR < 59
         int len = ::avcodec_decode_audio4(
             FFMPEG_CODEC(d->audio_stream),
             d->frame,
             &gotFrame,
             &d->packet );
+#else
+        int ret = ::avcodec_receive_frame(
+            FFMPEG_CODEC(d->audio_stream),
+            d->frame);
+
+        gotFrame = (ret == 0);
+
+        ret = avcodec_send_packet(
+            FFMPEG_CODEC(d->audio_stream),
+            &d->packet );
+        if (ret < 0) {
+            qDebug() << "(K3bFFMpegFile) decoding failed for " << m_filename;
+            return -1;
+        }
+        int len = d->packet.size;
+#endif
 
         if( d->packetSize <= 0 || len < 0 )
             ::av_packet_unref( &d->packet );
@@ -393,7 +423,9 @@ bool K3bFFMpegFile::seek( const K3b::Msf
 
 K3bFFMpegWrapper::K3bFFMpegWrapper()
 {
+#if LIBAVCODEC_VERSION_MAJOR < 59
     ::av_register_all();
+#endif
 }