]> pere.pagekite.me Git - homepage.git/blob - blog/archive/2018/07/07.rss
Typo.
[homepage.git] / blog / archive / 2018 / 07 / 07.rss
1 <?xml version="1.0" encoding="ISO-8859-1"?>
2 <rss version='2.0' xmlns:lj='http://www.livejournal.org/rss/lj/1.0/'>
3 <channel>
4 <title>Petter Reinholdtsen - Entries from July 2018</title>
5 <description>Entries from July 2018</description>
6 <link>http://people.skolelinux.org/pere/blog/</link>
7
8
9 <item>
10 <title>Streaming the Linux desktop to Kodi using VLC and RTSP</title>
11 <link>http://people.skolelinux.org/pere/blog/Streaming_the_Linux_desktop_to_Kodi_using_VLC_and_RTSP.html</link>
12 <guid isPermaLink="true">http://people.skolelinux.org/pere/blog/Streaming_the_Linux_desktop_to_Kodi_using_VLC_and_RTSP.html</guid>
13 <pubDate>Thu, 12 Jul 2018 02:00:00 +0200</pubDate>
14 <description>&lt;p&gt;A while back, I was asked by a friend how to stream the desktop to
15 my projector connected to Kodi. I sadly had to admit that I had no
16 idea, as it was a task I never had tried. Since then, I have been
17 looking for a way to do so, preferable without much extra software to
18 install on either side. Today I found a way that seem to kind of
19 work. Not great, but it is a start.&lt;/p&gt;
20
21 &lt;p&gt;I had a look at several approaches, for example
22 &lt;a href=&quot;https://github.com/mfoetsch/dlna_live_streaming&quot;&gt;using uPnP
23 DLNA as described in 2011&lt;/a&gt;, but it required a uPnP server, fuse and
24 local storage enough to store the stream locally. This is not going
25 to work well for me, lacking enough free space, and it would
26 impossible for my friend to get working.&lt;/p&gt;
27
28 &lt;p&gt;Next, it occurred to me that perhaps I could use VLC to create a
29 video stream that Kodi could play. Preferably using
30 broadcast/multicast, to avoid having to change any setup on the Kodi
31 side when starting such stream. Unfortunately, the only recipe I
32 could find using multicast used the rtp protocol, and this protocol
33 seem to not be supported by Kodi.&lt;/p&gt;
34
35 &lt;p&gt;On the other hand, the rtsp protocol is working! Unfortunately I
36 have to specify the IP address of the streaming machine in both the
37 sending command and the file on the Kodi server. But it is showing my
38 desktop, and thus allow us to have a shared look on the big screen at
39 the programs I work on.&lt;/p&gt;
40
41 &lt;p&gt;I did not spend much time investigating codeces. I combined the
42 rtp and rtsp recipes from
43 &lt;a href=&quot;https://wiki.videolan.org/Documentation:Streaming_HowTo/Command_Line_Examples/&quot;&gt;the
44 VLC Streaming HowTo/Command Line Examples&lt;/a&gt;, and was able to get
45 this working on the desktop/streaming end.&lt;/p&gt;
46
47 &lt;blockquote&gt;&lt;pre&gt;
48 vlc screen:// --sout \
49 &#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;
50 &lt;/pre&gt;&lt;/blockquote&gt;
51
52 &lt;p&gt;I ssh-ed into my Kodi box and created a file like this with the
53 same IP address:&lt;/p&gt;
54
55 &lt;blockquote&gt;&lt;pre&gt;
56 echo rtsp://192.168.11.4:8080/test.sdp \
57 &gt; /storage/videos/screenstream.m3u
58 &lt;/pre&gt;&lt;/blockquote&gt;
59
60 &lt;p&gt;Note the 192.168.11.4 IP address is my desktops IP address. As far
61 as I can tell the IP must be hardcoded for this to work. In other
62 words, if someone elses machine is going to do the steaming, you have
63 to update screenstream.m4u on the Kodi machine and adjust the vlc
64 recipe. To get started, locate the file in Kodi and select the m3u
65 file while the VLC stream is running. The desktop then show up in my
66 big screen. :)&lt;/p&gt;
67
68 &lt;p&gt;When using the same technique to stream a video file with audio,
69 the audio quality is really bad. No idea if the problem is package
70 loss or bad parameters for the transcode. I do not know VLC nor Kodi
71 enough to tell.&lt;/p&gt;
72
73 &lt;p&gt;&lt;strong&gt;Update 2018-07-12&lt;/strong&gt;: Johannes Schauer send me a few
74 succestions and reminded me about an important step. The &quot;screen:&quot;
75 input source is only available once the vlc-plugin-access-extra
76 package is installed on Debian. Without it, you will see this error
77 message: &quot;VLC is unable to open the MRL &#39;screen://&#39;. Check the log
78 for details.&quot; He further found that it is possible to drop some parts
79 of the VLC command line to reduce the amount of hardcoded information.
80 It is also useful to consider using cvlc to avoid having the VLC
81 window in the desktop view. In sum, this give us this command line on
82 the source end
83
84 &lt;blockquote&gt;&lt;pre&gt;
85 cvlc screen:// --sout \
86 &#39;#transcode{vcodec=mp4v,acodec=mpga,vb=800,ab=128}:rtp{sdp=rtsp://:8080/}&#39;
87 &lt;/pre&gt;&lt;/blockquote&gt;
88
89 &lt;p&gt;and this on the Kodi end&lt;p&gt;
90
91 &lt;blockquote&gt;&lt;pre&gt;
92 echo rtsp://192.168.11.4:8080/ \
93 &gt; /storage/videos/screenstream.m3u
94 &lt;/pre&gt;&lt;/blockquote&gt;
95
96 &lt;p&gt;Still bad image quality, though. But I did discover that streaming
97 a DVD using dvdsimple:///dev/dvd as the source had excellent video and
98 audio quality, so I guess the issue is in the input or transcoding
99 parts, not the rtsp part. I&#39;ve tried to change the vb and ab
100 parameters to use more bandwidth, but it did not make a
101 difference.&lt;/p&gt;
102
103 &lt;p&gt;I further received a suggestion from Einar Haraldseid to try using
104 gstreamer instead of VLC, and this proved to work great! He also
105 provided me with the trick to get Kodi to use a multicast stream as
106 its source. By using this monstrous oneliner, I can stream my desktop
107 with good video quality in reasonable framerate to the 239.255.0.1
108 multicast address on port 1234:
109
110 &lt;blockquote&gt;&lt;pre&gt;
111 gst-launch-1.0 ximagesrc use-damage=0 ! video/x-raw,framerate=30/1 ! \
112 videoconvert ! queue2 ! \
113 x264enc bitrate=8000 speed-preset=superfast tune=zerolatency qp-min=30 \
114 key-int-max=15 bframes=2 ! video/x-h264,profile=high ! queue2 ! \
115 mpegtsmux alignment=7 name=mux ! rndbuffersize max=1316 min=1316 ! \
116 udpsink host=239.255.0.1 port=1234 ttl-mc=0 auto-multicast=1 sync=0 \
117 pulsesrc device=$(pactl list | grep -A2 &#39;Source #&#39; | \
118 grep &#39;Name: .*\.monitor$&#39; | cut -d&quot; &quot; -f2|head -1) ! \
119 audioconvert ! queue2 ! avenc_aac ! queue2 ! mux.
120 &lt;/pre&gt;&lt;/blockquote&gt;
121
122 &lt;p&gt;and this on the Kodi end&lt;p&gt;
123
124 &lt;blockquote&gt;&lt;pre&gt;
125 echo udp://@239.255.0.1:1234 \
126 &gt; /storage/videos/screenstream.m3u
127 &lt;/pre&gt;&lt;/blockquote&gt;
128
129 &lt;p&gt;Note the trick to pick a valid pulseaudio source. It might not
130 pick the one you need. This approach will of course lead to trouble
131 if more than one source uses the same multicast port and address.
132 Note the ttl-mc=0 setting, which limit the multicast packages to the
133 local network. If the value is increased, your screen will be
134 broadcasted further, one network &quot;hop&quot; for each increase (read up on
135 multicast to learn more. :)!&lt;/p&gt;
136
137 &lt;p&gt;Having cracked how to get Kodi to receive multicast streams, I
138 could use this VLC command to stream to the same multicast address.
139 The image quality is way better than the rtsp approach.&lt;/p&gt;
140
141 &lt;blockquote&gt;&lt;pre&gt;
142 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;
143 &lt;/pre&gt;&lt;/blockquote&gt;
144
145 &lt;p&gt;As usual, if you use Bitcoin and want to show your support of my
146 activities, please send Bitcoin donations to my address
147 &lt;b&gt;&lt;a href=&quot;bitcoin:15oWEoG9dUPovwmUL9KWAnYRtNJEkP1u1b&quot;&gt;15oWEoG9dUPovwmUL9KWAnYRtNJEkP1u1b&lt;/a&gt;&lt;/b&gt;.&lt;/p&gt;
148 </description>
149 </item>
150
151 <item>
152 <title>What is the most supported MIME type in Debian in 2018?</title>
153 <link>http://people.skolelinux.org/pere/blog/What_is_the_most_supported_MIME_type_in_Debian_in_2018_.html</link>
154 <guid isPermaLink="true">http://people.skolelinux.org/pere/blog/What_is_the_most_supported_MIME_type_in_Debian_in_2018_.html</guid>
155 <pubDate>Mon, 9 Jul 2018 08:05:00 +0200</pubDate>
156 <description>&lt;p&gt;Five years ago,
157 &lt;a href=&quot;http://people.skolelinux.org/pere/blog/What_is_the_most_supported_MIME_type_in_Debian_.html&quot;&gt;I
158 measured what the most supported MIME type in Debian was&lt;/a&gt;, by
159 analysing the desktop files in all packages in the archive. Since
160 then, the DEP-11 AppStream system has been put into production, making
161 the task a lot easier. This made me want to repeat the measurement,
162 to see how much things changed. Here are the new numbers, for
163 unstable only this time:
164
165 &lt;p&gt;&lt;strong&gt;Debian Unstable:&lt;/strong&gt;&lt;/p&gt;
166
167 &lt;pre&gt;
168 count MIME type
169 ----- -----------------------
170 56 image/jpeg
171 55 image/png
172 49 image/tiff
173 48 image/gif
174 39 image/bmp
175 38 text/plain
176 37 audio/mpeg
177 34 application/ogg
178 33 audio/x-flac
179 32 audio/x-mp3
180 30 audio/x-wav
181 30 audio/x-vorbis+ogg
182 29 image/x-portable-pixmap
183 27 inode/directory
184 27 image/x-portable-bitmap
185 27 audio/x-mpeg
186 26 application/x-ogg
187 25 audio/x-mpegurl
188 25 audio/ogg
189 24 text/html
190 &lt;/pre&gt;
191
192 &lt;p&gt;The list was created like this using a sid chroot: &quot;cat
193 /var/lib/apt/lists/*sid*_dep11_Components-amd64.yml.gz| zcat | awk &#39;/^
194 - \S+\/\S+$/ {print $2 }&#39; | sort | uniq -c | sort -nr | head -20&quot;&lt;/p&gt;
195
196 &lt;p&gt;It is interesting to see how image formats have passed text/plain
197 as the most announced supported MIME type. These days, thanks to the
198 AppStream system, if you run into a file format you do not know, and
199 want to figure out which packages support the format, you can find the
200 MIME type of the file using &quot;file --mime &amp;lt;filename&amp;gt;&quot;, and then
201 look up all packages announcing support for this format in their
202 AppStream metadata (XML or .desktop file) using &quot;appstreamcli
203 what-provides mimetype &amp;lt;mime-type&amp;gt;. For example if you, like
204 me, want to know which packages support inode/directory, you can get a
205 list like this:&lt;/p&gt;
206
207 &lt;p&gt;&lt;blockquote&gt;&lt;pre&gt;
208 % appstreamcli what-provides mimetype inode/directory | grep Package: | sort
209 Package: anjuta
210 Package: audacious
211 Package: baobab
212 Package: cervisia
213 Package: chirp
214 Package: dolphin
215 Package: doublecmd-common
216 Package: easytag
217 Package: enlightenment
218 Package: ephoto
219 Package: filelight
220 Package: gwenview
221 Package: k4dirstat
222 Package: kaffeine
223 Package: kdesvn
224 Package: kid3
225 Package: kid3-qt
226 Package: nautilus
227 Package: nemo
228 Package: pcmanfm
229 Package: pcmanfm-qt
230 Package: qweborf
231 Package: ranger
232 Package: sirikali
233 Package: spacefm
234 Package: spacefm
235 Package: vifm
236 %
237 &lt;/pre&gt;&lt;/blockquote&gt;&lt;/p&gt;
238
239 &lt;p&gt;Using the same method, I can quickly discover that the Sketchup file
240 format is not yet supported by any package in Debian:&lt;/p&gt;
241
242 &lt;p&gt;&lt;blockquote&gt;&lt;pre&gt;
243 % appstreamcli what-provides mimetype application/vnd.sketchup.skp
244 Could not find component providing &#39;mimetype::application/vnd.sketchup.skp&#39;.
245 %
246 &lt;/pre&gt;&lt;/blockquote&gt;&lt;/p&gt;
247
248 &lt;p&gt;Yesterday I used it to figure out which packages support the STL 3D
249 format:&lt;/p&gt;
250
251 &lt;p&gt;&lt;blockquote&gt;&lt;pre&gt;
252 % appstreamcli what-provides mimetype application/sla|grep Package
253 Package: cura
254 Package: meshlab
255 Package: printrun
256 %
257 &lt;/pre&gt;&lt;/blockquote&gt;&lt;/p&gt;
258
259 &lt;p&gt;PS: A new version of Cura was uploaded to Debian yesterday.&lt;/p&gt;
260
261 &lt;p&gt;As usual, if you use Bitcoin and want to show your support of my
262 activities, please send Bitcoin donations to my address
263 &lt;b&gt;&lt;a href=&quot;bitcoin:15oWEoG9dUPovwmUL9KWAnYRtNJEkP1u1b&quot;&gt;15oWEoG9dUPovwmUL9KWAnYRtNJEkP1u1b&lt;/a&gt;&lt;/b&gt;.&lt;/p&gt;
264 </description>
265 </item>
266
267 <item>
268 <title>Debian APT upgrade without enough free space on the disk...</title>
269 <link>http://people.skolelinux.org/pere/blog/Debian_APT_upgrade_without_enough_free_space_on_the_disk___.html</link>
270 <guid isPermaLink="true">http://people.skolelinux.org/pere/blog/Debian_APT_upgrade_without_enough_free_space_on_the_disk___.html</guid>
271 <pubDate>Sun, 8 Jul 2018 12:10:00 +0200</pubDate>
272 <description>&lt;p&gt;Quite regularly, I let my Debian Sid/Unstable chroot stay untouch
273 for a while, and when I need to update it there is not enough free
274 space on the disk for apt to do a normal &#39;apt upgrade&#39;. I normally
275 would resolve the issue by doing &#39;apt install &amp;lt;somepackages&amp;gt;&#39; to
276 upgrade only some of the packages in one batch, until the amount of
277 packages to download fall below the amount of free space available.
278 Today, I had about 500 packages to upgrade, and after a while I got
279 tired of trying to install chunks of packages manually. I concluded
280 that I did not have the spare hours required to complete the task, and
281 decided to see if I could automate it. I came up with this small
282 script which I call &#39;apt-in-chunks&#39;:&lt;/p&gt;
283
284 &lt;p&gt;&lt;blockquote&gt;&lt;pre&gt;
285 #!/bin/sh
286 #
287 # Upgrade packages when the disk is too full to upgrade every
288 # upgradable package in one lump. Fetching packages to upgrade using
289 # apt, and then installing using dpkg, to avoid changing the package
290 # flag for manual/automatic.
291
292 set -e
293
294 ignore() {
295 if [ &quot;$1&quot; ]; then
296 grep -v &quot;$1&quot;
297 else
298 cat
299 fi
300 }
301
302 for p in $(apt list --upgradable | ignore &quot;$@&quot; |cut -d/ -f1 | grep -v &#39;^Listing...&#39;); do
303 echo &quot;Upgrading $p&quot;
304 apt clean
305 apt install --download-only -y $p
306 for f in /var/cache/apt/archives/*.deb; do
307 if [ -e &quot;$f&quot; ]; then
308 dpkg -i /var/cache/apt/archives/*.deb
309 break
310 fi
311 done
312 done
313 &lt;/pre&gt;&lt;/blockquote&gt;&lt;/p&gt;
314
315 &lt;p&gt;The script will extract the list of packages to upgrade, try to
316 download the packages needed to upgrade one package, install the
317 downloaded packages using dpkg. The idea is to upgrade packages
318 without changing the APT mark for the package (ie the one recording of
319 the package was manually requested or pulled in as a dependency). To
320 use it, simply run it as root from the command line. If it fail, try
321 &#39;apt install -f&#39; to clean up the mess and run the script again. This
322 might happen if the new packages conflict with one of the old
323 packages. dpkg is unable to remove, while apt can do this.&lt;/p&gt;
324
325 &lt;p&gt;It take one option, a package to ignore in the list of packages to
326 upgrade. The option to ignore a package is there to be able to skip
327 the packages that are simply too large to unpack. Today this was
328 &#39;ghc&#39;, but I have run into other large packages causing similar
329 problems earlier (like TeX).&lt;/p&gt;
330
331 &lt;p&gt;Update 2018-07-08: Thanks to Paul Wise, I am aware of two
332 alternative ways to handle this. The &quot;unattended-upgrades
333 --minimal-upgrade-steps&quot; option will try to calculate upgrade sets for
334 each package to upgrade, and then upgrade them in order, smallest set
335 first. It might be a better option than my above mentioned script.
336 Also, &quot;aptutude upgrade&quot; can upgrade single packages, thus avoiding
337 the need for using &quot;dpkg -i&quot; in the script above.&lt;/p&gt;
338
339 &lt;p&gt;As usual, if you use Bitcoin and want to show your support of my
340 activities, please send Bitcoin donations to my address
341 &lt;b&gt;&lt;a href=&quot;bitcoin:15oWEoG9dUPovwmUL9KWAnYRtNJEkP1u1b&quot;&gt;15oWEoG9dUPovwmUL9KWAnYRtNJEkP1u1b&lt;/a&gt;&lt;/b&gt;.&lt;/p&gt;
342 </description>
343 </item>
344
345 </channel>
346 </rss>