arcreactor

kodi-addon-inputstream-ffmpegdirect.diff

Nov 5th, 2025 (edited)
21
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.85 KB | None | 0 0
  1. diff --git a/.SRCINFO b/.SRCINFO
  2. index 51a3523..7f0510b 100644
  3. --- a/.SRCINFO
  4. +++ b/.SRCINFO
  5. @@ -15,9 +15,13 @@ pkgbase = kodi-addon-inputstream-ffmpegdirect
  6. makedepends = pkgconf
  7. makedepends = kodi-dev
  8. depends = kodi
  9. - depends = ffmpeg6.1
  10. + depends = ffmpeg
  11. provides = kodi-addon-inputstream-ffmpegdirect
  12. source = https://github.com/xbmc/inputstream.ffmpegdirect/archive/21.3.8-Omega.tar.gz
  13. - sha256sums = 0648c6bbb2143cec0c3f48ad476f2c213f20c809caaf5ac74c8ceb4e53635f4e
  14. + source = 0000-ffmpeg7.patch
  15. + source = 0001-ffmpeg8.patch
  16. + sha256sums = 0648c6bbb2143cec0c3f48ad476f2c213f20c809caaf5ac74c8ceb4e53635f4e
  17. + sha256sums = 87334d9b32b2dd62aa3756e9d46487d4184f3d70155c0afc34b5f14926d280ff
  18. + sha256sums = 1968f6299d58984f7782fbfda4da6ec5f1796ac84377d4131a42cf671edf4b4a
  19.  
  20. pkgname = kodi-addon-inputstream-ffmpegdirect
  21. diff --git a/0000-ffmpeg7.patch b/0000-ffmpeg7.patch
  22. new file mode 100644
  23. index 0000000..e5b306f
  24. --- /dev/null
  25. +++ b/0000-ffmpeg7.patch
  26. @@ -0,0 +1,227 @@
  27. +From 5552d0bde9ec84c42ef7a72972179f99755a2618 Mon Sep 17 00:00:00 2001
  28. +From: Vasyl Gello <[email protected]>
  29. +Date: Fri, 9 Aug 2024 07:11:41 +0000
  30. +Subject: [PATCH] Port FFmpeg 7.0 to ffmpegdirect Omega
  31. +
  32. +From https://github.com/xbmc/xbmc/pull/24972
  33. +
  34. +Signed-off-by: Vasyl Gello <[email protected]>
  35. +---
  36. + FindFFMPEG.cmake | 16 ++--
  37. + depends/common/ffmpeg/CMakeLists.txt | 4 +-
  38. + depends/common/ffmpeg/ffmpeg.sha256 | 2 +-
  39. + depends/common/ffmpeg/ffmpeg.txt | 2 +-
  40. + src/stream/FFmpegStream.cpp | 125 ++++++++-------------------
  41. + 5 files changed, 46 insertions(+), 103 deletions(-)
  42. +
  43. +diff --git a/FindFFMPEG.cmake b/FindFFMPEG.cmake
  44. +index d03f329..8b20538 100644
  45. +--- a/FindFFMPEG.cmake
  46. ++++ b/FindFFMPEG.cmake
  47. +@@ -33,14 +33,14 @@
  48. + #
  49. +
  50. + # required ffmpeg library versions
  51. +-set(REQUIRED_FFMPEG_VERSION 5.0.0)
  52. +-set(_avcodec_ver ">=59.18.100")
  53. +-set(_avfilter_ver ">=8.24.100")
  54. +-set(_avformat_ver ">=59.16.100")
  55. +-set(_avutil_ver ">=57.17.100")
  56. +-set(_postproc_ver ">=56.3.100")
  57. +-set(_swresample_ver ">=4.3.100")
  58. +-set(_swscale_ver ">=6.4.100")
  59. ++set(REQUIRED_FFMPEG_VERSION 7.0.0)
  60. ++set(_avcodec_ver ">=61.3.100")
  61. ++set(_avfilter_ver ">=10.1.100")
  62. ++set(_avformat_ver ">=61.1.100")
  63. ++set(_avutil_ver ">=59.8.100")
  64. ++set(_postproc_ver ">=58.1.100")
  65. ++set(_swresample_ver ">=5.1.100")
  66. ++set(_swscale_ver ">=8.1.100")
  67. +
  68. + # Allows building with external ffmpeg not found in system paths,
  69. + # without library version checks
  70. +diff --git a/src/stream/FFmpegStream.cpp b/src/stream/FFmpegStream.cpp
  71. +index 8bf474f..c77e09d 100644
  72. +--- a/src/stream/FFmpegStream.cpp
  73. ++++ b/src/stream/FFmpegStream.cpp
  74. +@@ -1012,74 +1012,7 @@ bool FFmpegStream::OpenWithCURL(const AVInputFormat* iformat)
  75. + if (iformat == nullptr)
  76. + {
  77. + // let ffmpeg decide which demuxer we have to open
  78. +- bool trySPDIFonly = (m_curlInput->GetContent() == "audio/x-spdif-compressed");
  79. +-
  80. +- if (!trySPDIFonly)
  81. +- av_probe_input_buffer(m_ioContext, &iformat, strFile.c_str(), NULL, 0, 0);
  82. +-
  83. +- // Use the more low-level code in case we have been built against an old
  84. +- // FFmpeg without the above av_probe_input_buffer(), or in case we only
  85. +- // want to probe for spdif (DTS or IEC 61937) compressed audio
  86. +- // specifically, or in case the file is a wav which may contain DTS or
  87. +- // IEC 61937 (e.g. ac3-in-wav) and we want to check for those formats.
  88. +- if (trySPDIFonly || (iformat && strcmp(iformat->name, "wav") == 0))
  89. +- {
  90. +- AVProbeData pd;
  91. +- int probeBufferSize = 32768;
  92. +- std::unique_ptr<uint8_t[]> probe_buffer (new uint8_t[probeBufferSize + AVPROBE_PADDING_SIZE]);
  93. +-
  94. +- // init probe data
  95. +- pd.buf = probe_buffer.get();
  96. +- pd.filename = strFile.c_str();
  97. +-
  98. +- // read data using avformat's buffers
  99. +- pd.buf_size = avio_read(m_ioContext, pd.buf, probeBufferSize);
  100. +- if (pd.buf_size <= 0)
  101. +- {
  102. +- Log(LOGLEVEL_ERROR, "%s - error reading from input stream, %s", __FUNCTION__, CURL::GetRedacted(strFile).c_str());
  103. +- return false;
  104. +- }
  105. +- memset(pd.buf + pd.buf_size, 0, AVPROBE_PADDING_SIZE);
  106. +-
  107. +- // restore position again
  108. +- avio_seek(m_ioContext , 0, SEEK_SET);
  109. +-
  110. +- // the advancedsetting is for allowing the user to force outputting the
  111. +- // 44.1 kHz DTS wav file as PCM, so that an A/V receiver can decode
  112. +- // it (this is temporary until we handle 44.1 kHz passthrough properly)
  113. +- if (trySPDIFonly || (iformat && strcmp(iformat->name, "wav") == 0)) // && !CServiceBroker::GetSettingsComponent()->GetAdvancedSettings()->m_VideoPlayerIgnoreDTSinWAV))
  114. +- {
  115. +- // check for spdif and dts
  116. +- // This is used with wav files and audio CDs that may contain
  117. +- // a DTS or AC3 track padded for S/PDIF playback. If neither of those
  118. +- // is present, we assume it is PCM audio.
  119. +- // AC3 is always wrapped in iec61937 (ffmpeg "spdif"), while DTS
  120. +- // may be just padded.
  121. +- const AVInputFormat* iformat2 = av_find_input_format("spdif");
  122. +-
  123. +- if (iformat2 && iformat2->read_probe(&pd) > AVPROBE_SCORE_MAX / 4)
  124. +- {
  125. +- iformat = iformat2;
  126. +- }
  127. +- else
  128. +- {
  129. +- // not spdif or no spdif demuxer, try dts
  130. +- iformat2 = av_find_input_format("dts");
  131. +-
  132. +- if (iformat2 && iformat2->read_probe(&pd) > AVPROBE_SCORE_MAX / 4)
  133. +- {
  134. +- iformat = iformat2;
  135. +- }
  136. +- else if (trySPDIFonly)
  137. +- {
  138. +- // not dts either, return false in case we were explicitly
  139. +- // requested to only check for S/PDIF padded compressed audio
  140. +- Log(LOGLEVEL_DEBUG, "%s - not spdif or dts file, falling back", __FUNCTION__);
  141. +- return false;
  142. +- }
  143. +- }
  144. +- }
  145. +- }
  146. ++ av_probe_input_buffer(m_ioContext, &iformat, strFile.c_str(), NULL, 0, 0);
  147. +
  148. + if (!iformat)
  149. + {
  150. +@@ -1535,7 +1468,7 @@ bool FFmpegStream::SeekTime(double time, bool backwards, double* startpts)
  151. +
  152. + if (ret >= 0)
  153. + {
  154. +- if (m_pFormatContext->iformat->read_seek)
  155. ++ if (!(m_pFormatContext->iformat->flags & AVFMT_NOTIMESTAMPS))
  156. + m_seekToKeyFrame = true;
  157. +
  158. + m_currentPts = STREAM_NOPTS_VALUE;
  159. +@@ -2059,43 +1992,49 @@ DemuxStream* FFmpegStream::AddStream(int streamIdx)
  160. + st->colorRange = pStream->codecpar->color_range;
  161. + st->hdr_type = DetermineHdrType(pStream);
  162. +
  163. +- // https://github.com/FFmpeg/FFmpeg/blob/release/5.0/doc/APIchanges
  164. +- size_t size = 0;
  165. +- uint8_t* side_data = nullptr;
  166. ++ // https://github.com/FFmpeg/FFmpeg/blob/release/7.0/doc/APIchanges
  167. ++ const AVPacketSideData* sideData = nullptr;
  168. +
  169. + if (st->hdr_type == StreamHdrType::HDR_TYPE_DOLBYVISION)
  170. + {
  171. +- side_data = av_stream_get_side_data(pStream, AV_PKT_DATA_DOVI_CONF, &size);
  172. +- if (side_data && size)
  173. ++
  174. ++ sideData =
  175. ++ av_packet_side_data_get(pStream->codecpar->coded_side_data,
  176. ++ pStream->codecpar->nb_coded_side_data, AV_PKT_DATA_DOVI_CONF);
  177. ++ if (sideData && sideData->size)
  178. + {
  179. +- st->dovi = *reinterpret_cast<AVDOVIDecoderConfigurationRecord*>(side_data);
  180. ++ st->dovi = *reinterpret_cast<const AVDOVIDecoderConfigurationRecord*>(sideData->data);
  181. + }
  182. + }
  183. +
  184. +- side_data = av_stream_get_side_data(pStream, AV_PKT_DATA_MASTERING_DISPLAY_METADATA, &size);
  185. +- if (side_data && size)
  186. ++ sideData = av_packet_side_data_get(pStream->codecpar->coded_side_data,
  187. ++ pStream->codecpar->nb_coded_side_data,
  188. ++ AV_PKT_DATA_MASTERING_DISPLAY_METADATA);
  189. ++ if (sideData && sideData->size)
  190. + {
  191. + st->masteringMetaData = std::make_shared<AVMasteringDisplayMetadata>(
  192. +- *reinterpret_cast<AVMasteringDisplayMetadata*>(side_data));
  193. ++ *reinterpret_cast<const AVMasteringDisplayMetadata*>(sideData->data));
  194. + }
  195. +
  196. +- side_data = av_stream_get_side_data(pStream, AV_PKT_DATA_CONTENT_LIGHT_LEVEL, &size);
  197. +- if (side_data && size)
  198. ++ sideData = av_packet_side_data_get(pStream->codecpar->coded_side_data,
  199. ++ pStream->codecpar->nb_coded_side_data,
  200. ++ AV_PKT_DATA_CONTENT_LIGHT_LEVEL);
  201. ++ if (sideData && sideData->size)
  202. + {
  203. + st->contentLightMetaData = std::make_shared<AVContentLightMetadata>(
  204. +- *reinterpret_cast<AVContentLightMetadata*>(side_data));
  205. ++ *reinterpret_cast<const AVContentLightMetadata*>(sideData->data));
  206. + }
  207. +
  208. +- AVDictionaryEntry* rtag = av_dict_get(pStream->metadata, "rotate", NULL, 0);
  209. +- uint8_t* displayMatrixSideData =
  210. +- av_stream_get_side_data(pStream, AV_PKT_DATA_DISPLAYMATRIX, nullptr);
  211. +- if (displayMatrixSideData)
  212. ++ sideData = av_packet_side_data_get(pStream->codecpar->coded_side_data,
  213. ++ pStream->codecpar->nb_coded_side_data,
  214. ++ AV_PKT_DATA_DISPLAYMATRIX);
  215. ++ if (sideData)
  216. + {
  217. +- const double tetha =
  218. +- av_display_rotation_get(reinterpret_cast<int32_t*>(displayMatrixSideData));
  219. +- if (!std::isnan(tetha))
  220. ++ const double theta =
  221. ++ av_display_rotation_get(reinterpret_cast<const int32_t*>(sideData->data));
  222. ++ if (!std::isnan(theta))
  223. + {
  224. +- st->iOrientation = ((static_cast<int>(-tetha) % 360) + 360) % 360;
  225. ++ st->iOrientation = ((static_cast<int>(-theta) % 360) + 360) % 360;
  226. + }
  227. + }
  228. +
  229. +@@ -2271,7 +2210,9 @@ StreamHdrType FFmpegStream::DetermineHdrType(AVStream* pStream)
  230. + {
  231. + StreamHdrType hdrType = StreamHdrType::HDR_TYPE_NONE;
  232. +
  233. +- if (av_stream_get_side_data(pStream, AV_PKT_DATA_DOVI_CONF, nullptr)) // DoVi
  234. ++ if (av_packet_side_data_get(pStream->codecpar->coded_side_data,
  235. ++ pStream->codecpar->nb_coded_side_data,
  236. ++ AV_PKT_DATA_DOVI_CONF)) // DoVi
  237. + hdrType = StreamHdrType::HDR_TYPE_DOLBYVISION;
  238. + else if (pStream->codecpar->color_trc == AVCOL_TRC_SMPTE2084) // HDR10
  239. + hdrType = StreamHdrType::HDR_TYPE_HDR10;
  240. +@@ -2279,7 +2220,9 @@ StreamHdrType FFmpegStream::DetermineHdrType(AVStream* pStream)
  241. + hdrType = StreamHdrType::HDR_TYPE_HLG;
  242. + // file could be SMPTE2086 which FFmpeg currently returns as unknown
  243. + // so use the presence of static metadata to detect it
  244. +- else if (av_stream_get_side_data(pStream, AV_PKT_DATA_MASTERING_DISPLAY_METADATA, nullptr))
  245. ++ else if (av_packet_side_data_get(pStream->codecpar->coded_side_data,
  246. ++ pStream->codecpar->nb_coded_side_data,
  247. ++ AV_PKT_DATA_MASTERING_DISPLAY_METADATA))
  248. + hdrType = StreamHdrType::HDR_TYPE_HDR10;
  249. +
  250. + return hdrType;
  251. +--
  252. +2.43.0
  253. +
  254. diff --git a/0001-ffmpeg8.patch b/0001-ffmpeg8.patch
  255. new file mode 100644
  256. index 0000000..9d85707
  257. --- /dev/null
  258. +++ b/0001-ffmpeg8.patch
  259. @@ -0,0 +1,49 @@
  260. +diff --git a/src/stream/DemuxStream.h b/src/stream/DemuxStream.h
  261. +index e66ecf0..00e071f 100644
  262. +--- a/src/stream/DemuxStream.h
  263. ++++ b/src/stream/DemuxStream.h
  264. +@@ -80,8 +80,8 @@ public:
  265. + dvdNavId = 0;
  266. + demuxerId = -1;
  267. + codec_fourcc = 0;
  268. +- profile = FF_PROFILE_UNKNOWN;
  269. +- level = FF_LEVEL_UNKNOWN;
  270. ++ profile = AV_PROFILE_UNKNOWN;
  271. ++ level = AV_LEVEL_UNKNOWN;
  272. + type = INPUTSTREAM_TYPE_NONE;
  273. + iDuration = 0;
  274. + pPrivate = NULL;
  275. +diff --git a/src/stream/FFmpegStream.cpp b/src/stream/FFmpegStream.cpp
  276. +index 8bf474f..9633728 100644
  277. +--- a/src/stream/FFmpegStream.cpp
  278. ++++ b/src/stream/FFmpegStream.cpp
  279. +@@ -1582,7 +1582,7 @@ bool FFmpegStream::SeekTime(double time, bool backwards, double* startpts)
  280. +
  281. + FFmpegExtraData FFmpegStream::GetPacketExtradata(const AVPacket* pkt, const AVCodecParameters* codecPar)
  282. + {
  283. +- constexpr int FF_MAX_EXTRADATA_SIZE = ((1 << 28) - AV_INPUT_BUFFER_PADDING_SIZE);
  284. ++ constexpr int AV_MAX_EXTRADATA_SIZE = ((1 << 28) - AV_INPUT_BUFFER_PADDING_SIZE);
  285. +
  286. + if (!pkt)
  287. + return {};
  288. +@@ -1675,7 +1675,7 @@ FFmpegExtraData FFmpegStream::GetPacketExtradata(const AVPacket* pkt, const AVCo
  289. + size_t retExtraDataSize = 0;
  290. + uint8_t* retExtraData =
  291. + av_packet_get_side_data(pktRef, AV_PKT_DATA_NEW_EXTRADATA, &retExtraDataSize);
  292. +- if (retExtraData && retExtraDataSize > 0 && retExtraDataSize < FF_MAX_EXTRADATA_SIZE)
  293. ++ if (retExtraData && retExtraDataSize > 0 && retExtraDataSize < AV_MAX_EXTRADATA_SIZE)
  294. + {
  295. + try
  296. + {
  297. +@@ -2317,9 +2317,9 @@ std::string FFmpegStream::GetStreamCodecName(int iStreamId)
  298. + /* use profile to determine the DTS type */
  299. + if (stream->codec == AV_CODEC_ID_DTS)
  300. + {
  301. +- if (stream->profile == FF_PROFILE_DTS_HD_MA)
  302. ++ if (stream->profile == AV_PROFILE_DTS_HD_MA)
  303. + strName = "dtshd_ma";
  304. +- else if (stream->profile == FF_PROFILE_DTS_HD_HRA)
  305. ++ else if (stream->profile == AV_PROFILE_DTS_HD_HRA)
  306. + strName = "dtshd_hra";
  307. + else
  308. + strName = "dca";
  309. diff --git a/PKGBUILD b/PKGBUILD
  310. index acaf10d..e280072 100644
  311. --- a/PKGBUILD
  312. +++ b/PKGBUILD
  313. @@ -11,20 +11,35 @@ license=('GPL')
  314. groups=('kodi')
  315. makedepends=('cmake' 'git' 'pkgconf' 'kodi-dev')
  316. provides=('kodi-addon-inputstream-ffmpegdirect')
  317. -depends=('kodi' 'ffmpeg6.1')
  318. -source=("https://github.com/xbmc/${_gitname}/archive/${pkgver}-${_koditarget}.tar.gz")
  319. +depends=('kodi' 'ffmpeg')
  320. +source=(
  321. + "https://github.com/xbmc/${_gitname}/archive/${pkgver}-${_koditarget}.tar.gz"
  322. + "0000-ffmpeg7.patch"
  323. + "0001-ffmpeg8.patch"
  324. +)
  325.  
  326. -sha256sums=('0648c6bbb2143cec0c3f48ad476f2c213f20c809caaf5ac74c8ceb4e53635f4e')
  327. +sha256sums=(
  328. + '0648c6bbb2143cec0c3f48ad476f2c213f20c809caaf5ac74c8ceb4e53635f4e'
  329. + '87334d9b32b2dd62aa3756e9d46487d4184f3d70155c0afc34b5f14926d280ff'
  330. + '1968f6299d58984f7782fbfda4da6ec5f1796ac84377d4131a42cf671edf4b4a'
  331. +)
  332. +
  333. +prepare() {
  334. + cd "${_gitname}-${pkgver}-${_koditarget}"
  335. + patch -Np1 -i ../0000-ffmpeg7.patch
  336. + patch -Np1 -i ../0001-ffmpeg8.patch
  337. +}
  338.  
  339. build() {
  340. mkdir -p "${_gitname}-${pkgver}-${_koditarget}/build"
  341. cd "${_gitname}-${pkgver}-${_koditarget}/build"
  342.  
  343. - PKG_CONFIG_PATH=/usr/lib/ffmpeg6.1/pkgconfig cmake \
  344. + cmake \
  345. -DCMAKE_INSTALL_PREFIX=/usr \
  346. -DCMAKE_BUILD_TYPE=Release \
  347. - -DLIBXML2_INCLUDE_DIRS=/usr/include/libxml2/libxml \
  348. + -DLIBXML2_INCLUDE_DIRS=/usr/include/libxml2/libxml \
  349. ..
  350. +
  351. make
  352. }
  353.  
Advertisement
Add Comment
Please, Sign In to add comment