]> pere.pagekite.me Git - homepage.git/blobdiff - blog/data/2018-07-12-kodi-linux-desktop-vlc.txt
Generated.
[homepage.git] / blog / data / 2018-07-12-kodi-linux-desktop-vlc.txt
index 2de00dbdc281ce1157bd69dbf83f2ad86537c0a6..615843b013c816097352f4f2e4699cbdae4b67b5 100644 (file)
@@ -1,7 +1,11 @@
 Title: Streaming the Linux desktop to Kodi using VLC and RTSP
-Tags: english, debian, video
+Tags: english, debian, video, kodi
 Date: 2018-07-12 02:00
 
+<p>PS: See
+<ahref="http://people.skolelinux.org/pere/blog/Simple_streaming_the_Linux_desktop_to_Kodi_using_GStreamer_and_RTP.html">the
+followup post</a> for a even better approach.</p>
+
 <p>A while back, I was asked by a friend how to stream the desktop to
 my projector connected to Kodi.  I sadly had to admit that I had no
 idea, as it was a task I never had tried.  Since then, I have been
@@ -51,7 +55,7 @@ echo rtsp://192.168.11.4:8080/test.sdp \
 <p>Note the 192.168.11.4 IP address is my desktops IP address.  As far
 as I can tell the IP must be hardcoded for this to work.  In other
 words, if someone elses machine is going to do the steaming, you have
-to update screenstream.m4u on the Kodi machine and adjust the vlc
+to update screenstream.m3u on the Kodi machine and adjust the vlc
 recipe.  To get started, locate the file in Kodi and select the m3u
 file while the VLC stream is running.  The desktop then show up in my
 big screen. :)</p>
@@ -76,7 +80,7 @@ the source end
 cvlc screen:// --sout \
   '#transcode{vcodec=mp4v,acodec=mpga,vb=800,ab=128}:rtp{sdp=rtsp://:8080/}'
 </pre></blockquote>
-n
+
 <p>and this on the Kodi end<p>
 
 <blockquote><pre>
@@ -91,6 +95,49 @@ parts, not the rtsp part.  I've tried to change the vb and ab
 parameters to use more bandwidth, but it did not make a
 difference.</p>
 
+<p>I further received a suggestion from Einar Haraldseid to try using
+gstreamer instead of VLC, and this proved to work great!  He also
+provided me with the trick to get Kodi to use a multicast stream as
+its source.  By using this monstrous oneliner, I can stream my desktop
+with good video quality in reasonable framerate to the 239.255.0.1
+multicast address on port 1234:
+
+<blockquote><pre>
+gst-launch-1.0 ximagesrc use-damage=0 ! video/x-raw,framerate=30/1 ! \
+  videoconvert ! queue2 ! \
+  x264enc bitrate=8000 speed-preset=superfast tune=zerolatency qp-min=30 \
+  key-int-max=15 bframes=2 ! video/x-h264,profile=high ! queue2 ! \
+  mpegtsmux alignment=7 name=mux ! rndbuffersize max=1316 min=1316 ! \
+  udpsink host=239.255.0.1 port=1234 ttl-mc=1 auto-multicast=1 sync=0 \
+  pulsesrc device=$(pactl list | grep -A2 'Source #' | \
+    grep 'Name: .*\.monitor$' |  cut -d" " -f2|head -1) ! \
+  audioconvert ! queue2 ! avenc_aac ! queue2 ! mux.
+</pre></blockquote>
+
+<p>and this on the Kodi end<p>
+
+<blockquote><pre>
+echo udp://@239.255.0.1:1234 \
+  > /storage/videos/screenstream.m3u
+</pre></blockquote>
+
+<p>Note the trick to pick a valid pulseaudio source.  It might not
+pick the one you need.  This approach will of course lead to trouble
+if more than one source uses the same multicast port and address.
+Note the ttl-mc=1 setting, which limit the multicast packages to the
+local network.  If the value is increased, your screen will be
+broadcasted further, one network "hop" for each increase (read up on
+multicast to learn more. :)!</p>
+
+<p>Having cracked how to get Kodi to receive multicast streams, I
+could use this VLC command to stream to the same multicast address.
+The image quality is way better than the rtsp approach, but gstreamer
+seem to be doing a better job.</p>
+
+<blockquote><pre>
+cvlc screen:// --sout '#transcode{vcodec=mp4v,acodec=mpga,vb=800,ab=128}:rtp{mux=ts,dst=239.255.0.1,port=1234,sdp=sap}'
+</pre></blockquote>
+
 <p>As usual, if you use Bitcoin and want to show your support of my
 activities, please send Bitcoin donations to my address
 <b><a href="bitcoin:15oWEoG9dUPovwmUL9KWAnYRtNJEkP1u1b">15oWEoG9dUPovwmUL9KWAnYRtNJEkP1u1b</a></b>.</p>