{"id":14,"date":"2019-01-18T18:11:37","date_gmt":"2019-01-18T18:11:37","guid":{"rendered":"https:\/\/oshablue.com\/bsides\/?p=14"},"modified":"2019-01-27T01:27:50","modified_gmt":"2019-01-27T01:27:50","slug":"motion-setup-for-two-2-usb-cameras-on-linux-super-quick-and-simple-basics-rapid-testing-sketch","status":"publish","type":"post","link":"https:\/\/oshablue.com\/doc\/motion-setup-for-two-2-usb-cameras-on-linux-super-quick-and-simple-basics-rapid-testing-sketch\/","title":{"rendered":"Motion Setup for Two (2) USB Cameras on Linux &#8211; Super Quick and Simple Basics &#8211; Rapid Testing Sketch"},"content":{"rendered":"\n<pre class=\"wp-block-code\"><code>sudo apt-get install motion<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo nano \/etc\/motion\/motion.conf<\/code><\/pre>\n\n\n\n<p><tt>ctrl-v<\/tt> until you get to the end of the file and uncomment the first two threads for the file locations for the configs files for the 2 cams (thread1 and thread2)<\/p>\n\n\n\n<p>create the corresponding two files both in the same \/etc\/motion\/ directory:  <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo touch thread1.conf &amp;&amp; sudo nano thread1.conf<\/code><\/pre>\n\n\n\n<p>and do the same for thread2.conf.  The contents are as follows:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#thread1.conf:\nvideodevice \/dev\/video0\ntarget_dir \/user\/me\/video0files\nstream_port 8081 # may be optional - seems necessary for reliability<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>#thread2.conf:\nvideodevice \/dev\/video1\ntarget_dir \/user\/me\/video1files\nstream_port 8082 # may be optional - seems necessary for reliability<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo motion # double-check the need for sudo there ...<\/code><\/pre>\n\n\n\n<p>view the output (via VNC in this case) at:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">localhost:8080 # the control interface for motion, including the option to action=&gt;restart<br><br>localhost:8081 # the video feed from video0 \/ thread1<br><br>localhost:8082 # the video feed from video1 \/ thread2<\/pre>\n\n\n\n<p>To allow access from a non-localhost different computer, for the web control interface and the video streams, respectively, set:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">webcontrol_localhost off<br>stream_localhost off<\/pre>\n\n\n\n<p>CAUTION: Be sure you really want this access allowed from a non-localhost computer.  You may want to look into authentication from here to allow access from another PC, and\/or you may want to configure firewalls and\/or VLANs to restrict access to the control and video streams.<\/p>\n\n\n\n<p>After making config changes, it seems so far most reliable, as one simple UI option, to select <tt>action =&gt; restart<\/tt> from the web control interface.<\/p>\n\n\n\n<p>This relies on the defaults, assumes your cameras are compatible with Linux\/motion default settings, assumes that your two cameras enumerate as video0 and video1, and was tested on a headless Intel iNUC (circa 2016) running Ubuntu 16.04.5 LTS or thereabouts (which is old, and retained for legacy comms project compatibility and reference).  Motion version is 3.2.12<\/p>\n\n\n\n<p>For an older slower headless fanless mini-ITX system, running 3 cameras required using a kernel driver documented &#8220;hack&#8221; (really just a setting &#8212; see the uvcvideo documentation) and\/or rebuilding the driver to mod bandwidth output data to guarantee 3 cameras continuous running when bandwidth data wasn&#8217;t correct, and or something like that &#8230; a while ago &#8230; haven&#8217;t tested on this iNUC platform.<\/p>\n\n\n\n<p>Update: For Motion on Ubuntu 18.04.1 (and what a nice rev I must say) the mutiple camera\/thread naming convention has been updated to:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">camera \/etc\/motion\/camera1.conf<br><br>camera \/etc\/motion\/camera2.conf<\/pre>\n\n\n\n<p>instead of the former:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">thread yada yada # (the filename itself doesn't matter, but the directive is different)<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">References<\/h2>\n\n\n\n<p><a href=\"https:\/\/motion-project.github.io\/motion_config.html\">https:\/\/motion-project.github.io\/motion_config.html<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>ctrl-v until you get to the end of the file and uncomment the first two threads for the file locations for the configs files for the 2 cams (thread1 and thread2) create the corresponding two files both in the same \/etc\/motion\/ directory: and do the same for thread2.conf. The contents are as follows: view the &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/oshablue.com\/doc\/motion-setup-for-two-2-usb-cameras-on-linux-super-quick-and-simple-basics-rapid-testing-sketch\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Motion Setup for Two (2) USB Cameras on Linux &#8211; Super Quick and Simple Basics &#8211; Rapid Testing Sketch&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[6,4,7,5],"tags":[],"class_list":["post-14","post","type-post","status-publish","format-standard","hentry","category-cameras","category-linux","category-motion","category-security","entry"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/oshablue.com\/doc\/wp-json\/wp\/v2\/posts\/14","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/oshablue.com\/doc\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/oshablue.com\/doc\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/oshablue.com\/doc\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/oshablue.com\/doc\/wp-json\/wp\/v2\/comments?post=14"}],"version-history":[{"count":5,"href":"https:\/\/oshablue.com\/doc\/wp-json\/wp\/v2\/posts\/14\/revisions"}],"predecessor-version":[{"id":39,"href":"https:\/\/oshablue.com\/doc\/wp-json\/wp\/v2\/posts\/14\/revisions\/39"}],"wp:attachment":[{"href":"https:\/\/oshablue.com\/doc\/wp-json\/wp\/v2\/media?parent=14"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/oshablue.com\/doc\/wp-json\/wp\/v2\/categories?post=14"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/oshablue.com\/doc\/wp-json\/wp\/v2\/tags?post=14"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}