]> pere.pagekite.me Git - homepage.git/blob - blog/tags/kodi/kodi.rss
6b2cc0093a25a5358f3e0a1d5ad9f462ab53e6a3
[homepage.git] / blog / tags / kodi / kodi.rss
1 <?xml version="1.0" encoding="utf-8"?>
2 <rss version='2.0' xmlns:lj='http://www.livejournal.org/rss/lj/1.0/'>
3 <channel>
4 <title>Petter Reinholdtsen - Entries tagged kodi</title>
5 <description>Entries tagged kodi</description>
6 <link>https://people.skolelinux.org/pere/blog/</link>
7
8
9 <item>
10 <title>New and improved Frikanalen Kodi addon version 0.0.3</title>
11 <link>https://people.skolelinux.org/pere/blog/New_and_improved_Frikanalen_Kodi_addon_version_0_0_3.html</link>
12 <guid isPermaLink="true">https://people.skolelinux.org/pere/blog/New_and_improved_Frikanalen_Kodi_addon_version_0_0_3.html</guid>
13 <pubDate>Thu, 8 Nov 2018 10:30:00 +0100</pubDate>
14 <description>&lt;p&gt;If you read my blog regularly, you probably know I am involved in
15 running and developing the &lt;a href=&quot;https://frikanalen.no/&quot;&gt;Norwegian
16 TV channel Frikanalen&lt;/a&gt;. It is an open channel, allowing everyone
17 in Norway to publish videos on a TV channel with national coverage.
18 You can think of it as Youtube for national television.
19 In addition to distribution on RiksTV and Uninett, Frikanalen is also
20 available as a Kodi addon. The last few days I have updated the code
21 to add more features. A
22 &lt;a href=&quot;https://kodi.tv/addon/plugins-video-add-ons/frikanalen-nett-tv&quot;&gt;new
23 and improved version 0.0.3 Frikanalen addon&lt;/a&gt; was just made
24 available via the Kodi repositories. This new version include a
25 option to browse videos by category, as well as free text search
26 in the video archive. It will now also show the video duration in the
27 video lists, which were missing earlier. A new and experimental
28 link to the HD video stream currently being worked on is provided, for
29 those that want to see what the &lt;a href=&quot;https://casparcg.com/&quot;&gt;CasparCG&lt;/a&gt;
30 output look like. The alternative is the SD video stream, generated
31 using MLT. CasparCG is controlled by our
32 &lt;a href=&quot;https://github.com/Frikanalen/mltplayout/&quot;&gt;mltplayout
33 server&lt;/a&gt; which instead of talking to mlt is giving PLAY instructions
34 to the CasparCG server when it is time to start a new program.&lt;/p&gt;
35
36 &lt;p&gt;By now, you are probably wondering what kind of content is being
37 played on the channel. These days, it is filled with technical
38 presentations like those from &lt;a href=&quot;https://www.nuug.no/&quot;&gt;NUUG&lt;/a&gt;,
39 &lt;a href=&quot;https://www.debconf.org/&quot;&gt;Debconf&lt;/a&gt;, Makercon, and TED,
40 but there are also some periods with
41 &lt;a href=&quot;https://www.empo.no/&quot;&gt;EMPT TV&lt;/a&gt; and
42 &lt;a href=&quot;https://www.p7.no/&quot;&gt;P7&lt;/a&gt;.
43
44 &lt;p&gt;As usual, if you use Bitcoin and want to show your support of my
45 activities, please send Bitcoin donations to my address
46 &lt;b&gt;&lt;a href=&quot;bitcoin:15oWEoG9dUPovwmUL9KWAnYRtNJEkP1u1b&quot;&gt;15oWEoG9dUPovwmUL9KWAnYRtNJEkP1u1b&lt;/a&gt;&lt;/b&gt;.&lt;/p&gt;
47 </description>
48 </item>
49
50 <item>
51 <title>Using the Kodi API to play Youtube videos</title>
52 <link>https://people.skolelinux.org/pere/blog/Using_the_Kodi_API_to_play_Youtube_videos.html</link>
53 <guid isPermaLink="true">https://people.skolelinux.org/pere/blog/Using_the_Kodi_API_to_play_Youtube_videos.html</guid>
54 <pubDate>Sun, 2 Sep 2018 23:40:00 +0200</pubDate>
55 <description>&lt;p&gt;I continue to explore my Kodi installation, and today I wanted to
56 tell it to play a youtube URL I received in a chat, without having to
57 insert search terms using the on-screen keyboard. After searching the
58 web for API access to the Youtube plugin and testing a bit, I managed
59 to find a recipe that worked. If you got a kodi instance with its API
60 available from http://kodihost/jsonrpc, you can try the following to
61 have check out a nice cover band.&lt;/p&gt;
62
63 &lt;p&gt;&lt;blockquote&gt;&lt;pre&gt;curl --silent --header &#39;Content-Type: application/json&#39; \
64 --data-binary &#39;{ &quot;id&quot;: 1, &quot;jsonrpc&quot;: &quot;2.0&quot;, &quot;method&quot;: &quot;Player.Open&quot;,
65 &quot;params&quot;: {&quot;item&quot;: { &quot;file&quot;:
66 &quot;plugin://plugin.video.youtube/play/?video_id=LuRGVM9O0qg&quot; } } }&#39; \
67 http://projector.local/jsonrpc&lt;/pre&gt;&lt;/blockquote&gt;&lt;/p&gt;
68
69 &lt;p&gt;I&#39;ve extended kodi-stream program to take a video source as its
70 first argument. It can now handle direct video links, youtube links
71 and &#39;desktop&#39; to stream my desktop to Kodi. It is almost like a
72 Chromecast. :)&lt;/p&gt;
73
74 &lt;p&gt;As usual, if you use Bitcoin and want to show your support of my
75 activities, please send Bitcoin donations to my address
76 &lt;b&gt;&lt;a href=&quot;bitcoin:15oWEoG9dUPovwmUL9KWAnYRtNJEkP1u1b&quot;&gt;15oWEoG9dUPovwmUL9KWAnYRtNJEkP1u1b&lt;/a&gt;&lt;/b&gt;.&lt;/p&gt;
77 </description>
78 </item>
79
80 <item>
81 <title>Simple streaming the Linux desktop to Kodi using GStreamer and RTP</title>
82 <link>https://people.skolelinux.org/pere/blog/Simple_streaming_the_Linux_desktop_to_Kodi_using_GStreamer_and_RTP.html</link>
83 <guid isPermaLink="true">https://people.skolelinux.org/pere/blog/Simple_streaming_the_Linux_desktop_to_Kodi_using_GStreamer_and_RTP.html</guid>
84 <pubDate>Thu, 12 Jul 2018 17:55:00 +0200</pubDate>
85 <description>&lt;p&gt;Last night, I wrote
86 &lt;a href=&quot;http://people.skolelinux.org/pere/blog/Streaming_the_Linux_desktop_to_Kodi_using_VLC_and_RTSP.html&quot;&gt;a
87 recipe to stream a Linux desktop using VLC to a instance of Kodi&lt;/a&gt;.
88 During the day I received valuable feedback, and thanks to the
89 suggestions I have been able to rewrite the recipe into a much simpler
90 approach requiring no setup at all. It is a single script that take
91 care of it all.&lt;/p&gt;
92
93 &lt;p&gt;This new script uses GStreamer instead of VLC to capture the
94 desktop and stream it to Kodi. This fixed the video quality issue I
95 saw initially. It further removes the need to add a m3u file on the
96 Kodi machine, as it instead connects to
97 &lt;a href=&quot;https://kodi.wiki/view/JSON-RPC_API/v8&quot;&gt;the JSON-RPC API in
98 Kodi&lt;/a&gt; and simply ask Kodi to play from the stream created using
99 GStreamer. Streaming the desktop to Kodi now become trivial. Copy
100 the script below, run it with the DNS name or IP address of the kodi
101 server to stream to as the only argument, and watch your screen show
102 up on the Kodi screen. Note, it depend on multicast on the local
103 network, so if you need to stream outside the local network, the
104 script must be modified. Also note, I have no idea if audio work, as
105 I only care about the picture part.&lt;/p&gt;
106
107 &lt;blockquote&gt;&lt;pre&gt;
108 #!/bin/sh
109 #
110 # Stream the Linux desktop view to Kodi. See
111 # http://people.skolelinux.org/pere/blog/Streaming_the_Linux_desktop_to_Kodi_using_VLC_and_RTSP.html
112 # for backgorund information.
113
114 # Make sure the stream is stopped in Kodi and the gstreamer process is
115 # killed if something go wrong (for example if curl is unable to find the
116 # kodi server). Do the same when interrupting this script.
117 kodicmd() {
118 host=&quot;$1&quot;
119 cmd=&quot;$2&quot;
120 params=&quot;$3&quot;
121 curl --silent --header &#39;Content-Type: application/json&#39; \
122 --data-binary &quot;{ \&quot;id\&quot;: 1, \&quot;jsonrpc\&quot;: \&quot;2.0\&quot;, \&quot;method\&quot;: \&quot;$cmd\&quot;, \&quot;params\&quot;: $params }&quot; \
123 &quot;http://$host/jsonrpc&quot;
124 }
125 cleanup() {
126 if [ -n &quot;$kodihost&quot; ] ; then
127 # Stop the playing when we end
128 playerid=$(kodicmd &quot;$kodihost&quot; Player.GetActivePlayers &quot;{}&quot; |
129 jq .result[].playerid)
130 kodicmd &quot;$kodihost&quot; Player.Stop &quot;{ \&quot;playerid\&quot; : $playerid }&quot; &gt; /dev/null
131 fi
132 if [ &quot;$gstpid&quot; ] &amp;&amp; kill -0 &quot;$gstpid&quot; &gt;/dev/null 2&gt;&amp;1; then
133 kill &quot;$gstpid&quot;
134 fi
135 }
136 trap cleanup EXIT INT
137
138 if [ -n &quot;$1&quot; ]; then
139 kodihost=$1
140 shift
141 else
142 kodihost=kodi.local
143 fi
144
145 mcast=239.255.0.1
146 mcastport=1234
147 mcastttl=1
148
149 pasrc=$(pactl list | grep -A2 &#39;Source #&#39; | grep &#39;Name: .*\.monitor$&#39; | \
150 cut -d&quot; &quot; -f2|head -1)
151 gst-launch-1.0 ximagesrc use-damage=0 ! video/x-raw,framerate=30/1 ! \
152 videoconvert ! queue2 ! \
153 x264enc bitrate=8000 speed-preset=superfast tune=zerolatency qp-min=30 \
154 key-int-max=15 bframes=2 ! video/x-h264,profile=high ! queue2 ! \
155 mpegtsmux alignment=7 name=mux ! rndbuffersize max=1316 min=1316 ! \
156 udpsink host=$mcast port=$mcastport ttl-mc=$mcastttl auto-multicast=1 sync=0 \
157 pulsesrc device=$pasrc ! audioconvert ! queue2 ! avenc_aac ! queue2 ! mux. \
158 &gt; /dev/null 2&gt;&amp;1 &amp;
159 gstpid=$!
160
161 # Give stream a second to get going
162 sleep 1
163
164 # Ask kodi to start streaming using its JSON-RPC API
165 kodicmd &quot;$kodihost&quot; Player.Open \
166 &quot;{\&quot;item\&quot;: { \&quot;file\&quot;: \&quot;udp://@$mcast:$mcastport\&quot; } }&quot; &gt; /dev/null
167
168 # wait for gst to end
169 wait &quot;$gstpid&quot;
170 &lt;/pre&gt;&lt;/blockquote&gt;
171
172 &lt;p&gt;I hope you find the approach useful. I know I do.&lt;/p&gt;
173
174 &lt;p&gt;As usual, if you use Bitcoin and want to show your support of my
175 activities, please send Bitcoin donations to my address
176 &lt;b&gt;&lt;a href=&quot;bitcoin:15oWEoG9dUPovwmUL9KWAnYRtNJEkP1u1b&quot;&gt;15oWEoG9dUPovwmUL9KWAnYRtNJEkP1u1b&lt;/a&gt;&lt;/b&gt;.&lt;/p&gt;
177 </description>
178 </item>
179
180 <item>
181 <title>Streaming the Linux desktop to Kodi using VLC and RTSP</title>
182 <link>https://people.skolelinux.org/pere/blog/Streaming_the_Linux_desktop_to_Kodi_using_VLC_and_RTSP.html</link>
183 <guid isPermaLink="true">https://people.skolelinux.org/pere/blog/Streaming_the_Linux_desktop_to_Kodi_using_VLC_and_RTSP.html</guid>
184 <pubDate>Thu, 12 Jul 2018 02:00:00 +0200</pubDate>
185 <description>&lt;p&gt;PS: See
186 &lt;ahref=&quot;http://people.skolelinux.org/pere/blog/Simple_streaming_the_Linux_desktop_to_Kodi_using_GStreamer_and_RTP.html&quot;&gt;the
187 followup post&lt;/a&gt; for a even better approach.&lt;/p&gt;
188
189 &lt;p&gt;A while back, I was asked by a friend how to stream the desktop to
190 my projector connected to Kodi. I sadly had to admit that I had no
191 idea, as it was a task I never had tried. Since then, I have been
192 looking for a way to do so, preferable without much extra software to
193 install on either side. Today I found a way that seem to kind of
194 work. Not great, but it is a start.&lt;/p&gt;
195
196 &lt;p&gt;I had a look at several approaches, for example
197 &lt;a href=&quot;https://github.com/mfoetsch/dlna_live_streaming&quot;&gt;using uPnP
198 DLNA as described in 2011&lt;/a&gt;, but it required a uPnP server, fuse and
199 local storage enough to store the stream locally. This is not going
200 to work well for me, lacking enough free space, and it would
201 impossible for my friend to get working.&lt;/p&gt;
202
203 &lt;p&gt;Next, it occurred to me that perhaps I could use VLC to create a
204 video stream that Kodi could play. Preferably using
205 broadcast/multicast, to avoid having to change any setup on the Kodi
206 side when starting such stream. Unfortunately, the only recipe I
207 could find using multicast used the rtp protocol, and this protocol
208 seem to not be supported by Kodi.&lt;/p&gt;
209
210 &lt;p&gt;On the other hand, the rtsp protocol is working! Unfortunately I
211 have to specify the IP address of the streaming machine in both the
212 sending command and the file on the Kodi server. But it is showing my
213 desktop, and thus allow us to have a shared look on the big screen at
214 the programs I work on.&lt;/p&gt;
215
216 &lt;p&gt;I did not spend much time investigating codeces. I combined the
217 rtp and rtsp recipes from
218 &lt;a href=&quot;https://wiki.videolan.org/Documentation:Streaming_HowTo/Command_Line_Examples/&quot;&gt;the
219 VLC Streaming HowTo/Command Line Examples&lt;/a&gt;, and was able to get
220 this working on the desktop/streaming end.&lt;/p&gt;
221
222 &lt;blockquote&gt;&lt;pre&gt;
223 vlc screen:// --sout \
224 &#39;#transcode{vcodec=mp4v,acodec=mpga,vb=800,ab=128}:rtp{dst=projector.local,port=1234,sdp=rtsp://192.168.11.4:8080/test.sdp}&#39;
225 &lt;/pre&gt;&lt;/blockquote&gt;
226
227 &lt;p&gt;I ssh-ed into my Kodi box and created a file like this with the
228 same IP address:&lt;/p&gt;
229
230 &lt;blockquote&gt;&lt;pre&gt;
231 echo rtsp://192.168.11.4:8080/test.sdp \
232 &gt; /storage/videos/screenstream.m3u
233 &lt;/pre&gt;&lt;/blockquote&gt;
234
235 &lt;p&gt;Note the 192.168.11.4 IP address is my desktops IP address. As far
236 as I can tell the IP must be hardcoded for this to work. In other
237 words, if someone elses machine is going to do the steaming, you have
238 to update screenstream.m3u on the Kodi machine and adjust the vlc
239 recipe. To get started, locate the file in Kodi and select the m3u
240 file while the VLC stream is running. The desktop then show up in my
241 big screen. :)&lt;/p&gt;
242
243 &lt;p&gt;When using the same technique to stream a video file with audio,
244 the audio quality is really bad. No idea if the problem is package
245 loss or bad parameters for the transcode. I do not know VLC nor Kodi
246 enough to tell.&lt;/p&gt;
247
248 &lt;p&gt;&lt;strong&gt;Update 2018-07-12&lt;/strong&gt;: Johannes Schauer send me a few
249 succestions and reminded me about an important step. The &quot;screen:&quot;
250 input source is only available once the vlc-plugin-access-extra
251 package is installed on Debian. Without it, you will see this error
252 message: &quot;VLC is unable to open the MRL &#39;screen://&#39;. Check the log
253 for details.&quot; He further found that it is possible to drop some parts
254 of the VLC command line to reduce the amount of hardcoded information.
255 It is also useful to consider using cvlc to avoid having the VLC
256 window in the desktop view. In sum, this give us this command line on
257 the source end
258
259 &lt;blockquote&gt;&lt;pre&gt;
260 cvlc screen:// --sout \
261 &#39;#transcode{vcodec=mp4v,acodec=mpga,vb=800,ab=128}:rtp{sdp=rtsp://:8080/}&#39;
262 &lt;/pre&gt;&lt;/blockquote&gt;
263
264 &lt;p&gt;and this on the Kodi end&lt;p&gt;
265
266 &lt;blockquote&gt;&lt;pre&gt;
267 echo rtsp://192.168.11.4:8080/ \
268 &gt; /storage/videos/screenstream.m3u
269 &lt;/pre&gt;&lt;/blockquote&gt;
270
271 &lt;p&gt;Still bad image quality, though. But I did discover that streaming
272 a DVD using dvdsimple:///dev/dvd as the source had excellent video and
273 audio quality, so I guess the issue is in the input or transcoding
274 parts, not the rtsp part. I&#39;ve tried to change the vb and ab
275 parameters to use more bandwidth, but it did not make a
276 difference.&lt;/p&gt;
277
278 &lt;p&gt;I further received a suggestion from Einar Haraldseid to try using
279 gstreamer instead of VLC, and this proved to work great! He also
280 provided me with the trick to get Kodi to use a multicast stream as
281 its source. By using this monstrous oneliner, I can stream my desktop
282 with good video quality in reasonable framerate to the 239.255.0.1
283 multicast address on port 1234:
284
285 &lt;blockquote&gt;&lt;pre&gt;
286 gst-launch-1.0 ximagesrc use-damage=0 ! video/x-raw,framerate=30/1 ! \
287 videoconvert ! queue2 ! \
288 x264enc bitrate=8000 speed-preset=superfast tune=zerolatency qp-min=30 \
289 key-int-max=15 bframes=2 ! video/x-h264,profile=high ! queue2 ! \
290 mpegtsmux alignment=7 name=mux ! rndbuffersize max=1316 min=1316 ! \
291 udpsink host=239.255.0.1 port=1234 ttl-mc=1 auto-multicast=1 sync=0 \
292 pulsesrc device=$(pactl list | grep -A2 &#39;Source #&#39; | \
293 grep &#39;Name: .*\.monitor$&#39; | cut -d&quot; &quot; -f2|head -1) ! \
294 audioconvert ! queue2 ! avenc_aac ! queue2 ! mux.
295 &lt;/pre&gt;&lt;/blockquote&gt;
296
297 &lt;p&gt;and this on the Kodi end&lt;p&gt;
298
299 &lt;blockquote&gt;&lt;pre&gt;
300 echo udp://@239.255.0.1:1234 \
301 &gt; /storage/videos/screenstream.m3u
302 &lt;/pre&gt;&lt;/blockquote&gt;
303
304 &lt;p&gt;Note the trick to pick a valid pulseaudio source. It might not
305 pick the one you need. This approach will of course lead to trouble
306 if more than one source uses the same multicast port and address.
307 Note the ttl-mc=1 setting, which limit the multicast packages to the
308 local network. If the value is increased, your screen will be
309 broadcasted further, one network &quot;hop&quot; for each increase (read up on
310 multicast to learn more. :)!&lt;/p&gt;
311
312 &lt;p&gt;Having cracked how to get Kodi to receive multicast streams, I
313 could use this VLC command to stream to the same multicast address.
314 The image quality is way better than the rtsp approach, but gstreamer
315 seem to be doing a better job.&lt;/p&gt;
316
317 &lt;blockquote&gt;&lt;pre&gt;
318 cvlc screen:// --sout &#39;#transcode{vcodec=mp4v,acodec=mpga,vb=800,ab=128}:rtp{mux=ts,dst=239.255.0.1,port=1234,sdp=sap}&#39;
319 &lt;/pre&gt;&lt;/blockquote&gt;
320
321 &lt;p&gt;As usual, if you use Bitcoin and want to show your support of my
322 activities, please send Bitcoin donations to my address
323 &lt;b&gt;&lt;a href=&quot;bitcoin:15oWEoG9dUPovwmUL9KWAnYRtNJEkP1u1b&quot;&gt;15oWEoG9dUPovwmUL9KWAnYRtNJEkP1u1b&lt;/a&gt;&lt;/b&gt;.&lt;/p&gt;
324 </description>
325 </item>
326
327 </channel>
328 </rss>