1 <?xml version=
"1.0" encoding=
"utf-8"?>
2 <rss version='
2.0' xmlns:lj='http://www.livejournal.org/rss/lj/
1.0/' xmlns:
atom=
"http://www.w3.org/2005/Atom">
4 <title>Petter Reinholdtsen
</title>
5 <description></description>
6 <link>http://people.skolelinux.org/pere/blog/
</link>
7 <atom:link href=
"http://people.skolelinux.org/pere/blog/index.rss" rel=
"self" type=
"application/rss+xml" />
10 <title>Automatic Google Drive sync using grive in Debian
</title>
11 <link>http://people.skolelinux.org/pere/blog/Automatic_Google_Drive_sync_using_grive_in_Debian.html
</link>
12 <guid isPermaLink=
"true">http://people.skolelinux.org/pere/blog/Automatic_Google_Drive_sync_using_grive_in_Debian.html
</guid>
13 <pubDate>Thu,
4 Oct
2018 15:
20:
00 +
0200</pubDate>
14 <description><p
>A few days, I rescued a Windows victim over to Debian. To try to
15 rescue the remains, I helped set up automatic sync with Google Drive.
16 I did not find any sensible Debian package handling this
17 automatically, so I rebuild the grive2 source from
18 <a href=
"http://www.webupd8.org/
">the Ubuntu UPD8 PPA
</a
> to do the
19 task and added a autostart desktop entry and a small shell script to
20 run in the background while the user is logged in to do the sync.
21 Here is a sketch of the setup for future reference.
</p
>
23 <p
>I first created
<tt
>~/googledrive
</tt
>, entered the directory and
24 ran
'<tt
>grive -a
</tt
>' to authenticate the machine/user. Next, I
25 created a autostart hook in
<tt
>~/.config/autostart/grive.desktop
</tt
>
26 to start the sync when the user log in:
</p
>
28 <p
><blockquote
><pre
>
30 Name=Google drive autosync
32 Exec=/home/user/bin/grive-sync
33 </pre
></blockquote
></p
>
35 <p
>Finally, I wrote the
<tt
>~/bin/grive-sync
</tt
> script to sync
36 ~/googledrive/ with the files in Google Drive.
</p
>
38 <p
><blockquote
><pre
>
43 if [
"$syncpid
" ] ; then
47 trap cleanup EXIT INT QUIT
48 /usr/lib/grive/grive-sync.sh listen googledrive
2>&1 | sed
"s%^%$
0:%
" &
51 if ! xhost
>/dev/null
2>&1 ; then
52 echo
"no DISPLAY, exiting as the user probably logged out
"
55 if [ ! -e /run/user/
1000/grive-sync.sh_googledrive ] ; then
56 /usr/lib/grive/grive-sync.sh sync googledrive
59 done
2>&1 | sed
"s%^%$
0:%
"
60 </pre
></blockquote
></p
>
62 <p
>Feel free to use the setup if you want. It can be assumed to be
63 GNU GPL v2 licensed (or any later version, at your leisure), but I
64 doubt this code is possible to claim copyright on.
</p
>
66 <p
>As usual, if you use Bitcoin and want to show your support of my
67 activities, please send Bitcoin donations to my address
68 <b
><a href=
"bitcoin:
15oWEoG9dUPovwmUL9KWAnYRtNJEkP1u1b
">15oWEoG9dUPovwmUL9KWAnYRtNJEkP1u1b
</a
></b
>.
</p
>
73 <title>Valutakrambod - A python and bitcoin love story
</title>
74 <link>http://people.skolelinux.org/pere/blog/Valutakrambod___A_python_and_bitcoin_love_story.html
</link>
75 <guid isPermaLink=
"true">http://people.skolelinux.org/pere/blog/Valutakrambod___A_python_and_bitcoin_love_story.html
</guid>
76 <pubDate>Sat,
29 Sep
2018 22:
20:
00 +
0200</pubDate>
77 <description><p
>It would come as no surprise to anyone that I am interested in
78 bitcoins and virtual currencies. I
've been keeping an eye on virtual
79 currencies for many years, and it is part of the reason a few months
80 ago, I started writing a python library for collecting currency
81 exchange rates and trade on virtual currency exchanges. I decided to
82 name the end result valutakrambod, which perhaps can be translated to
83 small currency shop.
</p
>
85 <p
>The library uses the tornado python library to handle HTTP and
86 websocket connections, and provide a asynchronous system for
87 connecting to and tracking several services. The code is available
89 <a href=
"http://github.com/petterreinholdtsen/valutakrambod
">github
</a
>.
</p
>
91 </p
>There are two example clients of the library. One is very simple and
92 list every updated buy/sell price received from the various services.
93 This code is started by running bin/btc-rates and call the client code
94 in valutakrambod/client.py. The simple client look like this:
</p
>
96 <p
><blockquote
><pre
>
100 class SimpleClient(object):
105 def newdata(self, service, pair, changed):
106 print(
"%-
15s %s-%s: %
8.3f %
8.3f
" % (
107 service.servicename(),
110 service.rates[pair][
'ask
'],
111 service.rates[pair][
'bid
'])
113 async def refresh(self, service):
114 await service.fetchRates(service.wantedpairs)
116 self.ioloop = tornado.ioloop.IOLoop.current()
117 self.services = valutakrambod.service.knownServices()
118 for e in self.services:
120 service.subscribe(self.newdata)
121 stream = service.websocket()
123 self.streams.append(stream)
125 # Fetch information from non-streaming services immediately
126 self.ioloop.call_later(len(self.services),
127 functools.partial(self.refresh, service))
128 # as well as regularly
129 service.periodicUpdate(
60)
130 for stream in self.streams:
134 except KeyboardInterrupt:
135 print(
"Interrupted by keyboard, closing all connections.
")
137 for stream in self.streams:
139 </pre
></blockquote
></p
>
141 <p
>The library client loops over all known
"public
" services,
142 initialises it, subscribes to any updates from the service, checks and
143 activates websocket streaming if the service provide it, and if no
144 streaming is supported, fetches information from the service and sets
145 up a periodic update every
60 seconds. The output from this client
146 can look like this:
</p
>
148 <p
><blockquote
><pre
>
149 Bl3p BTC-EUR:
5687.110 5653.690
150 Bl3p BTC-EUR:
5687.110 5653.690
151 Bl3p BTC-EUR:
5687.110 5653.690
152 Hitbtc BTC-USD:
6594.560 6593.690
153 Hitbtc BTC-USD:
6594.560 6593.690
154 Bl3p BTC-EUR:
5687.110 5653.690
155 Hitbtc BTC-USD:
6594.570 6593.690
156 Bitstamp EUR-USD:
1.159 1.154
157 Hitbtc BTC-USD:
6594.570 6593.690
158 Hitbtc BTC-USD:
6594.580 6593.690
159 Hitbtc BTC-USD:
6594.580 6593.690
160 Hitbtc BTC-USD:
6594.580 6593.690
161 Bl3p BTC-EUR:
5687.110 5653.690
162 Paymium BTC-EUR:
5680.000 5620.240
163 </pre
></blockquote
></p
>
165 <p
>The exchange order book is tracked in addition to the best buy/sell
166 price, for those that need to know the details.
</p
>
168 <p
>The other example client is focusing on providing a curses view
169 with updated buy/sell prices as soon as they are received from the
170 services. This code is located in bin/btc-rates-curses and activated
171 by using the
'-c
' argument. Without the argument the
"curses
" output
172 is printed without using curses, which is useful for debugging. The
173 curses view look like this:
</p
>
175 <p
><blockquote
><pre
>
176 Name Pair Bid Ask Spr Ftcd Age
177 BitcoinsNorway BTCEUR
5591.8400 5711.0800 2.1%
16 nan
60
178 Bitfinex BTCEUR
5671.0000 5671.2000 0.0%
16 22 59
179 Bitmynt BTCEUR
5580.8000 5807.5200 3.9%
16 41 60
180 Bitpay BTCEUR
5663.2700 nan nan%
15 nan
60
181 Bitstamp BTCEUR
5664.8400 5676.5300 0.2%
0 1 1
182 Bl3p BTCEUR
5653.6900 5684.9400 0.5%
0 nan
19
183 Coinbase BTCEUR
5600.8200 5714.9000 2.0%
15 nan nan
184 Kraken BTCEUR
5670.1000 5670.2000 0.0%
14 17 60
185 Paymium BTCEUR
5620.0600 5680.0000 1.1%
1 7515 nan
186 BitcoinsNorway BTCNOK
52898.9700 54034.6100 2.1%
16 nan
60
187 Bitmynt BTCNOK
52960.3200 54031.1900 2.0%
16 41 60
188 Bitpay BTCNOK
53477.7833 nan nan%
16 nan
60
189 Coinbase BTCNOK
52990.3500 54063.0600 2.0%
15 nan nan
190 MiraiEx BTCNOK
52856.5300 54100.6000 2.3%
16 nan nan
191 BitcoinsNorway BTCUSD
6495.5300 6631.5400 2.1%
16 nan
60
192 Bitfinex BTCUSD
6590.6000 6590.7000 0.0%
16 23 57
193 Bitpay BTCUSD
6564.1300 nan nan%
15 nan
60
194 Bitstamp BTCUSD
6561.1400 6565.6200 0.1%
0 2 1
195 Coinbase BTCUSD
6504.0600 6635.9700 2.0%
14 nan
117
196 Gemini BTCUSD
6567.1300 6573.0700 0.1%
16 89 nan
197 Hitbtc+BTCUSD
6592.6200 6594.2100 0.0%
0 0 0
198 Kraken BTCUSD
6565.2000 6570.9000 0.1%
15 17 58
199 Exchangerates EURNOK
9.4665 9.4665 0.0%
16 107789 nan
200 Norgesbank EURNOK
9.4665 9.4665 0.0%
16 107789 nan
201 Bitstamp EURUSD
1.1537 1.1593 0.5%
4 5 1
202 Exchangerates EURUSD
1.1576 1.1576 0.0%
16 107789 nan
203 BitcoinsNorway LTCEUR
1.0000 49.0000 98.0%
16 nan nan
204 BitcoinsNorway LTCNOK
492.4800 503.7500 2.2%
16 nan
60
205 BitcoinsNorway LTCUSD
1.0221 49.0000 97.9%
15 nan nan
206 Norgesbank USDNOK
8.1777 8.1777 0.0%
16 107789 nan
207 </pre
></blockquote
></p
>
209 <p
>The code for this client is too complex for a simple blog post, so
210 you will have to check out the git repository to figure out how it
211 work. What I can tell is how the three last numbers on each line
212 should be interpreted. The first is how many seconds ago information
213 was received from the service. The second is how long ago, according
214 to the service, the provided information was updated. The last is an
215 estimate on how often the buy/sell values change.
</p
>
217 <p
>If you find this library useful, or would like to improve it, I
218 would love to hear from you. Note that for some of the services I
've
219 implemented a trading API. It might be the topic of a future blog
222 <p
>As usual, if you use Bitcoin and want to show your support of my
223 activities, please send Bitcoin donations to my address
224 <b
><a href=
"bitcoin:
15oWEoG9dUPovwmUL9KWAnYRtNJEkP1u1b
">15oWEoG9dUPovwmUL9KWAnYRtNJEkP1u1b
</a
></b
>.
</p
>
229 <title>VLC in Debian now can do bittorrent streaming
</title>
230 <link>http://people.skolelinux.org/pere/blog/VLC_in_Debian_now_can_do_bittorrent_streaming.html
</link>
231 <guid isPermaLink=
"true">http://people.skolelinux.org/pere/blog/VLC_in_Debian_now_can_do_bittorrent_streaming.html
</guid>
232 <pubDate>Mon,
24 Sep
2018 21:
20:
00 +
0200</pubDate>
233 <description><p
>Back in February, I got curious to see
234 <a href=
"http://people.skolelinux.org/pere/blog/Using_VLC_to_stream_bittorrent_sources.html
">if
235 VLC now supported Bittorrent streaming
</a
>. It did not, despite the
236 fact that the idea and code to handle such streaming had been floating
237 around for years. I did however find
238 <a href=
"https://github.com/johang/vlc-bittorrent
">a standalone plugin
239 for VLC
</a
> to do it, and half a year later I decided to wrap up the
240 plugin and get it into Debian. I uploaded it to NEW a few days ago,
241 and am very happy to report that it
242 <a href=
"https://tracker.debian.org/pkg/vlc-plugin-bittorrent
">entered
243 Debian
</a
> a few hours ago, and should be available in Debian/Unstable
244 tomorrow, and Debian/Testing in a few days.
</p
>
246 <p
>With the vlc-plugin-bittorrent package installed you should be able
247 to stream videos using a simple call to
</p
>
249 <p
><blockquote
><pre
>
250 vlc https://archive.org/download/TheGoat/TheGoat_archive.torrent
251 </pre
></blockquote
></p
>
253 </p
>It can handle magnet links too. Now if only native vlc had
254 bittorrent support. Then a lot more would be helping each other to
255 share public domain and creative commons movies. The plugin need some
256 stability work with seeking and picking the right file in a torrent
257 with many files, but is already usable. Please note that the plugin
258 is not removing downloaded files when vlc is stopped, so it can fill
259 up your disk if you are not careful. Have fun. :)
</p
>
261 <p
>I would love to get help maintaining this package. Get in touch if
262 you are interested.
</p
>
264 <p
>As usual, if you use Bitcoin and want to show your support of my
265 activities, please send Bitcoin donations to my address
266 <b
><a href=
"bitcoin:
15oWEoG9dUPovwmUL9KWAnYRtNJEkP1u1b
">15oWEoG9dUPovwmUL9KWAnYRtNJEkP1u1b
</a
></b
>.
</p
>
271 <title>Using the Kodi API to play Youtube videos
</title>
272 <link>http://people.skolelinux.org/pere/blog/Using_the_Kodi_API_to_play_Youtube_videos.html
</link>
273 <guid isPermaLink=
"true">http://people.skolelinux.org/pere/blog/Using_the_Kodi_API_to_play_Youtube_videos.html
</guid>
274 <pubDate>Sun,
2 Sep
2018 23:
40:
00 +
0200</pubDate>
275 <description><p
>I continue to explore my Kodi installation, and today I wanted to
276 tell it to play a youtube URL I received in a chat, without having to
277 insert search terms using the on-screen keyboard. After searching the
278 web for API access to the Youtube plugin and testing a bit, I managed
279 to find a recipe that worked. If you got a kodi instance with its API
280 available from http://kodihost/jsonrpc, you can try the following to
281 have check out a nice cover band.
</p
>
283 <p
><blockquote
><pre
>curl --silent --header
'Content-Type: application/json
' \
284 --data-binary
'{
"id
":
1,
"jsonrpc
":
"2.0",
"method
":
"Player.Open
",
285 "params
": {
"item
": {
"file
":
286 "plugin://plugin.video.youtube/play/?video_id=LuRGVM9O0qg
" } } }
' \
287 http://projector.local/jsonrpc
</pre
></blockquote
></p
>
289 <p
>I
've extended kodi-stream program to take a video source as its
290 first argument. It can now handle direct video links, youtube links
291 and
'desktop
' to stream my desktop to Kodi. It is almost like a
292 Chromecast. :)
</p
>
294 <p
>As usual, if you use Bitcoin and want to show your support of my
295 activities, please send Bitcoin donations to my address
296 <b
><a href=
"bitcoin:
15oWEoG9dUPovwmUL9KWAnYRtNJEkP1u1b
">15oWEoG9dUPovwmUL9KWAnYRtNJEkP1u1b
</a
></b
>.
</p
>
301 <title>Software created using taxpayers’ money should be Free Software
</title>
302 <link>http://people.skolelinux.org/pere/blog/Software_created_using_taxpayers__money_should_be_Free_Software.html
</link>
303 <guid isPermaLink=
"true">http://people.skolelinux.org/pere/blog/Software_created_using_taxpayers__money_should_be_Free_Software.html
</guid>
304 <pubDate>Thu,
30 Aug
2018 13:
50:
00 +
0200</pubDate>
305 <description><p
>It might seem obvious that software created using tax money should
306 be available for everyone to use and improve. Free Software
307 Foundation Europe recentlystarted a campaign to help get more people
308 to understand this, and I just signed the petition on
309 <a href=
"https://publiccode.eu/
">Public Money, Public Code
</a
> to help
310 them. I hope you too will do the same.
</p
>
315 <title>A bit more on privacy respecting health monitor / fitness tracker
</title>
316 <link>http://people.skolelinux.org/pere/blog/A_bit_more_on_privacy_respecting_health_monitor___fitness_tracker.html
</link>
317 <guid isPermaLink=
"true">http://people.skolelinux.org/pere/blog/A_bit_more_on_privacy_respecting_health_monitor___fitness_tracker.html
</guid>
318 <pubDate>Mon,
13 Aug
2018 09:
00:
00 +
0200</pubDate>
319 <description><p
>A few days ago, I wondered if there are any privacy respecting
320 health monitors and/or fitness trackers available for sale these days.
321 I would like to buy one, but do not want to share my personal data
322 with strangers, nor be forced to have a mobile phone to get data out
323 of the unit. I
've received some ideas, and would like to share them
326 One interesting data point was a pointer to a Free Software app for
328 <a href=
"https://github.com/Freeyourgadget/Gadgetbridge/
">Gadgetbridge
</a
>.
329 It provide cloudless collection and storing of data from a variety of
331 <a href=
"https://github.com/Freeyourgadget/Gadgetbridge/#supported-devices
">list
332 of supported devices
</a
> is a good indicator for units where the
333 protocol is fairly open, as it is obviously being handled by Free
334 Software. Other units are reportedly encrypting the collected
335 information with their own public key, making sure only the vendor
336 cloud service is able to extract data from the unit. The people
337 contacting me about Gadgetbirde said they were using
338 <a href=
"https://us.amazfit.com/shop/bip?variant=
336750">Amazfit
340 <a href=
"http://www.xiaomimi6phone.com/xiaomi-mi-band-
3-features-release-date-rumors/
">Xiaomi
341 Band
3</a
>.
</p
>
343 <p
>I also got a suggestion to look at some of the units from Garmin.
344 I was told their GPS watches can be connected via USB and show up as a
345 USB storage device with
346 <a href=
"https://www.gpsbabel.org/htmldoc-development/fmt_garmin_fit.html
">Garmin
347 FIT files
</a
> containing the collected measurements. While
348 proprietary, FIT files apparently can be read at least by
349 <a href=
"https://www.gpsbabel.org
">GPSBabel
</a
> and the
350 <a href=
"https://apps.nextcloud.com/apps/gpxpod
">GpxPod
</a
> Nextcloud
351 app. It is unclear to me if they can read step count and heart rate
352 data. The person I talked to was using a
353 <a href=
"https://buy.garmin.com/en-US/US/p/
564291">Garmin Forerunner
354 935</a
>, which is a fairly expensive unit. I doubt it is worth it for
355 a unit where the vendor clearly is trying its best to move from open
356 to closed systems. I still remember when Garmin dropped NMEA support
357 in its GPSes.
</p
>
359 <p
>A final idea was to build ones own unit, perhaps by basing it on a
360 wearable hardware platforms like
361 <a href=
"https://learn.adafruit.com/flora-geo-watch
">the Flora Geo
362 Watch
</a
>. Sound like fun, but I had more money than time to spend on
363 the topic, so I suspect it will have to wait for another time.
</p
>
365 <p
>While I was working on tracking down links, I came across an
366 inspiring TED talk by Dave Debronkart about
367 <a href=
"https://archive.org/details/DavedeBronkart_2010X
">being a
368 e-patient
</a
>, and discovered the web site
369 <a href=
"https://participatorymedicine.org/epatients/
">Participatory
370 Medicine
</a
>. If you too want to track your own health and fitness
371 without having information about your private life floating around on
372 computers owned by others, I recommend checking it out.
</p
>
374 <p
>As usual, if you use Bitcoin and want to show your support of my
375 activities, please send Bitcoin donations to my address
376 <b
><a href=
"bitcoin:
15oWEoG9dUPovwmUL9KWAnYRtNJEkP1u1b
">15oWEoG9dUPovwmUL9KWAnYRtNJEkP1u1b
</a
></b
>.
</p
>
381 <title>Privacy respecting health monitor / fitness tracker?
</title>
382 <link>http://people.skolelinux.org/pere/blog/Privacy_respecting_health_monitor___fitness_tracker_.html
</link>
383 <guid isPermaLink=
"true">http://people.skolelinux.org/pere/blog/Privacy_respecting_health_monitor___fitness_tracker_.html
</guid>
384 <pubDate>Tue,
7 Aug
2018 16:
00:
00 +
0200</pubDate>
385 <description><p
>Dear lazyweb,
</p
>
387 <p
>I wonder, is there a fitness tracker / health monitor available for
388 sale today that respect the users privacy? With this I mean a
389 watch/bracelet capable of measuring pulse rate and other
390 fitness/health related values (and by all means, also the correct time
391 and location if possible), which is
<strong
>only
</strong
> provided for
392 me to extract/read from the unit with computer without a radio beacon
393 and Internet connection. In other words, it do not depend on a cell
394 phone app, and do make the measurements available via other peoples
395 computer (aka
"the cloud
"). The collected data should be available
396 using only free software. I
'm not interested in depending on some
397 non-free software that will leave me high and dry some time in the
398 future. I
've been unable to find any such unit. I would like to buy
399 it. The ones I have seen for sale here in Norway are proud to report
400 that they share my health data with strangers (aka
"cloud enabled
").
401 Is there an alternative? I
'm not interested in giving money to people
402 requiring me to accept
"privacy terms
" to allow myself to measure my
403 own health.
</p
>
405 <p
>As usual, if you use Bitcoin and want to show your support of my
406 activities, please send Bitcoin donations to my address
407 <b
><a href=
"bitcoin:
15oWEoG9dUPovwmUL9KWAnYRtNJEkP1u1b
">15oWEoG9dUPovwmUL9KWAnYRtNJEkP1u1b
</a
></b
>.
</p
>
412 <title>Sharing images with friends and family using RSS and EXIF/XMP metadata
</title>
413 <link>http://people.skolelinux.org/pere/blog/Sharing_images_with_friends_and_family_using_RSS_and_EXIF_XMP_metadata.html
</link>
414 <guid isPermaLink=
"true">http://people.skolelinux.org/pere/blog/Sharing_images_with_friends_and_family_using_RSS_and_EXIF_XMP_metadata.html
</guid>
415 <pubDate>Tue,
31 Jul
2018 23:
30:
00 +
0200</pubDate>
416 <description><p
>For a while now, I have looked for a sensible way to share images
417 with my family using a self hosted solution, as it is unacceptable to
418 place images from my personal life under the control of strangers
419 working for data hoarders like Google or Dropbox. The last few days I
420 have drafted an approach that might work out, and I would like to
421 share it with you. I would like to publish images on a server under
422 my control, and point some Internet connected display units using some
423 free and open standard to the images I published. As my primary
424 language is not limited to ASCII, I need to store metadata using
425 UTF-
8. Many years ago, I hoped to find a digital photo frame capable
426 of reading a RSS feed with image references (aka using the
427 &lt;enclosure
&gt; RSS tag), but was unable to find a current supplier
428 of such frames. In the end I gave up that approach.
</p
>
430 <p
>Some months ago, I discovered that
431 <a href=
"https://www.jwz.org/xscreensaver/
">XScreensaver
</a
> is able to
432 read images from a RSS feed, and used it to set up a screen saver on
433 my home info screen, showing images from the Daily images feed from
434 NASA. This proved to work well. More recently I discovered that
435 <a href=
"https://kodi.tv
">Kodi
</a
> (both using
436 <a href=
"https://www.openelec.tv/
">OpenELEC
</a
> and
437 <a href=
"https://libreelec.tv
">LibreELEC
</a
>) provide the
438 <a href=
"https://github.com/grinsted/script.screensaver.feedreader
">Feedreader
</a
>
439 screen saver capable of reading a RSS feed with images and news. For
440 fun, I used it this summer to test Kodi on my parents TV by hooking up
441 a Raspberry PI unit with LibreELEC, and wanted to provide them with a
442 screen saver showing selected pictures from my selection.
</p
>
444 <p
>Armed with motivation and a test photo frame, I set out to generate
445 a RSS feed for the Kodi instance. I adjusted my
<a
446 href=
"https://freedombox.org/
">Freedombox
</a
> instance, created
447 /var/www/html/privatepictures/, wrote a small Perl script to extract
448 title and description metadata from the photo files and generate the
449 RSS file. I ended up using Perl instead of python, as the
450 libimage-exiftool-perl Debian package seemed to handle the EXIF/XMP
451 tags I ended up using, while python3-exif did not. The relevant EXIF
452 tags only support ASCII, so I had to find better alternatives. XMP
453 seem to have the support I need.
</p
>
455 <p
>I am a bit unsure which EXIF/XMP tags to use, as I would like to
456 use tags that can be easily added/updated using normal free software
457 photo managing software. I ended up using the tags set using this
458 exiftool command, as these tags can also be set using digiKam:
</p
>
460 <blockquote
><pre
>
461 exiftool -headline=
'The RSS image title
' \
462 -description=
'The RSS image description.
' \
463 -subject+=for-family photo.jpeg
464 </pre
></blockquote
>
466 <p
>I initially tried the
"-title
" and
"keyword
" tags, but they were
467 invisible in digiKam, so I changed to
"-headline
" and
"-subject
". I
468 use the keyword/subject
'for-family
' to flag that the photo should be
469 shared with my family. Images with this keyword set are located and
470 copied into my Freedombox for the RSS generating script to find.
</p
>
472 <p
>Are there better ways to do this? Get in touch if you have better
473 suggestions.
</p
>
475 <p
>As usual, if you use Bitcoin and want to show your support of my
476 activities, please send Bitcoin donations to my address
477 <b
><a href=
"bitcoin:
15oWEoG9dUPovwmUL9KWAnYRtNJEkP1u1b
">15oWEoG9dUPovwmUL9KWAnYRtNJEkP1u1b
</a
></b
>.
</p
>
482 <title>Simple streaming the Linux desktop to Kodi using GStreamer and RTP
</title>
483 <link>http://people.skolelinux.org/pere/blog/Simple_streaming_the_Linux_desktop_to_Kodi_using_GStreamer_and_RTP.html
</link>
484 <guid isPermaLink=
"true">http://people.skolelinux.org/pere/blog/Simple_streaming_the_Linux_desktop_to_Kodi_using_GStreamer_and_RTP.html
</guid>
485 <pubDate>Thu,
12 Jul
2018 17:
55:
00 +
0200</pubDate>
486 <description><p
>Last night, I wrote
487 <a href=
"http://people.skolelinux.org/pere/blog/Streaming_the_Linux_desktop_to_Kodi_using_VLC_and_RTSP.html
">a
488 recipe to stream a Linux desktop using VLC to a instance of Kodi
</a
>.
489 During the day I received valuable feedback, and thanks to the
490 suggestions I have been able to rewrite the recipe into a much simpler
491 approach requiring no setup at all. It is a single script that take
492 care of it all.
</p
>
494 <p
>This new script uses GStreamer instead of VLC to capture the
495 desktop and stream it to Kodi. This fixed the video quality issue I
496 saw initially. It further removes the need to add a m3u file on the
497 Kodi machine, as it instead connects to
498 <a href=
"https://kodi.wiki/view/JSON-RPC_API/v8
">the JSON-RPC API in
499 Kodi
</a
> and simply ask Kodi to play from the stream created using
500 GStreamer. Streaming the desktop to Kodi now become trivial. Copy
501 the script below, run it with the DNS name or IP address of the kodi
502 server to stream to as the only argument, and watch your screen show
503 up on the Kodi screen. Note, it depend on multicast on the local
504 network, so if you need to stream outside the local network, the
505 script must be modified. Also note, I have no idea if audio work, as
506 I only care about the picture part.
</p
>
508 <blockquote
><pre
>
511 # Stream the Linux desktop view to Kodi. See
512 # http://people.skolelinux.org/pere/blog/Streaming_the_Linux_desktop_to_Kodi_using_VLC_and_RTSP.html
513 # for backgorund information.
515 # Make sure the stream is stopped in Kodi and the gstreamer process is
516 # killed if something go wrong (for example if curl is unable to find the
517 # kodi server). Do the same when interrupting this script.
521 params=
"$
3"
522 curl --silent --header
'Content-Type: application/json
' \
523 --data-binary
"{ \
"id\
":
1, \
"jsonrpc\
": \
"2.0\
", \
"method\
": \
"$cmd\
", \
"params\
": $params }
" \
524 "http://$host/jsonrpc
"
527 if [ -n
"$kodihost
" ] ; then
528 # Stop the playing when we end
529 playerid=$(kodicmd
"$kodihost
" Player.GetActivePlayers
"{}
" |
530 jq .result[].playerid)
531 kodicmd
"$kodihost
" Player.Stop
"{ \
"playerid\
" : $playerid }
" > /dev/null
533 if [
"$gstpid
" ]
&& kill -
0 "$gstpid
" >/dev/null
2>&1; then
534 kill
"$gstpid
"
537 trap cleanup EXIT INT
539 if [ -n
"$
1" ]; then
550 pasrc=$(pactl list | grep -A2
'Source #
' | grep
'Name: .*\.monitor$
' | \
551 cut -d
" " -f2|head -
1)
552 gst-launch-
1.0 ximagesrc use-damage=
0 ! video/x-raw,framerate=
30/
1 ! \
553 videoconvert ! queue2 ! \
554 x264enc bitrate=
8000 speed-preset=superfast tune=zerolatency qp-min=
30 \
555 key-int-max=
15 bframes=
2 ! video/x-h264,profile=high ! queue2 ! \
556 mpegtsmux alignment=
7 name=mux ! rndbuffersize max=
1316 min=
1316 ! \
557 udpsink host=$mcast port=$mcastport ttl-mc=$mcastttl auto-multicast=
1 sync=
0 \
558 pulsesrc device=$pasrc ! audioconvert ! queue2 ! avenc_aac ! queue2 ! mux. \
559 > /dev/null
2>&1 &
562 # Give stream a second to get going
565 # Ask kodi to start streaming using its JSON-RPC API
566 kodicmd
"$kodihost
" Player.Open \
567 "{\
"item\
": { \
"file\
": \
"udp://@$mcast:$mcastport\
" } }
" > /dev/null
569 # wait for gst to end
570 wait
"$gstpid
"
571 </pre
></blockquote
>
573 <p
>I hope you find the approach useful. I know I do.
</p
>
575 <p
>As usual, if you use Bitcoin and want to show your support of my
576 activities, please send Bitcoin donations to my address
577 <b
><a href=
"bitcoin:
15oWEoG9dUPovwmUL9KWAnYRtNJEkP1u1b
">15oWEoG9dUPovwmUL9KWAnYRtNJEkP1u1b
</a
></b
>.
</p
>
582 <title>Streaming the Linux desktop to Kodi using VLC and RTSP
</title>
583 <link>http://people.skolelinux.org/pere/blog/Streaming_the_Linux_desktop_to_Kodi_using_VLC_and_RTSP.html
</link>
584 <guid isPermaLink=
"true">http://people.skolelinux.org/pere/blog/Streaming_the_Linux_desktop_to_Kodi_using_VLC_and_RTSP.html
</guid>
585 <pubDate>Thu,
12 Jul
2018 02:
00:
00 +
0200</pubDate>
586 <description><p
>PS: See
587 <ahref=
"http://people.skolelinux.org/pere/blog/Simple_streaming_the_Linux_desktop_to_Kodi_using_GStreamer_and_RTP.html
">the
588 followup post
</a
> for a even better approach.
</p
>
590 <p
>A while back, I was asked by a friend how to stream the desktop to
591 my projector connected to Kodi. I sadly had to admit that I had no
592 idea, as it was a task I never had tried. Since then, I have been
593 looking for a way to do so, preferable without much extra software to
594 install on either side. Today I found a way that seem to kind of
595 work. Not great, but it is a start.
</p
>
597 <p
>I had a look at several approaches, for example
598 <a href=
"https://github.com/mfoetsch/dlna_live_streaming
">using uPnP
599 DLNA as described in
2011</a
>, but it required a uPnP server, fuse and
600 local storage enough to store the stream locally. This is not going
601 to work well for me, lacking enough free space, and it would
602 impossible for my friend to get working.
</p
>
604 <p
>Next, it occurred to me that perhaps I could use VLC to create a
605 video stream that Kodi could play. Preferably using
606 broadcast/multicast, to avoid having to change any setup on the Kodi
607 side when starting such stream. Unfortunately, the only recipe I
608 could find using multicast used the rtp protocol, and this protocol
609 seem to not be supported by Kodi.
</p
>
611 <p
>On the other hand, the rtsp protocol is working! Unfortunately I
612 have to specify the IP address of the streaming machine in both the
613 sending command and the file on the Kodi server. But it is showing my
614 desktop, and thus allow us to have a shared look on the big screen at
615 the programs I work on.
</p
>
617 <p
>I did not spend much time investigating codeces. I combined the
618 rtp and rtsp recipes from
619 <a href=
"https://wiki.videolan.org/Documentation:Streaming_HowTo/Command_Line_Examples/
">the
620 VLC Streaming HowTo/Command Line Examples
</a
>, and was able to get
621 this working on the desktop/streaming end.
</p
>
623 <blockquote
><pre
>
624 vlc screen:// --sout \
625 '#transcode{vcodec=mp4v,acodec=mpga,vb=
800,ab=
128}:rtp{dst=projector.local,port=
1234,sdp=rtsp://
192.168.11.4:
8080/test.sdp}
'
626 </pre
></blockquote
>
628 <p
>I ssh-ed into my Kodi box and created a file like this with the
629 same IP address:
</p
>
631 <blockquote
><pre
>
632 echo rtsp://
192.168.11.4:
8080/test.sdp \
633 > /storage/videos/screenstream.m3u
634 </pre
></blockquote
>
636 <p
>Note the
192.168.11.4 IP address is my desktops IP address. As far
637 as I can tell the IP must be hardcoded for this to work. In other
638 words, if someone elses machine is going to do the steaming, you have
639 to update screenstream.m3u on the Kodi machine and adjust the vlc
640 recipe. To get started, locate the file in Kodi and select the m3u
641 file while the VLC stream is running. The desktop then show up in my
642 big screen. :)
</p
>
644 <p
>When using the same technique to stream a video file with audio,
645 the audio quality is really bad. No idea if the problem is package
646 loss or bad parameters for the transcode. I do not know VLC nor Kodi
647 enough to tell.
</p
>
649 <p
><strong
>Update
2018-
07-
12</strong
>: Johannes Schauer send me a few
650 succestions and reminded me about an important step. The
"screen:
"
651 input source is only available once the vlc-plugin-access-extra
652 package is installed on Debian. Without it, you will see this error
653 message:
"VLC is unable to open the MRL
'screen://
'. Check the log
654 for details.
" He further found that it is possible to drop some parts
655 of the VLC command line to reduce the amount of hardcoded information.
656 It is also useful to consider using cvlc to avoid having the VLC
657 window in the desktop view. In sum, this give us this command line on
660 <blockquote
><pre
>
661 cvlc screen:// --sout \
662 '#transcode{vcodec=mp4v,acodec=mpga,vb=
800,ab=
128}:rtp{sdp=rtsp://:
8080/}
'
663 </pre
></blockquote
>
665 <p
>and this on the Kodi end
<p
>
667 <blockquote
><pre
>
668 echo rtsp://
192.168.11.4:
8080/ \
669 > /storage/videos/screenstream.m3u
670 </pre
></blockquote
>
672 <p
>Still bad image quality, though. But I did discover that streaming
673 a DVD using dvdsimple:///dev/dvd as the source had excellent video and
674 audio quality, so I guess the issue is in the input or transcoding
675 parts, not the rtsp part. I
've tried to change the vb and ab
676 parameters to use more bandwidth, but it did not make a
677 difference.
</p
>
679 <p
>I further received a suggestion from Einar Haraldseid to try using
680 gstreamer instead of VLC, and this proved to work great! He also
681 provided me with the trick to get Kodi to use a multicast stream as
682 its source. By using this monstrous oneliner, I can stream my desktop
683 with good video quality in reasonable framerate to the
239.255.0.1
684 multicast address on port
1234:
686 <blockquote
><pre
>
687 gst-launch-
1.0 ximagesrc use-damage=
0 ! video/x-raw,framerate=
30/
1 ! \
688 videoconvert ! queue2 ! \
689 x264enc bitrate=
8000 speed-preset=superfast tune=zerolatency qp-min=
30 \
690 key-int-max=
15 bframes=
2 ! video/x-h264,profile=high ! queue2 ! \
691 mpegtsmux alignment=
7 name=mux ! rndbuffersize max=
1316 min=
1316 ! \
692 udpsink host=
239.255.0.1 port=
1234 ttl-mc=
1 auto-multicast=
1 sync=
0 \
693 pulsesrc device=$(pactl list | grep -A2
'Source #
' | \
694 grep
'Name: .*\.monitor$
' | cut -d
" " -f2|head -
1) ! \
695 audioconvert ! queue2 ! avenc_aac ! queue2 ! mux.
696 </pre
></blockquote
>
698 <p
>and this on the Kodi end
<p
>
700 <blockquote
><pre
>
701 echo udp://@
239.255.0.1:
1234 \
702 > /storage/videos/screenstream.m3u
703 </pre
></blockquote
>
705 <p
>Note the trick to pick a valid pulseaudio source. It might not
706 pick the one you need. This approach will of course lead to trouble
707 if more than one source uses the same multicast port and address.
708 Note the ttl-mc=
1 setting, which limit the multicast packages to the
709 local network. If the value is increased, your screen will be
710 broadcasted further, one network
"hop
" for each increase (read up on
711 multicast to learn more. :)!
</p
>
713 <p
>Having cracked how to get Kodi to receive multicast streams, I
714 could use this VLC command to stream to the same multicast address.
715 The image quality is way better than the rtsp approach, but gstreamer
716 seem to be doing a better job.
</p
>
718 <blockquote
><pre
>
719 cvlc screen:// --sout
'#transcode{vcodec=mp4v,acodec=mpga,vb=
800,ab=
128}:rtp{mux=ts,dst=
239.255.0.1,port=
1234,sdp=sap}
'
720 </pre
></blockquote
>
722 <p
>As usual, if you use Bitcoin and want to show your support of my
723 activities, please send Bitcoin donations to my address
724 <b
><a href=
"bitcoin:
15oWEoG9dUPovwmUL9KWAnYRtNJEkP1u1b
">15oWEoG9dUPovwmUL9KWAnYRtNJEkP1u1b
</a
></b
>.
</p
>