Skip to content

chschnell/desktop2kodi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

desktop2kodi

Stream your Windows desktop to Kodi.

+------------[Windows PC]-----------+
|  +--------+            +-------+  |           +------+
|  | ffmpeg |<--[RTMP]-->|  srs  |<-+--[RTMP]-->| kodi |
|  +--------+            +-------+  |           +------+
|       ^                    ^      |               ^
|       |                    |      |               |
|  +----+--------------------+---+  |               |
|  |       desktop2kodi.py       |--+--[JSON-RPC]---+
|  +-----------------------------+  |
+-----------------------------------+

This Python script is executed on the streaming Windows host and integrates these functions:

  1. launch SRS background process as RTMP server
  2. launch ffmpeg background process to start A/V-grabbing, encoding and streaming to RTMP server
  3. employ Kodi's JSON-RPC interface to start playing from RTMP server
  4. mute the streaming host's desktop speakers while streaming (Windows only)

The script ends when you press Q, it will stop SRS, ffmpeg and kodi and will unmute your desktop speakers.

Installation

You need to install Python 3, ffmpeg, and a clone of this repository. For Windows it is recommended to also install screen-capture-recorder-to-video-windows-free for an audio capture device. You will also need to install SRS.

Configuration

Create a copy of desktop2kodi.ini.template and name it desktop2kodi.ini. This INI file mostly revolves around FFmpeg configuration, and it is the only file you need to edit. Edit your copy as needed, most importantly try to employ a GPU-accelerated video encoder.

This software was developed and tested with a GPU from NVIDIA and a Raspberry Pi 4.

Fixed ffmpeg pipeline

This project's ffmpeg pipeline has a fixed layout:

+---------+     +---------+
| Screen  |     |  Audio  |
| grabber |     | grabber |
+----+----+     +----+----+
     |               |
+----V----+     +----V----+
|  Video  |     |  Audio  |
| encoder |     | encoder |
+----+----+     +----+----+
     |               |
+----V---------------V----+           +-------------+
|      FLV/RTMP muxer     |----//---->| Kodi device |
+-------------------------+           +-------------+

Grabber

The grabbers "Screen grabber" and "Audio grabber" depend on the streaming host's operating system. The video grabber should capture the desktop screen as fast as possible. Any audio grabber will do, but in this use case we prefer "unmutable" audio grabbers (that is an audio grabber that is not muted when the desktop speakers are muted).

Screen grabber

Audio grabber

Encoder

Video encoder

Preferred video encoding format is H.265/HEVC, H.264 is considered only as a fallback in case H.265 is too demanding for either the encoding host or the decoding device. Using a GPU-accelerated encoder on the streaming host is most likely a requirement if you aim for 60fps at 1080p. Usually the decoding device has less computing power than the encoding host, start by identifying hardware-accelerated decoders for the device and then see if you find an accelerated encoder for your streaming host that encodes in the device's preferred format.

  • GPU-accelerated video encoders (Windows and Linux, recommended)
  • CPU-based video encoders (for all platforms)

You can always reduce the load by lowering fps (to 30, for example) and/or screen resolution (to 720p, for example).

Audio encoder

Audio encoder is AAC, the successor to MP3.

  • AAC (recommended)

See also

About

Stream your Windows desktop to Kodi.

Topics

Resources

License

Stars

Watchers

Forks

Languages