xbmc / inputstream.ffmpegdirect

Supports streams opened by FFmpeg's libavformat or Kodi's cURL such as plain TS, HLS and DASH (non-DRM) as well as many others. There is support for Archive/Catchup services where there is a replay window and can timeshift across that span. Also provides timeshift for live streams where rewind/pause and fast-forward would not have been available.
GNU General Public License v2.0
59 stars 42 forks source link

I had to adjust some things to build under Archlinux - Nexus/20.X #164

Open ilikenwf opened 2 years ago

ilikenwf commented 2 years ago

I had to roll a couple files back and adjust as below, not sure if this matters, as Arch uses bleeding edge packages sometimes...

diff --git a/src/stream/FFmpegCatchupStream.cpp b/src/stream/FFmpegCatchupStream.cpp
index a47ad8f..dd2e995 100644
--- a/src/stream/FFmpegCatchupStream.cpp
+++ b/src/stream/FFmpegCatchupStream.cpp
@@ -371,7 +371,7 @@ void FFmpegCatchupStream::UpdateCurrentPTS()

 bool FFmpegCatchupStream::IsRealTimeStream()
 {
-  if (kodi::addon::GetSettingBoolean("forceRealtimeOffCatchup"))
+  if (kodi::GetSettingBoolean("forceRealtimeOffCatchup"))
     return false;

   return m_isRealTimeStream && m_pFormatContext->duration <= 0;
diff --git a/src/stream/FFmpegStream.cpp b/src/stream/FFmpegStream.cpp
index 05dbc39..8fd9c00 100644
--- a/src/stream/FFmpegStream.cpp
+++ b/src/stream/FFmpegStream.cpp
@@ -151,7 +151,7 @@ FFmpegStream::FFmpegStream(IManageDemuxPacket* demuxPacketManager, const Propert
   m_dtsAtDisplayTime = STREAM_NOPTS_VALUE;

   FFmpegLog::SetLogLevel(AV_LOG_INFO);
-  FFmpegLog::SetEnabled(kodi::addon::GetSettingBoolean("allowFFmpegLogging"));
+  FFmpegLog::SetEnabled(kodi::GetSettingBoolean("allowFFmpegLogging"));
   av_log_set_callback(ff_avutil_log);
 }

@@ -181,7 +181,7 @@ bool FFmpegStream::Open(const std::string& streamUrl, const std::string& mimeTyp
     FFmpegLog::SetEnabled(true);
     av_dump_format(m_pFormatContext, 0, CURL::GetRedacted(streamUrl).c_str(), 0);
   }
-  FFmpegLog::SetEnabled(kodi::addon::GetSettingBoolean("allowFFmpegLogging"));
+  FFmpegLog::SetEnabled(kodi::GetSettingBoolean("allowFFmpegLogging"));

   return m_opened;
 }
@@ -709,7 +709,7 @@ bool FFmpegStream::Open(bool fileinfo)
   }

   // Avoid detecting framerate if our advanced settings says so
-  if (!kodi::addon::GetSettingBoolean("probeForFps"))
+  if (!kodi::GetSettingBoolean("probeForFps"))
     m_pFormatContext->fps_probe_size = 0;

   // analyse very short to speed up mjpeg playback start
