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
57 stars 40 forks source link
hacktoberfest kodi

License: GPL-2.0-or-later Build Status Build and run tests Build Status

inputstream.ffmpegdirect addon for Kodi

This is a Kodi input stream addon for streams that can be opened by either FFmpeg's libavformat or Kodi's cURL. Common stream formats such as plain TS, HLS and DASH are supported as well as many others. Note that the only DASH streams supported are those without DRM.

The addon also has support for Archive/Catchup services where there is a replay window (usually in days) and can timeshift across that span. In addition the addon can also provide timeshift to live streams where rewind/pause and fast-forward woud not have previously been possible.

Platform specific differences

There are a few minor differences between the implementations. If using the kodi Ubuntu PPA the underlying ffmpeg is the same as Kodi's, which means it won't support teletext or Dash without DRM but it will currently have AV1 support as Kodi does. For users who need it with teletext or Dash without DRM support please just build the addon using the instructions below.

On windows there is no teletext support unfortuntely as libzvbi is not currently building. If anyone would like to figure this out I'm sure the users would appreciate it.

Finally, outside of the Ubuntu PPA there is currently no support for AV1. This is simply because the python3/ninja/meson build system required to build libdav1d would have to be built from scratch specifically for the addon. I'm sure support will get added eventually when someone has the time to do it.

Build instructions

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.

Mac OSX

In order to build the addon on mac the steps are different to Linux and Windows as the cmake command above will not produce an addon that will run in kodi. Instead using make directly as per the supported build steps for kodi on mac we can build the tools and just the addon on it's own. Following this we copy the addon into kodi. Note that we checkout kodi to a separate directory as this repo will only only be used to build the addon and nothing else.

Build tools and initial addon build

  1. Get the repos
    • cd $HOME
    • git clone https://github.com/xbmc/xbmc xbmc-addon
    • git clone https://github.com/xbmc/inputstream.ffmpegdirect
  2. Build the kodi tools
    • cd $HOME/xbmc-addon/tools/depends
    • ./bootstrap
    • ./configure --host=x86_64-apple-darwin
    • make -j$(getconf _NPROCESSORS_ONLN)
  3. Build the addon
    • cd $HOME/xbmc-addon
    • make -j$(getconf _NPROCESSORS_ONLN) -C tools/depends/target/binary-addons ADDONS="inputstream.ffmpegdirect" ADDON_SRC_PREFIX=$HOME

Note that the steps in the following section need to be performed before the addon is installed and you can run it in Kodi.

To rebuild the addon and copy to kodi after changes (after the initial addon build)

  1. cd $HOME/inputstream.ffmpegdirect
  2. ./build-install-mac.sh ../xbmc-addon

If you would prefer to run the rebuild steps manually instead of using the above helper script check the appendix here

Settings

FFmpeg HTTP Proxy

This category contains the settings for network configuration such as FFmpeg proxy and bandwidth limits.

Timeshift

This category contains the settings for timeshift. Timeshifting allows you to pause live TV as well as move back and forward from your current position similar to playing back a recording.

Advanced

This category contains the advanced settings for the addon.

Using the addon

The addon can be accessed like any other inputstream in Kodi. The following example will show how to manually choose this addon for playback when using IPTV Simple Client with the following entry in the M3U file (Note that the IPTV Simple Client will in fact automatcially detect a catchup stream and use the addon based on configured settings).

#KODIPROP:inputstream=inputstream.ffmpegdirect
#KODIPROP:mimetype=video/mp2t
#KODIPROP:inputstream.ffmpegdirect.program_number=2154
#KODIPROP:inputstream.ffmpegdirect.is_realtime_stream=true
#EXTINF:-1,MyChannel
http://127.0.0.1:3002/mystream.ts

Note that the appropriate mime type should always be set. Here are the some common ones:

The field program_number can be used to indicate the Program ID to use for TS streams.

If enabling timeshift support for live streams here is an example set of properties.

#KODIPROP:inputstream=inputstream.ffmpegdirect
#KODIPROP:mimetype=application/x-mpegURL
#KODIPROP:inputstream.ffmpegdirect.is_realtime_stream=true
#KODIPROP:inputstream.ffmpegdirect.stream_mode=timeshift
#KODIPROP:inputstream.ffmpegdirect.manifest_type=hls
#EXTINF:-1,MyChannel
http://127.0.0.1:3002/mystream.m3u8

If enabling archive/catchup support there are a number of other properties that needs to be set as shown in this example.

#KODIPROP:inputstream=inputstream.ffmpegdirect
#KODIPROP:mimetype=application/x-mpegURL
#KODIPROP:inputstream.ffmpegdirect.is_realtime_stream=true
#KODIPROP:inputstream.ffmpegdirect.stream_mode=catchup
#KODIPROP:inputstream.ffmpegdirect.open_mode=ffmpeg
#KODIPROP:inputstream.ffmpegdirect.manifest_type=hls
#KODIPROP:inputstream.ffmpegdirect.default_url=http://mysite.com/streamX
#KODIPROP:inputstream.ffmpegdirect.playback_as_live=true
#KODIPROP:inputstream.ffmpegdirect.programme_start_time=1111111
#KODIPROP:inputstream.ffmpegdirect.programme_end_time=2111111
#KODIPROP:inputstream.ffmpegdirect.catchup_url_format_string=http://mysite.com/streamX?cutv={Y}-{m}-{d}T{H}:{M}:{S}
#KODIPROP:inputstream.ffmpegdirect.catchup_buffer_start_time=1111111
#KODIPROP:inputstream.ffmpegdirect.catchup_buffer_end_time=1111111
#KODIPROP:inputstream.ffmpegdirect.catchup_buffer_offset=1111111
#KODIPROP:inputstream.ffmpegdirect.timezone_shift=0
#KODIPROP:inputstream.ffmpegdirect.default_programme_duration=3600
#EXTINF:-1,MyChannel
http://127.0.0.1:3002/mystream.m3u8

Notes:

Appendix

Manual Steps to rebuild the addon on MacOSX

The following steps can be followed manually instead of using the build-install-mac.sh in the root of the addon repo after the initial addon build has been completed.

To rebuild the addon after changes

  1. rm tools/depends/target/binary-addons/.installed-macosx*
  2. make -j$(getconf _NPROCESSORS_ONLN) -C tools/depends/target/binary-addons ADDONS="inputstream.ffmpegdirect" ADDON_SRC_PREFIX=$HOME

or

  1. cd tools/depends/target/binary-addons/macosx*
  2. make

Copy the addon to the Kodi addon directory on Mac

  1. rm -rf "$HOME/Library/Application Support/Kodi/addons/inputstream.ffmpegdirect"
  2. cp -rf $HOME/xbmc-addon/addons/inputstream.ffmpegdirect "$HOME/Library/Application Support/Kodi/addons"