{"id":1768,"date":"2015-07-08T21:49:34","date_gmt":"2015-07-08T20:49:34","guid":{"rendered":"https:\/\/andyland.info\/wordpress\/?p=1768"},"modified":"2018-09-16T16:06:28","modified_gmt":"2018-09-16T15:06:28","slug":"syphon-to-rtmp","status":"publish","type":"post","link":"https:\/\/andyland.info\/wordpress\/syphon-to-rtmp\/","title":{"rendered":"Syphon to RTMP"},"content":{"rendered":"<p>This idea caught me a while back and it took quite some effort to rebuild it from the leftovers a few days ago. Kids don&#8217;t forget: The only difference between noodling around and being a true specialiologist (they don&#8217;t call me &#8220;Doktor Andy&#8221; for nothing) lies in a reusable form of documentation. Fortunately I got this website. What would I do without it.<\/p>\n<p>&lt;TL; DR&gt; video from Mac to Raspberry via network&lt;\/TL; DR&gt;<\/p>\n<p>The approach uses Syphon, Open Broadcaster Software (obs), nginx and Omxplayer. I guess this ain&#8217;t too revolutionary. Using RTMP is quite a common task to distribute video. But it&#8217;s a good idea to have it all written down at least once. Furthermore I couldn&#8217;t find any kind of writeup like this covering this topic so &#8230; it&#8217;s okay.<\/p>\n<p><!--more--><\/p>\n<p>This is the setup. It consists of a MacBook running VDMX and 2 Raspberry Pies (well, and a monitor).<\/p>\n<p><a href=\"https:\/\/andyland.info\/wordpress\/wp-content\/uploads\/CIMG0616.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1770\" src=\"https:\/\/andyland.info\/wordpress\/wp-content\/uploads\/CIMG0616.jpg\" alt=\"CIMG0616\" width=\"800\" height=\"600\" srcset=\"https:\/\/andyland.info\/wordpress\/wp-content\/uploads\/CIMG0616.jpg 800w, https:\/\/andyland.info\/wordpress\/wp-content\/uploads\/CIMG0616-300x225.jpg 300w, https:\/\/andyland.info\/wordpress\/wp-content\/uploads\/CIMG0616-200x150.jpg 200w, https:\/\/andyland.info\/wordpress\/wp-content\/uploads\/CIMG0616-150x113.jpg 150w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><\/a><\/p>\n<p>Starting with the MacBook I am running VDMX and <a href=\"https:\/\/obsproject.com\/\">obs (Open Broadcaster Software)<\/a>. VDMX sends its main output via Syphon into obs. Obs, on the other hand, streams it to an RTMP server which is setup on the first of two Raspberry Pies (&#8216;vidserv&#8217;, the orange one in the upper picture). The picture below shows how everything is configured on the MacBook. VDMX&#8217;s Syphon plugin in the top left corner. Of course, any layer could be selected and sent out via Syphon. The lower right square showing something green is VDMX&#8217;s output. The &#8216;more center-left&#8217; green footage is the preview in obs and shows that it works &#8211; at least the first step.<\/p>\n<p><a href=\"https:\/\/andyland.info\/wordpress\/wp-content\/uploads\/Bildschirmfoto-2015-07-08-um-19.49.04.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-1775\" src=\"https:\/\/andyland.info\/wordpress\/wp-content\/uploads\/Bildschirmfoto-2015-07-08-um-19.49.04-1024x640.png\" alt=\"Bildschirmfoto 2015-07-08 um 19.49.04\" width=\"800\" height=\"500\" srcset=\"https:\/\/andyland.info\/wordpress\/wp-content\/uploads\/Bildschirmfoto-2015-07-08-um-19.49.04-1024x640.png 1024w, https:\/\/andyland.info\/wordpress\/wp-content\/uploads\/Bildschirmfoto-2015-07-08-um-19.49.04-300x188.png 300w, https:\/\/andyland.info\/wordpress\/wp-content\/uploads\/Bildschirmfoto-2015-07-08-um-19.49.04-240x150.png 240w, https:\/\/andyland.info\/wordpress\/wp-content\/uploads\/Bildschirmfoto-2015-07-08-um-19.49.04-150x94.png 150w, https:\/\/andyland.info\/wordpress\/wp-content\/uploads\/Bildschirmfoto-2015-07-08-um-19.49.04.png 1280w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><\/a><\/p>\n<p>This picture shows obs&#8217;s settings-dialog (German&#8230; but I think you&#8217;ll find this in other languages as well). Click to enlarge. See how I changed the stream type to &#8216;user defined streaming-server&#8217; and the URL to <strong>rtmp:\/\/vidserv\/live<\/strong>\u00a0\u00a0 . The stream&#8217;s key (which is asterisk&#8217;ed) is &#8216;<strong>test<\/strong>&#8216;. Remember that &#8216;vidserv&#8217; ist the hostname of the first raspberry receiving the video data from my MacBook.<\/p>\n<p><a href=\"https:\/\/andyland.info\/wordpress\/wp-content\/uploads\/Bildschirmfoto-2015-07-08-um-19.49.23.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-1776\" src=\"https:\/\/andyland.info\/wordpress\/wp-content\/uploads\/Bildschirmfoto-2015-07-08-um-19.49.23-1024x640.png\" alt=\"Bildschirmfoto 2015-07-08 um 19.49.23\" width=\"800\" height=\"500\" srcset=\"https:\/\/andyland.info\/wordpress\/wp-content\/uploads\/Bildschirmfoto-2015-07-08-um-19.49.23-1024x640.png 1024w, https:\/\/andyland.info\/wordpress\/wp-content\/uploads\/Bildschirmfoto-2015-07-08-um-19.49.23-300x188.png 300w, https:\/\/andyland.info\/wordpress\/wp-content\/uploads\/Bildschirmfoto-2015-07-08-um-19.49.23-240x150.png 240w, https:\/\/andyland.info\/wordpress\/wp-content\/uploads\/Bildschirmfoto-2015-07-08-um-19.49.23-150x94.png 150w, https:\/\/andyland.info\/wordpress\/wp-content\/uploads\/Bildschirmfoto-2015-07-08-um-19.49.23.png 1280w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><\/a><\/p>\n<p>In order for the first Raspberry being able to receive and process the video stream coming from the MacBook I installed a software called nginx. Though I tried a few different approaches and am not quite sure about every step I did any more (&#8230;) I am quite sure that most of the pieces of information that helped me came from the <a href=\"https:\/\/obsproject.com\/forum\/resources\/how-to-set-up-your-own-private-rtmp-server-using-nginx.50\/\">obs website<\/a> itself. I am very much of a Linux noob but got it done. So don&#8217;t worry&#8230; it IS possible.<\/p>\n<p>At one point you have to configure nginx using a config file. The <a href=\"https:\/\/obsproject.com\/forum\/resources\/how-to-set-up-your-own-private-rtmp-server-using-nginx.50\/\">obs website<\/a> states the lines below as an example. See the string I marked in bold (&#8216;live&#8217;). Guess why the URL of the streaming server is rtmp:\/\/vidserv\/<strong>live\u00a0\u00a0\u00a0\u00a0 <\/strong>.<\/p>\n<pre>rtmp {\n        server {\n                listen 1935;\n                chunk_size 4096;\n\n                application <strong>live<\/strong> {\n                        live on;\n                        record off;\n                }\n        }\n}<\/pre>\n<p>You have to have the first Raspberry (&#8216;vidserv&#8217;) up and running before you can start streaming from obs. Otherwise it will tell you.<\/p>\n<p>The second Raspberry (&#8216;vidclient&#8217;) is connected to the monitor and is running an instance of Omxplayer from the command line:\u00a0 <strong>omxplayer &#8211;live &#8211;threshold 0 rtmp:\/\/vidserv\/live\/test<\/strong>\u00a0\u00a0\u00a0 . Remember that &#8216;live&#8217; was configured in the nginx-configfile and &#8216;test&#8217; was the asterisk&#8217;ed streaming key we set within obs. See how it doesn&#8217;t work on the first try at all&#8230;<\/p>\n<p><iframe loading=\"lazy\" width=\"1333\" height=\"1000\" src=\"https:\/\/www.youtube.com\/embed\/ref0TLEXCWg?feature=oembed\" frameborder=\"0\" allow=\"autoplay; encrypted-media\" allowfullscreen><\/iframe><\/p>\n<p>Here is another video of the setup. It&#8217;s obvious that there is quite some latency involved. I guess we won&#8217;t be able to ditch our trusty ol&#8217; TripleHead2Go for now.<\/p>\n<p>[tube]https:\/\/www.youtube.com\/watch?v=Ch3n4-6b2Ms&amp;feature=youtu.be,800,600[\/tube]<\/p>\n<p>In conclusion I&#8217;d say that this setup is &#8230; not perfect. I somehow think that obs is the one to &#8216;blame&#8217; here since it&#8217;s only available in version 0.10.1 for Mac as time of this writing. Even in the 30 minutes I took to recreate this setup it had to be restarted once or twice. Far worse: it&#8217;s consuming a truckload of CPU cycles somewhere between 5% and 30%(!\u00a0 You can see the CPU load in the status bar of the software in the secod and third picture of this post) . Sometimes the Omxplayer doesn&#8217;t recognize the stream on the first try, the overall performance is far from realtime. but anyway. It&#8217;s good having this in your toolbag and in situation where all the downsides are acceptable it might come in quite handy.<\/p>\n<p>In order to make things a little bit clearer I drew a diagram about how everything is connected and about how the data travels between the computers. And there&#8217;s a little ghost. Being there and being obviously happy =)<\/p>\n<p><a href=\"https:\/\/andyland.info\/wordpress\/wp-content\/uploads\/CIMG0622.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1771\" src=\"https:\/\/andyland.info\/wordpress\/wp-content\/uploads\/CIMG0622.jpg\" alt=\"CIMG0622\" width=\"800\" height=\"600\" srcset=\"https:\/\/andyland.info\/wordpress\/wp-content\/uploads\/CIMG0622.jpg 800w, https:\/\/andyland.info\/wordpress\/wp-content\/uploads\/CIMG0622-300x225.jpg 300w, https:\/\/andyland.info\/wordpress\/wp-content\/uploads\/CIMG0622-200x150.jpg 200w, https:\/\/andyland.info\/wordpress\/wp-content\/uploads\/CIMG0622-150x113.jpg 150w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This idea caught me a while back and it took quite some effort to rebuild it from the leftovers a few days ago. Kids don&#8217;t forget: The only difference between noodling around and being a true specialiologist (they don&#8217;t call me &#8220;Doktor Andy&#8221; for nothing) lies in a reusable form \u2026 <a class=\"continue-reading-link\" href=\"https:\/\/andyland.info\/wordpress\/syphon-to-rtmp\/\"> Continue reading <span class=\"meta-nav\">&rarr; <\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_crdt_document":"","footnotes":"","_links_to":"","_links_to_target":""},"categories":[24,21],"tags":[108,59,58,107,104,62],"class_list":["post-1768","post","type-post","status-publish","format-standard","hentry","category-raspberry-pi","category-video","tag-obs","tag-omxplayer","tag-raspberry-pi-2","tag-rtmp","tag-syphon","tag-vdmx","odd"],"_links":{"self":[{"href":"https:\/\/andyland.info\/wordpress\/wp-json\/wp\/v2\/posts\/1768","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/andyland.info\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/andyland.info\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/andyland.info\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/andyland.info\/wordpress\/wp-json\/wp\/v2\/comments?post=1768"}],"version-history":[{"count":0,"href":"https:\/\/andyland.info\/wordpress\/wp-json\/wp\/v2\/posts\/1768\/revisions"}],"wp:attachment":[{"href":"https:\/\/andyland.info\/wordpress\/wp-json\/wp\/v2\/media?parent=1768"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/andyland.info\/wordpress\/wp-json\/wp\/v2\/categories?post=1768"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/andyland.info\/wordpress\/wp-json\/wp\/v2\/tags?post=1768"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}