diff --git a/media-tv/kodi/Manifest b/media-tv/kodi/Manifest
index 0fad6b3..cbcf6f1 100644
--- a/media-tv/kodi/Manifest
+++ b/media-tv/kodi/Manifest
@@ -1,7 +1,7 @@
AUX kodi-20.1-SavestateFlatBuffer-Remove-forward-declararion-of-FlatBufferBuilder.patch 1333 BLAKE2B 3debed4353672cdcf9215496ffc6d17c7427111b3be1e49497f16ead7f5e72411d811775e12cb5d1a0307ad48fa9f46bdc110e436c7f51416af2e3cdcc2e3540 SHA512 8447aaec6a56c9ba8f58658625cac2dc54f1266e0bfeccb29b0771e75b92818dd93d6275423cc8da4e74c9ff530008da0d50473bcb9bc92acfe72e2da06eb1a2
AUX kodi-20.1-VideoPlayerAudio-invalidate-previous-sync-type-after-Audio.patch 1010 BLAKE2B e623854a71f0b53b90950fbbf71ee4d666a24c3071c6ae8489d476a8407068e01028a69c8ec5cbff909a646dd15efe7a1807aeee214995ae1486281bce309e30 SHA512 3db461ebad0f922fab7727e902beada28b5b43e2b71d9c6e39bdf9b2a7767d214ea6caf3a975649a27ba77b7a9a93d5e7b1df6c1ec0edf61223855e2463d5115
AUX kodi-20.1-ffmpeg5.patch 94498 BLAKE2B f8244260911df037ec6cdf945fe19dae7e71e98c052c0ce3ec4c9bf5459205bef7696af599b00a86d5b554d0cbc674fed6f7835a45dd6df40ae4e83549e55175 SHA512 9dc21d7e41eac956816330e79e826456566a88c5fdc747be234fe873ff3b9e7241d87dcc6ecd804189fff8b61c027ac4e31e1af0da5de0537f91e8f51b3d96c5
-AUX kodi-20.2-ffmpeg6.patch 87835 BLAKE2B 796e989fee6867278c67f1b5ad2b23b0bef5690dc8a7663b6952261ac7f1e42c7d2cae2174acb312e1983aea50945db638a254f46503ec4ade580999313007b4 SHA512 82c5f1cbba785ebea003dcfc9316acc4445bbad7ded65a2160dd40527ca0806492d7eec683669696714289c0c40807734477d666091021ee22a85456769df959
+AUX kodi-20.2-ffmpeg6.patch 24798 BLAKE2B d9ed0a7e8d0d873f46ffe95e84eefb94ca4f5328da80a447acd3996971b3b913a2ce249ddf8b5c4019db58e5fdb158b2c5d1034cd3962c8ca6d6aab34e9c6f15 SHA512 3e419a882a112bc9c12078f9c8f8c31c6eb5546f12e71e558f31a862ac8119999aa1e63c8e42cc654361534024e0483288da3bec62a45c601ecf7694c04a66c2
DIST ffmpeg-kodi-4.4.1-Nexus-Alpha1.tar.gz 13725564 BLAKE2B 51d310e7000aeba657d55341c5fdb540474e197b85062228ab4b314c8309ec11985aa7f105193333fc6106529e8e58c86eafe268190894be8532d0e0b9065fa6 SHA512 8beb04d577b5251e74b0d52f4d130997a8ba94bbd488c7c8309e6b45095c27807e150212888ce3a384b23dff52f8df1a7bde5407bae924ddc363f8125c0616c5
DIST kodi-20.1-Nexus.tar.gz 54584529 BLAKE2B 32c945d7dbdcbfed4f319a91f445b6fd49de7fdcd59b2269aea46d7bc6b52677938800dbe9fba86e6e0451d86bb3afc80be6dd4f6f2fb83f6b2e3eb7375e2f8b SHA512 648df0649a0443d884b9414f43be4253764f1aaf9072aa8111e5a8a217c8291024ce1f27c2f7f673ac24005b32cc7dd25d86e99fc68166e3d5a637ae36b20f02
DIST kodi-20.2-Nexus.tar.gz 54587775 BLAKE2B 05c90cf9559f1e98c58deb5edd51c91d8ce60f75f13669e33c7168913870d13ca0ef68615834d9a6dd47c8f563ed591c1d43ec70e579938fb2f3251725538842 SHA512 ddeaa626f324817f6d038fd1eaeb851d0006156fa9ef96ef475932ec50c64cbdcc7ce8b93ceea0d8bfcd1f24edc1c9d0c4a97a163a615842a9fb698e5393f7ca
diff --git a/media-tv/kodi/files/kodi-20.2-ffmpeg6.patch b/media-tv/kodi/files/kodi-20.2-ffmpeg6.patch
index b7e0031..97398ff 100644
--- a/media-tv/kodi/files/kodi-20.2-ffmpeg6.patch
+++ b/media-tv/kodi/files/kodi-20.2-ffmpeg6.patch
@@ -1,710 +1,624 @@
-
-
-
-
-
-
-
-debian/patches/workarounds/0004-ffmpeg6.patch · debian/sid · Debian Multimedia Team / kodi / kodi · GitLab
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+From c9e25dc15acf1214b079da7021ad89acf85fa77d Mon Sep 17 00:00:00 2001
+From: CastagnaIT
+Date: Sun, 29 Jan 2023 17:51:51 +0100
+Subject: [PATCH] [VideoPlayerVideo] Log an error when codec extradata is
+ required
+
+---
+ xbmc/cores/VideoPlayer/VideoPlayerVideo.cpp | 5 ++++-
+ 1 file changed, 4 insertions(+), 1 deletion(-)
+
+diff --git a/xbmc/cores/VideoPlayer/VideoPlayerVideo.cpp b/xbmc/cores/VideoPlayer/VideoPlayerVideo.cpp
+index 20f6b3b1cb51d..38f63f0766718 100644
+--- a/xbmc/cores/VideoPlayer/VideoPlayerVideo.cpp
++++ b/xbmc/cores/VideoPlayer/VideoPlayerVideo.cpp
+@@ -114,8 +114,11 @@ bool CVideoPlayerVideo::OpenStream(CDVDStreamInfo hint)
+ hint.codec == AV_CODEC_ID_WMV3 ||
+ hint.codec == AV_CODEC_ID_VC1 ||
+ hint.codec == AV_CODEC_ID_AV1)
+- // clang-format on
++ {
++ CLog::LogF(LOGERROR, "Codec id {} require extradata.", hint.codec);
+ return false;
++ }
++ // clang-format on
+ }
+
+ CLog::Log(LOGINFO, "Creating video codec with codec id: {}", hint.codec);
+
+
+From 2559466404d342428d43076bf90fcacc24313af0 Mon Sep 17 00:00:00 2001
+From: enen92 <92enen@gmail.com>
+Date: Mon, 6 Feb 2023 15:36:11 +0000
+Subject: [PATCH] video: remove ffmpeg bsf hack
+
+Manually setting the codecID on the bsf filter is wrong.
+avcodec_parameters_copy should be used instead.
+---
+ xbmc/cores/FFmpeg.cpp | 13 ++++++++-----
+ xbmc/cores/FFmpeg.h | 3 +--
+ .../VideoPlayer/DVDDemuxers/DVDDemuxClient.cpp | 10 +++++++++-
+ .../VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.cpp | 3 +--
+ 4 files changed, 19 insertions(+), 10 deletions(-)
+
+diff --git a/xbmc/cores/FFmpeg.cpp b/xbmc/cores/FFmpeg.cpp
+index d071f6d8e33a3..73b7ea2ae875c 100644
+--- a/xbmc/cores/FFmpeg.cpp
++++ b/xbmc/cores/FFmpeg.cpp
+@@ -135,9 +135,7 @@ void ff_avutil_log(void* ptr, int level, const char* format, va_list va)
+ buffer.erase(0, start);
+ }
+
+-std::tuple GetPacketExtradata(const AVPacket* pkt,
+- const AVCodecParserContext* parserCtx,
+- AVCodecContext* codecCtx)
++std::tuple GetPacketExtradata(const AVPacket* pkt, const AVCodecParameters* codecPar)
+ {
+ constexpr int FF_MAX_EXTRADATA_SIZE = ((1 << 28) - AV_INPUT_BUFFER_PADDING_SIZE);
+
+@@ -151,7 +149,7 @@ std::tuple GetPacketExtradata(const AVPacket* pkt,
+ * for certain codecs, as noted in discussion of PR#21248
+ */
+
+- AVCodecID codecId = codecCtx->codec_id;
++ AVCodecID codecId = codecPar->codec_id;
+
+ // clang-format off
+ if (
+@@ -178,7 +176,12 @@ std::tuple GetPacketExtradata(const AVPacket* pkt,
+ if (ret < 0)
+ return std::make_tuple(nullptr, 0);
+
+- bsf->par_in->codec_id = codecId;
++ ret = avcodec_parameters_copy(bsf->par_in, codecPar);
++ if (ret < 0)
++ {
++ av_bsf_free(&bsf);
++ return std::make_tuple(nullptr, 0);
++ }
+
+ ret = av_bsf_init(bsf);
+ if (ret < 0)
+diff --git a/xbmc/cores/FFmpeg.h b/xbmc/cores/FFmpeg.h
+index 05547a0ba2b5f..5e35d58c6b0a6 100644
+--- a/xbmc/cores/FFmpeg.h
++++ b/xbmc/cores/FFmpeg.h
+@@ -73,5 +73,4 @@ class CFFmpegLog
+ };
+
+ std::tuple GetPacketExtradata(const AVPacket* pkt,
+- const AVCodecParserContext* parserCtx,
+- AVCodecContext* codecCtx);
++ const AVCodecParameters* codecPar);
+diff --git a/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxClient.cpp b/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxClient.cpp
+index 052332331702a..9ca07b9a2dd39 100644
+--- a/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxClient.cpp
++++ b/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxClient.cpp
+@@ -162,7 +162,15 @@ bool CDVDDemuxClient::ParsePacket(DemuxPacket* pkt)
+ avpkt->size = pkt->iSize;
+ avpkt->dts = avpkt->pts = AV_NOPTS_VALUE;
+
+- auto [retExtraData, len] = GetPacketExtradata(avpkt, stream->m_parser, stream->m_context);
++ AVCodecParameters* codecPar = nullptr;
++ int ret = avcodec_parameters_from_context(codecPar, stream->m_context);
++ if (ret < 0)
++ {
++ CLog::LogF(LOGERROR, "avcodec_parameters_from_context failed");
++ return false;
++ }
++
++ auto [retExtraData, len] = GetPacketExtradata(avpkt, codecPar);
+ if (len > 0)
+ {
+ st->changes++;
+diff --git a/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.cpp b/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.cpp
+index 7e6a2e10616d7..bc6b54c87235d 100644
+--- a/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.cpp
++++ b/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.cpp
+@@ -2290,8 +2290,7 @@ void CDVDDemuxFFmpeg::ParsePacket(AVPacket* pkt)
+ parser->second->m_parserCtx->parser &&
+ !st->codecpar->extradata)
+ {
+- auto [retExtraData, i] =
+- GetPacketExtradata(pkt, parser->second->m_parserCtx, parser->second->m_codecCtx);
++ auto [retExtraData, i] = GetPacketExtradata(pkt, st->codecpar);
+ if (i > 0)
+ {
+ st->codecpar->extradata_size = i;
+
+
+From f30f1e6418ea60bc7cb081c59f5f1d9431d264e6 Mon Sep 17 00:00:00 2001
+From: Lukas Rusak
+Date: Sat, 11 Mar 2023 13:28:38 -0800
+Subject: [PATCH 01/10] CDVDAudioCodecFFmpeg: ifdef use of
+ AV_CODEC_FLAG_TRUNCATED for ffmpeg 6.0
+
+Signed-off-by: Lukas Rusak
+---
+ xbmc/cores/VideoPlayer/DVDCodecs/Audio/DVDAudioCodecFFmpeg.cpp | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Audio/DVDAudioCodecFFmpeg.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/Audio/DVDAudioCodecFFmpeg.cpp
+index b2849c797dbc4..325bb0b7549ab 100644
+--- a/xbmc/cores/VideoPlayer/DVDCodecs/Audio/DVDAudioCodecFFmpeg.cpp
++++ b/xbmc/cores/VideoPlayer/DVDCodecs/Audio/DVDAudioCodecFFmpeg.cpp
+@@ -73,8 +73,10 @@ bool CDVDAudioCodecFFmpeg::Open(CDVDStreamInfo &hints, CDVDCodecOptions &options
+ m_pCodecContext->debug = 0;
+ m_pCodecContext->workaround_bugs = 1;
+
++#if LIBAVCODEC_VERSION_MAJOR < 60
+ if (pCodec->capabilities & AV_CODEC_CAP_TRUNCATED)
+ m_pCodecContext->flags |= AV_CODEC_FLAG_TRUNCATED;
++#endif
+
+ m_matrixEncoding = AV_MATRIX_ENCODING_NONE;
+ m_channels = 0;
+
+From 3b71910ee0bb650816456ecc9a21251aff650c4d Mon Sep 17 00:00:00 2001
+From: Lukas Rusak
+Date: Sat, 11 Mar 2023 13:29:18 -0800
+Subject: [PATCH 02/10] CDVDAudioCodecFFmpeg: fix setting channel layout mask
+ when opening codec
+
+Signed-off-by: Lukas Rusak
+---
+ .../DVDCodecs/Audio/DVDAudioCodecFFmpeg.cpp | 17 ++++++++++++++---
+ 1 file changed, 14 insertions(+), 3 deletions(-)
+
+diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Audio/DVDAudioCodecFFmpeg.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/Audio/DVDAudioCodecFFmpeg.cpp
+index 325bb0b7549ab..d1fb2cfe96afc 100644
+--- a/xbmc/cores/VideoPlayer/DVDCodecs/Audio/DVDAudioCodecFFmpeg.cpp
++++ b/xbmc/cores/VideoPlayer/DVDCodecs/Audio/DVDAudioCodecFFmpeg.cpp
+@@ -80,13 +80,21 @@
+ m_channels = 0;
+ #if LIBAVCODEC_BUILD >= AV_VERSION_INT(59, 37, 100) && \
+ LIBAVUTIL_BUILD >= AV_VERSION_INT(57, 28, 100)
+- av_channel_layout_uninit(&m_pCodecContext->ch_layout);
+- m_pCodecContext->ch_layout.order = AV_CHANNEL_ORDER_NATIVE;
+- m_pCodecContext->ch_layout.nb_channels = hints.channels;
++ if (hints.channels > 0 && hints.channellayout > 0)
++ {
++ m_pCodecContext->ch_layout.order = AV_CHANNEL_ORDER_NATIVE;
++ m_pCodecContext->ch_layout.nb_channels = hints.channels;
++ m_pCodecContext->ch_layout.u.mask = hints.channellayout;
++ }
++ else if (hints.channels > 0)
++ {
++ av_channel_layout_default(&m_pCodecContext->ch_layout, hints.channels);
++ }
++
++ m_hint_layout = m_pCodecContext->ch_layout.u.mask;
+ #else
+ m_pCodecContext->channels = hints.channels;
+ #endif
+- m_hint_layout = hints.channellayout;
+ m_pCodecContext->sample_rate = hints.samplerate;
+ m_pCodecContext->block_align = hints.blockalign;
+ m_pCodecContext->bit_rate = hints.bitrate;
+
+From f4fadb3ba4583c45fb06908a3eb352be8c29f235 Mon Sep 17 00:00:00 2001
+From: Lukas Rusak
+Date: Sat, 11 Mar 2023 13:29:34 -0800
+Subject: [PATCH 03/10] CDVDAudioCodecFFmpeg: drop unneeded use of
+ AVFMT_FLAG_PRIV_OPT
+
+Signed-off-by: Lukas Rusak
+---
+ xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.cpp | 2 --
+ 1 file changed, 2 deletions(-)
+
+diff --git a/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.cpp b/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.cpp
+index bc6b54c87235d..016d198206716 100644
+--- a/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.cpp
++++ b/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.cpp
+@@ -323,7 +323,6 @@ bool CDVDDemuxFFmpeg::Open(const std::shared_ptr& pInput, bool
+ }
+ if (result < 0)
+ {
+- m_pFormatContext->flags |= AVFMT_FLAG_PRIV_OPT;
+ if (avformat_open_input(&m_pFormatContext, strFile.c_str(), iformat, &options) < 0)
+ {
+ CLog::Log(LOGDEBUG, "Error, could not open file {}", CURL::GetRedacted(strFile));
+@@ -335,7 +334,6 @@ bool CDVDDemuxFFmpeg::Open(const std::shared_ptr& pInput, bool
+ avformat_close_input(&m_pFormatContext);
+ m_pFormatContext = avformat_alloc_context();
+ m_pFormatContext->interrupt_callback = int_cb;
+- m_pFormatContext->flags &= ~AVFMT_FLAG_PRIV_OPT;
+ AVDictionary* options = GetFFMpegOptionsFromInput();
+ av_dict_set_int(&options, "load_all_variants", 0, AV_OPT_SEARCH_CHILDREN);
+ if (avformat_open_input(&m_pFormatContext, strFile.c_str(), iformat, &options) < 0)
+
+From 7d03f33b83e5fb127a7495798a20c3b63ac06795 Mon Sep 17 00:00:00 2001
+From: Lukas Rusak
+Date: Wed, 15 Mar 2023 19:58:56 -0700
+Subject: [PATCH 04/10] CDVDVideoCodecFFmpeg: update filter args to use
+ key/value pairs
+
+Signed-off-by: Lukas Rusak
+---
+ .../VideoPlayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp | 5 +++--
+ 1 file changed, 3 insertions(+), 2 deletions(-)
+
+diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp
+index bb9c20bf9d06e..c080589896ce7 100644
+--- a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp
++++ b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp
+@@ -1164,8 +1164,9 @@ int CDVDVideoCodecFFmpeg::FilterOpen(const std::string& filters, bool scale)
+ const AVFilter* outFilter = avfilter_get_by_name("buffersink"); // should be last filter in the graph for now
+
+ std::string args = StringUtils::Format(
+- "{}:{}:{}:{}:{}:{}:{}", m_pCodecContext->width, m_pCodecContext->height,
+- m_pCodecContext->pix_fmt, m_pCodecContext->time_base.num ? m_pCodecContext->time_base.num : 1,
++ "video_size={}x{}:pix_fmt={}:time_base={}/{}:pixel_aspect={}/{}", m_pCodecContext->width,
++ m_pCodecContext->height, m_pCodecContext->pix_fmt,
++ m_pCodecContext->time_base.num ? m_pCodecContext->time_base.num : 1,
+ m_pCodecContext->time_base.num ? m_pCodecContext->time_base.den : 1,
+ m_pCodecContext->sample_aspect_ratio.num != 0 ? m_pCodecContext->sample_aspect_ratio.num : 1,
+ m_pCodecContext->sample_aspect_ratio.num != 0 ? m_pCodecContext->sample_aspect_ratio.den : 1);
+
+From 30bd7912802cf0f608751c452c48fc1a2eb8d91b Mon Sep 17 00:00:00 2001
+From: Lukas Rusak
+Date: Wed, 15 Mar 2023 19:59:27 -0700
+Subject: [PATCH 05/10] CFFmpegPostproc: update filter args to use key/value
+ pairs
+
+Signed-off-by: Lukas Rusak
+---
+ xbmc/cores/VideoPlayer/DVDCodecs/Video/VAAPI.cpp | 9 +++++----
+ 1 file changed, 5 insertions(+), 4 deletions(-)
+
+diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Video/VAAPI.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/Video/VAAPI.cpp
+index 81b969d119667..6c4f664591a04 100644
+--- a/xbmc/cores/VideoPlayer/DVDCodecs/Video/VAAPI.cpp
++++ b/xbmc/cores/VideoPlayer/DVDCodecs/Video/VAAPI.cpp
+@@ -2962,10 +2962,11 @@ bool CFFmpegPostproc::Init(EINTERLACEMETHOD method)
+ const AVFilter* srcFilter = avfilter_get_by_name("buffer");
+ const AVFilter* outFilter = avfilter_get_by_name("buffersink");
+
+- std::string args = StringUtils::Format("{}:{}:{}:{}:{}:{}:{}", m_config.vidWidth,
+- m_config.vidHeight, AV_PIX_FMT_NV12, 1, 1,
+- (m_config.aspect.num != 0) ? m_config.aspect.num : 1,
+- (m_config.aspect.num != 0) ? m_config.aspect.den : 1);
++ std::string args =
++ StringUtils::Format("video_size={}x{}:pix_fmt={}:time_base={}/{}:pixel_aspect={}/{}",
++ m_config.vidWidth, m_config.vidHeight, AV_PIX_FMT_NV12, 1, 1,
++ (m_config.aspect.num != 0) ? m_config.aspect.num : 1,
++ (m_config.aspect.num != 0) ? m_config.aspect.den : 1);
+
+ if (avfilter_graph_create_filter(&m_pFilterIn, srcFilter, "src", args.c_str(), NULL, m_pFilterGraph) < 0)
+ {
+
+From 54a21151374a2d40a2a452fae2709205ed8e8836 Mon Sep 17 00:00:00 2001
+From: Lukas Rusak
+Date: Sat, 11 Mar 2023 19:32:09 -0800
+Subject: [PATCH 08/10] DXVA: CDecoder: replace removed av_mallocz_array with
+ av_calloc
+
+ref: https://ffmpeg.org/doxygen/5.0/group__lavu__mem__funcs.html\#ga6627f140c3f70847bc6d9690a2fd001f
+
+Signed-off-by: Lukas Rusak
+---
+ xbmc/cores/VideoPlayer/DVDCodecs/Video/DXVA.cpp | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DXVA.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DXVA.cpp
+index a1bc3761c59d1..c06bd1ac0c7e6 100644
+--- a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DXVA.cpp
++++ b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DXVA.cpp
+@@ -972,7 +972,8 @@ CDecoder::CDecoder(CProcessInfo& processInfo)
+ m_event.Set();
+ m_avD3D11Context = av_d3d11va_alloc_context();
+ m_avD3D11Context->cfg = reinterpret_cast(av_mallocz(sizeof(D3D11_VIDEO_DECODER_CONFIG)));
+- m_avD3D11Context->surface = reinterpret_cast(av_mallocz_array(32, sizeof(ID3D11VideoDecoderOutputView*)));
++ m_avD3D11Context->surface = reinterpret_cast(
++ av_calloc(32, sizeof(ID3D11VideoDecoderOutputView*)));
+ m_bufferPool.reset();
+
+ DX::Windowing()->Register(this);
+
+From be1247d627cee6561174467094f1e8a46357df79 Mon Sep 17 00:00:00 2001
+From: Lukas Rusak
+Date: Sat, 11 Mar 2023 19:45:46 -0800
+Subject: [PATCH 09/10] CFFmpegImage: remove deprecated use of pkt_duration
+
+ref: https://ffmpeg.org/doxygen/6.0/structAVFrame.html\#a91725a40000e348b0607adf7f577e646
+
+Signed-off-by: Lukas Rusak
+---
+ xbmc/guilib/FFmpegImage.cpp | 16 +++++++++++++++-
+ 1 file changed, 15 insertions(+), 1 deletion(-)
+
+diff --git a/xbmc/guilib/FFmpegImage.cpp b/xbmc/guilib/FFmpegImage.cpp
+index e71980998b2e5..7171c046a9ce5 100644
+--- a/xbmc/guilib/FFmpegImage.cpp
++++ b/xbmc/guilib/FFmpegImage.cpp
+@@ -294,7 +294,15 @@ AVFrame* CFFmpegImage::ExtractFrame()
+ return nullptr;
+ }
+ //we need milliseconds
+- frame->pkt_duration = av_rescale_q(frame->pkt_duration, m_fctx->streams[0]->time_base, AVRational{ 1, 1000 });
++
++#if LIBAVCODEC_VERSION_MAJOR < 60
++ frame->pkt_duration =
++ av_rescale_q(frame->pkt_duration, m_fctx->streams[0]->time_base, AVRational{1, 1000});
++#else
++ frame->duration =
++ av_rescale_q(frame->duration, m_fctx->streams[0]->time_base, AVRational{1, 1000});
++#endif
++
+ m_height = frame->height;
+ m_width = frame->width;
+ m_originalWidth = m_width;
+@@ -745,7 +753,13 @@ std::shared_ptr CFFmpegImage::ReadFrame()
+ if (avframe == nullptr)
+ return nullptr;
+ std::shared_ptr frame(new Frame());
++
++#if LIBAVCODEC_VERSION_MAJOR < 60
+ frame->m_delay = (unsigned int)avframe->pkt_duration;
++#else
++ frame->m_delay = (unsigned int)avframe->duration;
++#endif
++
+ frame->m_pitch = avframe->width * 4;
+ frame->m_pImage = (unsigned char*) av_malloc(avframe->height * frame->m_pitch);
+ DecodeFrame(avframe, avframe->width, avframe->height, frame->m_pitch, frame->m_pImage);
+
+From c12af890b0973f7c86316087e823f8a31c6b2ed3 Mon Sep 17 00:00:00 2001
+From: Lukas Rusak
+Date: Sat, 11 Mar 2023 19:45:01 -0800
+Subject: [PATCH 10/10] CDVDVideoCodecFFmpeg: remove deprecated use of
+ reordered_opaque
+
+ref: https://ffmpeg.org/doxygen/6.0/structAVFrame.html#a12f572ed19a2cba6be3790393cee76b5
+
+Signed-off-by: Lukas Rusak
+---
+ .../DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp | 11 ++++++++++-
+ xbmc/cores/VideoPlayer/DVDCodecs/Video/DXVA.cpp | 6 ++++--
+ xbmc/cores/VideoPlayer/DVDCodecs/Video/VAAPI.cpp | 3 +++
+ xbmc/cores/VideoPlayer/DVDCodecs/Video/VDPAU.cpp | 5 ++++-
+ 4 files changed, 21 insertions(+), 4 deletions(-)
+
+diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp
+index c080589896ce7..6a53ade4a7351 100644
+--- a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp
++++ b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp
+@@ -370,6 +370,10 @@ bool CDVDVideoCodecFFmpeg::Open(CDVDStreamInfo &hints, CDVDCodecOptions &options
+ m_pCodecContext->get_format = GetFormat;
+ m_pCodecContext->codec_tag = hints.codec_tag;
+
++#if LIBAVCODEC_VERSION_MAJOR >= 60
++ m_pCodecContext->flags = AV_CODEC_FLAG_COPY_OPAQUE;
++#endif
++
+ // setup threading model
+ if (!(hints.codecOptions & CODEC_FORCE_SOFTWARE))
+ {
+@@ -545,9 +549,10 @@ void CDVDVideoCodecFFmpeg::UpdateName()
+ CLog::Log(LOGDEBUG, "CDVDVideoCodecFFmpeg - Updated codec: {}", m_name);
+ }
+
++#if LIBAVCODEC_VERSION_MAJOR < 60
+ union pts_union
+ {
+- double pts_d;
++ double pts_d;
+ int64_t pts_i;
+ };
+
+@@ -557,6 +562,7 @@ static int64_t pts_dtoi(double pts)
+ u.pts_d = pts;
+ return u.pts_i;
+ }
++#endif
+
+ bool CDVDVideoCodecFFmpeg::AddData(const DemuxPacket &packet)
+ {
+@@ -575,7 +581,10 @@ bool CDVDVideoCodecFFmpeg::AddData(const DemuxPacket &packet)
+ m_started = true;
+
+ m_dts = packet.dts;
++
++#if LIBAVCODEC_VERSION_MAJOR < 60
+ m_pCodecContext->reordered_opaque = pts_dtoi(packet.pts);
++#endif
+
+ AVPacket* avpkt = av_packet_alloc();
+ if (!avpkt)
+diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DXVA.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DXVA.cpp
+index c06bd1ac0c7e6..81451995ca1db 100644
+--- a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DXVA.cpp
++++ b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DXVA.cpp
+@@ -1538,8 +1538,6 @@ int CDecoder::GetBuffer(AVCodecContext* avctx, AVFrame* pic)
+ return -1;
+ }
+
+- pic->reordered_opaque = avctx->reordered_opaque;
+-
+ for (unsigned i = 0; i < 4; i++)
+ {
+ pic->data[i] = nullptr;
+@@ -1556,6 +1554,10 @@ int CDecoder::GetBuffer(AVCodecContext* avctx, AVFrame* pic)
+ }
+ pic->buf[0] = buffer;
+
++#if LIBAVCODEC_VERSION_MAJOR < 60
++ pic->reordered_opaque = avctx->reordered_opaque;
++#endif
++
+ Acquire();
+
+ return 0;
+diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Video/VAAPI.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/Video/VAAPI.cpp
+index 6c4f664591a04..447a13495d4e8 100644
+--- a/xbmc/cores/VideoPlayer/DVDCodecs/Video/VAAPI.cpp
++++ b/xbmc/cores/VideoPlayer/DVDCodecs/Video/VAAPI.cpp
+@@ -867,7 +867,10 @@ int CDecoder::FFGetBuffer(AVCodecContext *avctx, AVFrame *pic, int flags)
+ }
+ pic->buf[0] = buffer;
+
++#if LIBAVCODEC_VERSION_MAJOR < 60
+ pic->reordered_opaque = avctx->reordered_opaque;
++#endif
++
+ va->Acquire();
+ return 0;
+ }
+diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Video/VDPAU.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/Video/VDPAU.cpp
+index ec07af79de819..50e16d492ebc7 100644
+--- a/xbmc/cores/VideoPlayer/DVDCodecs/Video/VDPAU.cpp
++++ b/xbmc/cores/VideoPlayer/DVDCodecs/Video/VDPAU.cpp
+@@ -1041,7 +1041,10 @@ int CDecoder::FFGetBuffer(AVCodecContext *avctx, AVFrame *pic, int flags)
+ }
+ pic->buf[0] = buffer;
+
+- pic->reordered_opaque= avctx->reordered_opaque;
++#if LIBAVCODEC_VERSION_MAJOR < 60
++ pic->reordered_opaque = avctx->reordered_opaque;
++#endif
++
+ return 0;
+ }
+
+
+From 928a7e4196046154419727a23c734d904e5e1b6c Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Markus=20H=C3=A4rer?=
+Date: Sun, 23 Apr 2023 23:29:28 +0200
+Subject: [PATCH] FFmpegImage: Switch back to jpeg_pipe for FFmpeg>=6.0
+
+---
+ xbmc/guilib/FFmpegImage.cpp | 11 +++++++++--
+ 1 file changed, 9 insertions(+), 2 deletions(-)
+
+diff --git a/xbmc/guilib/FFmpegImage.cpp b/xbmc/guilib/FFmpegImage.cpp
+index 7171c046a9ce5..429037740a7d2 100644
+--- a/xbmc/guilib/FFmpegImage.cpp
++++ b/xbmc/guilib/FFmpegImage.cpp
+@@ -198,9 +198,16 @@ bool CFFmpegImage::Initialize(unsigned char* buffer, size_t bufSize)
+ bool is_png = (bufSize > 3 && buffer[1] == 'P' && buffer[2] == 'N' && buffer[3] == 'G');
+ bool is_tiff = (bufSize > 2 && buffer[0] == 'I' && buffer[1] == 'I' && buffer[2] == '*');
+
++ // See Github #19113
++#if LIBAVCODEC_VERSION_MAJOR < 60
++ constexpr char jpegFormat[] = "image2";
++#else
++ constexpr char jpegFormat[] = "jpeg_pipe";
++#endif
++
+ FFMPEG_FMT_CONST AVInputFormat* inp = nullptr;
+ if (is_jpeg)
+- inp = av_find_input_format("image2");
++ inp = av_find_input_format(jpegFormat);
+ else if (m_strMimeType == "image/apng")
+ inp = av_find_input_format("apng");
+ else if (is_png)
+@@ -213,7 +220,7 @@ bool CFFmpegImage::Initialize(unsigned char* buffer, size_t bufSize)
+ inp = av_find_input_format("webp_pipe");
+ // brute force parse if above check already failed
+ else if (m_strMimeType == "image/jpeg" || m_strMimeType == "image/jpg")
+- inp = av_find_input_format("image2");
++ inp = av_find_input_format(jpegFormat);
+ else if (m_strMimeType == "image/png")
+ inp = av_find_input_format("png_pipe");
+ else if (m_strMimeType == "image/tiff")
+
+
+From 9d7f4dfd00d89d4a5d6d8095ee9b0b746051b30c Mon Sep 17 00:00:00 2001
+From: CrystalP
+Date: Mon, 1 May 2023 13:26:56 -0400
+Subject: [PATCH] [fix] extern C for ffmpeg includes
+
+---
+ xbmc/cores/RetroPlayer/process/RPProcessInfo.h | 3 +++
+ xbmc/cores/RetroPlayer/rendering/RenderTranslator.h | 3 +++
+ xbmc/cores/VideoPlayer/DVDFileInfo.cpp | 4 ++--
+ xbmc/cores/VideoPlayer/VideoRenderers/windows/RendererDXVA.h | 4 ++++
+ .../VideoPlayer/VideoRenderers/windows/RendererShaders.h | 4 ++++
+ 5 files changed, 16 insertions(+), 2 deletions(-)
+
+diff --git a/xbmc/cores/RetroPlayer/process/RPProcessInfo.h b/xbmc/cores/RetroPlayer/process/RPProcessInfo.h
+index 9f930e78e9d84..f5ffe670d68aa 100644
+--- a/xbmc/cores/RetroPlayer/process/RPProcessInfo.h
++++ b/xbmc/cores/RetroPlayer/process/RPProcessInfo.h
+@@ -17,7 +17,10 @@
+ #include
+ #include
+
++extern "C"
++{
+ #include
++}
+
+ class CDataCacheCore;
+
+diff --git a/xbmc/cores/RetroPlayer/rendering/RenderTranslator.h b/xbmc/cores/RetroPlayer/rendering/RenderTranslator.h
+index 575ad814fc125..d78e1c25e4070 100644
+--- a/xbmc/cores/RetroPlayer/rendering/RenderTranslator.h
++++ b/xbmc/cores/RetroPlayer/rendering/RenderTranslator.h
+@@ -10,7 +10,10 @@
+
+ #include "cores/GameSettings.h"
+
++extern "C"
++{
+ #include
++}
+
+ namespace KODI
+ {
+diff --git a/xbmc/cores/VideoPlayer/DVDFileInfo.cpp b/xbmc/cores/VideoPlayer/DVDFileInfo.cpp
+index 0860b40475b18..c7253bbd5497f 100644
+--- a/xbmc/cores/VideoPlayer/DVDFileInfo.cpp
++++ b/xbmc/cores/VideoPlayer/DVDFileInfo.cpp
+@@ -32,8 +32,6 @@
+ #include "DVDDemuxers/DVDDemuxVobsub.h"
+ #include "Process/ProcessInfo.h"
+
+-#include
+-#include
+ #include "filesystem/File.h"
+ #include "cores/FFmpeg.h"
+ #include "TextureCache.h"
+@@ -44,7 +42,9 @@
+ #include
+
+ extern "C" {
++#include
+ #include
++#include
+ }
+
+ bool CDVDFileInfo::GetFileDuration(const std::string &path, int& duration)
+diff --git a/xbmc/cores/VideoPlayer/VideoRenderers/windows/RendererDXVA.h b/xbmc/cores/VideoPlayer/VideoRenderers/windows/RendererDXVA.h
+index 9412377157f94..0eed9503dc9ac 100644
+--- a/xbmc/cores/VideoPlayer/VideoRenderers/windows/RendererDXVA.h
++++ b/xbmc/cores/VideoPlayer/VideoRenderers/windows/RendererDXVA.h
+@@ -13,7 +13,11 @@
+ #include