@@ -924,7 +924,7 @@ bool FFmpegStream::OpenWithFFmpeg(AVInputFormat* iformat, const AVIOInterruptCB&
   if (result < 0)
   {
     // We only process this condition for manifest streams when this setting is disabled
-    if (!kodi::addon::GetSettingBoolean("useFastOpenForManifestStreams") || m_manifestType.empty())
+    if (!kodi::GetSettingBoolean("useFastOpenForManifestStreams") || m_manifestType.empty())
     {
       m_pFormatContext->flags |= AVFMT_FLAG_PRIV_OPT;
       if (avformat_open_input(&m_pFormatContext, strFile.c_str(), iformat, &options) < 0)
@@ -1244,7 +1244,7 @@ unsigned int FFmpegStream::HLSSelectProgram()
 {
   unsigned int prog = UINT_MAX;

-  int bandwidth = kodi::addon::GetSettingInt("streamBandwidth") * 1000;
+  int bandwidth = kodi::GetSettingInt("streamBandwidth") * 1000;
   if (bandwidth <= 0)
     bandwidth = INT_MAX;

@@ -1907,7 +1907,7 @@ DemuxStream* FFmpegStream::AddStream(int streamIdx)
       // }
       case AVMEDIA_TYPE_SUBTITLE:
       {
-        if (pStream->codecpar->codec_id == AV_CODEC_ID_DVB_TELETEXT && kodi::addon::GetSettingBoolean("enableTeletext"))
+        if (pStream->codecpar->codec_id == AV_CODEC_ID_DVB_TELETEXT && kodi::GetSettingBoolean("enableTeletext"))
         {
           DemuxStreamTeletext* st = new DemuxStreamTeletext();
           stream = st;
diff --git a/src/stream/TimeshiftBuffer.cpp b/src/stream/TimeshiftBuffer.cpp
index 78e5c1b..9e7f08e 100644
--- a/src/stream/TimeshiftBuffer.cpp
+++ b/src/stream/TimeshiftBuffer.cpp
@@ -20,7 +20,7 @@ using namespace kodi::tools;
 TimeshiftBuffer::TimeshiftBuffer(IManageDemuxPacket* demuxPacketManager)
   : m_demuxPacketManager(demuxPacketManager)
 {
-  m_timeshiftBufferPath = kodi::addon::GetSettingString("timeshiftBufferPath");
+  m_timeshiftBufferPath = kodi::GetSettingString("timeshiftBufferPath");
   if (m_timeshiftBufferPath.empty())
   {
     m_timeshiftBufferPath = DEFAULT_TIMESHIFT_BUFFER_PATH;
@@ -34,9 +34,9 @@ TimeshiftBuffer::TimeshiftBuffer(IManageDemuxPacket* demuxPacketManager)
   if (!kodi::vfs::DirectoryExists(m_timeshiftBufferPath))
     kodi::vfs::CreateDirectory(m_timeshiftBufferPath);

-  if (!kodi::addon::CheckSettingBoolean("timeshiftEnableLimit", m_enableOnDiskSegmentLimit))
+  if (!kodi::CheckSettingBoolean("timeshiftEnableLimit", m_enableOnDiskSegmentLimit))
     m_enableOnDiskSegmentLimit = true;
-  float onDiskTotalLengthHours = kodi::addon::GetSettingFloat("timeshiftOnDiskLength");
+  float onDiskTotalLengthHours = kodi::GetSettingFloat("timeshiftOnDiskLength");
   if (onDiskTotalLengthHours <= 0.0f)
     onDiskTotalLengthHours = DEFAULT_TIMESHIFT_SEGMENT_ON_DISK_LENGTH_HOURS;
   int onDiskTotalLengthSeconds = onDiskTotalLengthHours * 60 * 60;
ilikenwf commented 2 years ago

I also had to adjust the version in addon.xml...but I'm running the git version of Nexus.

phunkyfish commented 2 years ago

The issue here is that your Kodi source needs to be updated. You have pretty much undone a recent merge which had API changes (kodi:: -> kodi::addon::, was one of those).

I imagine that Arch will start to use the latest soon enough which just means undoing your patch.

ilikenwf commented 2 years ago

I'm running the latest git version of Kodi itself - I may still have the -dev package that's older or something?

phunkyfish commented 2 years ago

I'm running the latest git version of Kodi itself - I may still have the -dev package that's older or something?

If you were running the latest git version of kodi then the kodi::addon namespace would have worked.

Note that the master branch of Kodi applies to the Nexus branch of the binary addons.

daiaji commented 1 year ago

https://gist.github.com/daiaji/a21877de163585394f58902093ab3631

I also encountered a compilation error.

phunkyfish commented 1 year ago

Please use a pastesite link instead of adding logs straight into the issue.

What changes did you need to make? Maybe submit them as a PR and I can review them.

daiaji commented 1 year ago

After upgrading the version of binutils to 2.41, an error occurred:

src/libavcodec/x86/mathops.h:125: Error: operand type mismatch for `shr'
src/libavcodec/x86/mathops.h:125: Error: operand type mismatch for `shr'
src/libavcodec/x86/mathops.h:125: Error: operand type mismatch for `shr'
src/libavcodec/x86/mathops.h:125: Error: operand type mismatch for `shr'

I suspect that this patch needs to be applied to the FFmpeg used by inputstream.ffmpegdirect. However, I don't know how to do this, as the FindFFMPEG.cmake used by inputstream.ffmpegdirect is different from the FindFFMPEG.cmake used by xbmc itself.

It appears that whether it's xbmc itself or inputstream.ffmpegdirect, a patch for FFmpeg is required after the version of binutils exceeds 2.41. I believe this patch should be integrated into the repositories of both xbmc and inputstream.ffmpegdirect.

daiaji commented 1 year ago

Frankly speaking, I'm utterly at a loss about what to do now. I've tried patching XBMC and altering FFmpeg, and redirected my download links locally, but damn it, CMake keeps downloading from https://github.com/FFmpeg/FFmpeg/archive/n4.4.tar.gz.

phunkyfish commented 1 year ago

There should be arch packages to build this. Are there not?

For Linux platforms your system ffmpeg should be used. I.e. you should not need to build it.

daiaji commented 1 year ago

https://github.com/daiaji/inputstream.ffmpegdirect/tree/fix The repair is completed, yet when compiling the AUR package, it appears that the patch, 04-Fixes-assembling-w-binutil-as-2.41.patch, isn't being applied for some unknown reason.

There should be arch packages to build this. Are there not?

For Linux platforms your system ffmpeg should be used. I.e. you should not need to build it.

Even with FFmpeg installed, the compilation script will still download and compile FFmpeg when compiling inputstream.ffmpegdirect.

phunkyfish commented 1 year ago

But that’s my point, if the build for arch Linux was correctly configured it should use the system ffmpeg. As it’s not, something is not being set up correctly.

I’m afraid I’m not a Linux user so I don’t know what that might be.

daiaji commented 1 year ago
ffmpeg -version
ffmpeg version n6.0 Copyright (c) 2000-2023 the FFmpeg developers
built with gcc 13.2.1 (GCC) 20230801
configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-amf --enable-avisynth --enable-cuda-llvm --enable-lto --enable-fontconfig --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libdav1d --enable-libdrm --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libiec61883 --enable-libjack --enable-libjxl --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librav1e --enable-librsvg --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libsvtav1 --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvpl --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxml2 --enable-libxvid --enable-libzimg --enable-nvdec --enable-nvenc --enable-opencl --enable-opengl --enable-shared --enable-version3 --enable-vulkan
libavutil      58.  2.100 / 58.  2.100
libavcodec     60.  3.100 / 60.  3.100
libavformat    60.  3.100 / 60.  3.100
libavdevice    60.  1.100 / 60.  1.100
libavfilter     9.  3.100 /  9.  3.100
libswscale      7.  1.100 /  7.  1.100
libswresample   4. 10.100 /  4. 10.100
libpostproc    57.  1.100 / 57.  1.100

It seems that specifying the path of FFmpeg doesn't make much of a difference either. https://gist.github.com/daiaji/29d7319785eb52773d128d8150007e18

phunkyfish commented 1 year ago

The path in pkgbuild is for ffmpeg 4.4. Why is it not 6.0?

daiaji commented 1 year ago

Can I use 6.0?

usr/lib/
usr/lib/libavcodec.so
usr/lib/libavcodec.so.60
usr/lib/libavcodec.so.60.3.100
usr/lib/libavdevice.so
usr/lib/libavdevice.so.60
usr/lib/libavdevice.so.60.1.100
usr/lib/libavfilter.so
usr/lib/libavfilter.so.9
usr/lib/libavfilter.so.9.3.100
usr/lib/libavformat.so
usr/lib/libavformat.so.60
usr/lib/libavformat.so.60.3.100
usr/lib/libavutil.so
usr/lib/libavutil.so.58
usr/lib/libavutil.so.58.2.100
usr/lib/libpostproc.so
usr/lib/libpostproc.so.57
usr/lib/libpostproc.so.57.1.100
usr/lib/libswresample.so
usr/lib/libswresample.so.4
usr/lib/libswresample.so.4.10.100
usr/lib/libswscale.so
usr/lib/libswscale.so.7
usr/lib/libswscale.so.7.1.100
phunkyfish commented 1 year ago

Ah, sorry. I see you are building Nexus and Omega. If arch is bleeding edge maybe try bleeding edge kodi 😉

daiaji commented 1 year ago

Under what circumstances would the source code under https://github.com/xbmc/repo-binary-addons be compiled? This situation renders my modifications ineffective.

phunkyfish commented 1 year ago

It depends how you are building the add-on. You can pass a path to a local clone of the repo. But if you build as as part of the xbmc build it will always download from that repo.

daiaji commented 1 year ago
pkgname=kodi-addon-inputstream-ffmpegdirect
pkgver=20.5.0
pkgrel=1
pkgdesc="Inputstream ffmpegdirect kodi plugin"
_koditarget=Nexus
_gitname=inputstream.ffmpegdirect
_kodiver=20.0
        mkdir -p "${_gitname}-${pkgver}-${_koditarget}/build"
        cd "${_gitname}-${pkgver}-${_koditarget}/build"

        cmake \
                -DCMAKE_INSTALL_PREFIX=/usr \
                -DCMAKE_INSTALL_LIBDIR=/usr/lib/kodi \
                -DCMAKE_BUILD_TYPE=Release \
                -DBUILD_SHARED_LIBS=1 \
                -DADDONS_TO_BUILD=${_gitname} \
                -DADDONS_SRC_PREFIX=../.. \
                ../../xbmc-${_kodiver}-${_koditarget}/cmake/addons
        make
}

The build command I used, for some reason, did not use my own modified code during the build.

phunkyfish commented 1 year ago

But this is building kodi not building the addon itself. If you want to build using a local source from the addon you must use what’s in in the README:

https://github.com/xbmc/inputstream.ffmpegdirect#linux

daiaji commented 1 year ago

Linux

  1. git clone --branch master https://github.com/xbmc/xbmc.git
  2. git clone https://github.com/xbmc/inputstream.ffmpegdirect.git
  3. cd inputstream.ffmpegdirect && mkdir build && cd build
  4. cmake -DADDONS_TO_BUILD=inputstream.ffmpegdirect -DADDON_SRC_PREFIX=../.. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=../../xbmc/build/addons -DPACKAGE_ZIP=1 ../../xbmc/cmake/addons
  5. make

The addon files will be placed in ../../xbmc/build/addons so if you build Kodi from source and run it

directly the addon will be available as a system addon.

It seems like the commands don't have any noticeable differences.

It seems that BUILD_SHARED_LIBS is necessary.

ilikenwf commented 9 months ago

I just downgrade binutils, build, then you can update binutils again.