{"id":623,"date":"2019-08-10T19:20:39","date_gmt":"2019-08-10T19:20:39","guid":{"rendered":"http:\/\/james-batchelor.com\/?p=623"},"modified":"2019-08-17T15:41:26","modified_gmt":"2019-08-17T15:41:26","slug":"libreelec-pi-camera-mjpeg-streaming","status":"publish","type":"post","link":"https:\/\/james-batchelor.com\/index.php\/2019\/08\/10\/libreelec-pi-camera-mjpeg-streaming\/","title":{"rendered":"LibreElec \u2013 Pi Camera Mjpeg Streaming"},"content":{"rendered":"\n<p>Following the setup of a <a href=\"https:\/\/james-batchelor.com\/index.php\/2019\/06\/29\/motioneye-cent-os-cctv-server\/\">Cent OS CCTV<\/a> server, I\u2019ve been using Raspberry Pi\u2019s as video sources. But what if there was a Raspberry Pi in perfect situ for a CCTV camera, but was already in use as a media player?<\/p>\n\n\n\n<p>A Linux system has always had the impression that it is\nversatile, so this should be an achievable task. A barrier would be how to get\nthis done with the operating system installed, in this case it is LibreElec, an\nOS with the tagline \u201cJust enough OS for Kodi\u201d. Therefore, it would be more of a\nchallenge than a usual Debian install.<\/p>\n\n\n\n<p>The team at LibreElec saw this type of thing coming, and included the Docker service as a Kodi addon to allow the curious tinkerer to add more than Kodi to a Pi.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"554\" src=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2019\/08\/le00.jpg\" alt=\"\" class=\"wp-image-627\" srcset=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2019\/08\/le00.jpg 800w, https:\/\/james-batchelor.com\/wp-content\/uploads\/2019\/08\/le00-300x208.jpg 300w, https:\/\/james-batchelor.com\/wp-content\/uploads\/2019\/08\/le00-768x532.jpg 768w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\" \/><\/figure>\n\n\n\n<p>If you have the LibreElec based Pi in the opportune\nplacement to add a camera, here is how to add Mjpeg streaming capabilities\u2026<\/p>\n\n\n\n<!--more-->\n\n\n\n<h3 class=\"wp-block-heading\">Add the Addons<\/h3>\n\n\n\n<p>Via Kodi on the screen, goto:<\/p>\n\n\n\n<pre class=\"wp-block-verse\">Addons --&gt; Install from Repositories --&gt; Services<\/pre>\n\n\n\n<p>Then install the two addons required:<\/p>\n\n\n\n<pre class=\"wp-block-verse\">RaspiTools<br>Docker<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">CLI Access<\/h3>\n\n\n\n<p>To setup Docker and its container (the Mjpeg streamer)\nrequires Command Line Interface (CLI) access to the Pi, if not already enabled\nduring setup enable it via Kodi by navigating to:<\/p>\n\n\n\n<pre class=\"wp-block-verse\">Settings --&gt; LibreElec --&gt; Services --&gt; SSH<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Mjpeg streamer<\/h3>\n\n\n\n<p>The M-Jpeg-streamer is a well-used Linux library, and have\nchosen the Open-Horizon version of a Docker image for this task.<\/p>\n\n\n\n<p>Log in to the Pi via SSH and run the following:<\/p>\n\n\n\n<pre class=\"wp-block-verse\">docker pull openhorizon\/mjpg-streamer-pi3:latest<\/pre>\n\n\n\n<p>Follow the prompts and be prepared to wait as the Docker\nimage builds.<\/p>\n\n\n\n<p>When complete, start the Docker container with:<\/p>\n\n\n\n<pre class=\"wp-block-verse\">docker run --restart=always -it -d --privileged -p 8081:8080\nopenhorizon\/mjpg-streamer-pi3 .\/mjpg_streamer -o \"output_http.so -w\n.\/www\" -i \"input_raspicam.so -x 1280 -y 720 -fps 10 -ex night\"<\/pre>\n\n\n\n<p>This code explained:<\/p>\n\n\n\n<p><strong>docker run:<\/strong> start a Docker container<br> <strong>&#8211;restart=always:<\/strong> Restarts a container if the system is restarted<br> <strong>-it:<\/strong> allocate a pseudo-TTY for debugging and to stop it.<br> <strong>-d:<\/strong> Run in background, enables CLI to exit without stopping container.<br> <strong>&#8211;privileged:<\/strong> Give privileges that allows access to the camera.<br> <strong>-p 8081:8080:<\/strong> Translate streaming port from 8080 to 8081, as not to conflict with Kodi.<br> <strong>openhorizon\/mjpg-streamer-pi3 .\/mjpg_streamer:<\/strong> name of Docker image.<br> <strong>-o &#8220;output_http.so -w .\/www&#8221;:<\/strong> internal reference.<br> <strong>-i &#8220;input_raspicam.so -x 1280 -y 720 -fps 10 -ex night&#8221;:<\/strong> Camera settings, set resolution, frames per second and Pi camera filters.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Run<\/h3>\n\n\n\n<p>The Docker container should now be running, check this by\nentering this in the CLI:<\/p>\n\n\n\n<pre class=\"wp-block-verse\">docker ps -a<\/pre>\n\n\n\n<p>To show running containers.<\/p>\n\n\n\n<p>Now you can access the web GUI by visiting <a href=\"http:\/\/ip_address:8081\">http:\/\/ip_address:8081<\/a> to test.<\/p>\n\n\n\n<p>From here it can be added as a Network Camera to MotionEye.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Configuration<\/h3>\n\n\n\n<p>During setup its important to consider the hardware it\nrunning on. This was running on a Wi-Fi only Raspberry Pi 3A+, while it\u2019s\nprocessing power was more than adequate for my initial setup of 1920&#215;1080@20fps\nthis saturated the network connection, leaving no bandwidth left to stream the\nmedia LibreElec was designed for. The reduction to 1280&#215;720@10fps reduced the\nactive bandwidth enough as not to interrupt the media players primary function.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Following the setup of a Cent OS CCTV server, I\u2019ve been using Raspberry Pi\u2019s as video sources. But what if there was a Raspberry Pi in perfect situ for a CCTV camera, but was already in use as a media player? A Linux system has always had the impression that it is versatile, so this &hellip; <a href=\"https:\/\/james-batchelor.com\/index.php\/2019\/08\/10\/libreelec-pi-camera-mjpeg-streaming\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;LibreElec \u2013 Pi Camera Mjpeg Streaming&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[212,4],"tags":[269,180,268,161,243,261,262,263,63,70],"class_list":["post-623","post","type-post","status-publish","format-standard","hentry","category-network","category-raspberry-pi","tag-addon","tag-camera","tag-docker","tag-ip-camera","tag-libreelec","tag-motioneye","tag-motioneye-os","tag-pi","tag-raspberry-pi","tag-rpi"],"_links":{"self":[{"href":"https:\/\/james-batchelor.com\/index.php\/wp-json\/wp\/v2\/posts\/623","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/james-batchelor.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/james-batchelor.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/james-batchelor.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/james-batchelor.com\/index.php\/wp-json\/wp\/v2\/comments?post=623"}],"version-history":[{"count":3,"href":"https:\/\/james-batchelor.com\/index.php\/wp-json\/wp\/v2\/posts\/623\/revisions"}],"predecessor-version":[{"id":634,"href":"https:\/\/james-batchelor.com\/index.php\/wp-json\/wp\/v2\/posts\/623\/revisions\/634"}],"wp:attachment":[{"href":"https:\/\/james-batchelor.com\/index.php\/wp-json\/wp\/v2\/media?parent=623"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/james-batchelor.com\/index.php\/wp-json\/wp\/v2\/categories?post=623"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/james-batchelor.com\/index.php\/wp-json\/wp\/v2\/tags?post=623"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}