]> pere.pagekite.me Git - homepage.git/blob - blog/data/2018-07-12-kodi-linux-desktop-vlc.txt
Typo.
[homepage.git] / blog / data / 2018-07-12-kodi-linux-desktop-vlc.txt
1 Title: Streaming the Linux desktop to Kodi using VLC and RTSP
2 Tags: english, debian, video
3 Date: 2018-07-12 02:00
4
5 <p>A while back, I was asked by a friend how to stream the desktop to
6 my projector connected to Kodi. I sadly had to admit that I had no
7 idea, as it was a task I never had tried. Since then, I have been
8 looking for a way to do so, preferable without much extra software to
9 install on either side. Today I found a way that seem to kind of
10 work. Not great, but it is a start.</p>
11
12 <p>I had a look at several approaches, for example
13 <a href="https://github.com/mfoetsch/dlna_live_streaming">using uPnP
14 DLNA as described in 2011</a>, but it required a uPnP server, fuse and
15 local storage enough to store the stream locally. This is not going
16 to work well for me, lacking enough free space, and it would
17 impossible for my friend to get working.</p>
18
19 <p>Next, it occurred to me that perhaps I could use VLC to create a
20 video stream that Kodi could play. Preferably using
21 broadcast/multicast, to avoid having to change any setup on the Kodi
22 side when starting such stream. Unfortunately, the only recipe I
23 could find using multicast used the rtp protocol, and this protocol
24 seem to not be supported by Kodi.</p>
25
26 <p>On the other hand, the rtsp protocol is working! Unfortunately I
27 have to specify the IP address of the streaming machine in both the
28 sending command and the file on the Kodi server. But it is showing my
29 desktop, and thus allow us to have a shared look on the big screen at
30 the programs I work on.</p>
31
32 <p>I did not spend much time investigating codeces. I combined the
33 rtp and rtsp recipes from
34 <a href="https://wiki.videolan.org/Documentation:Streaming_HowTo/Command_Line_Examples/">the
35 VLC Streaming HowTo/Command Line Examples</a>, and was able to get
36 this working on the desktop/streaming end.</p>
37
38 <blockquote><pre>
39 vlc screen:// --sout \
40 '#transcode{vcodec=mp4v,acodec=mpga,vb=800,ab=128}:rtp{dst=projector.local,port=1234,sdp=rtsp://192.168.11.4:8080/test.sdp}'
41 </pre></blockquote>
42
43 <p>I ssh-ed into my Kodi box and created a file like this with the
44 same IP address:</p>
45
46 <blockquote><pre>
47 echo rtsp://192.168.11.4:8080/test.sdp \
48 > /storage/videos/screenstream.m3u
49 </pre></blockquote>
50
51 <p>Note the 192.168.11.4 IP address is my desktops IP address. As far
52 as I can tell the IP must be hardcoded for this to work. In other
53 words, if someone elses machine is going to do the steaming, you have
54 to update screenstream.m4u on the Kodi machine and adjust the vlc
55 recipe. To get started, locate the file in Kodi and select the m3u
56 file while the VLC stream is running. The desktop then show up in my
57 big screen. :)</p>
58
59 <p>When using the same technique to stream a video file with audio,
60 the audio quality is really bad. No idea if the problem is package
61 loss or bad parameters for the transcode. I do not know VLC nor Kodi
62 enough to tell.</p>
63
64 <p><strong>Update 2018-07-12</strong>: Johannes Schauer send me a few
65 succestions and reminded me about an important step. The "screen:"
66 input source is only available once the vlc-plugin-access-extra
67 package is installed on Debian. Without it, you will see this error
68 message: "VLC is unable to open the MRL 'screen://'. Check the log
69 for details." He further found that it is possible to drop some parts
70 of the VLC command line to reduce the amount of hardcoded information.
71 It is also useful to consider using cvlc to avoid having the VLC
72 window in the desktop view. In sum, this give us this command line on
73 the source end
74
75 <blockquote><pre>
76 cvlc screen:// --sout \
77 '#transcode{vcodec=mp4v,acodec=mpga,vb=800,ab=128}:rtp{sdp=rtsp://:8080/}'
78 </pre></blockquote>
79
80 <p>and this on the Kodi end<p>
81
82 <blockquote><pre>
83 echo rtsp://192.168.11.4:8080/ \
84 > /storage/videos/screenstream.m3u
85 </pre></blockquote>
86
87 <p>Still bad image quality, though. But I did discover that streaming
88 a DVD using dvdsimple:///dev/dvd as the source had excellent video and
89 audio quality, so I guess the issue is in the input or transcoding
90 parts, not the rtsp part. I've tried to change the vb and ab
91 parameters to use more bandwidth, but it did not make a
92 difference.</p>
93
94 <p>As usual, if you use Bitcoin and want to show your support of my
95 activities, please send Bitcoin donations to my address
96 <b><a href="bitcoin:15oWEoG9dUPovwmUL9KWAnYRtNJEkP1u1b">15oWEoG9dUPovwmUL9KWAnYRtNJEkP1u1b</a></b>.</p>