{"id":12,"date":"2014-10-31T01:57:58","date_gmt":"2014-10-30T17:57:58","guid":{"rendered":"http:\/\/blog.haostudio.net\/hwp\/?p=12"},"modified":"2017-07-25T00:26:00","modified_gmt":"2017-07-24T16:26:00","slug":"12","status":"publish","type":"post","link":"https:\/\/blog.haostudio.net\/hwp\/12\/","title":{"rendered":"CubieBoard \u4e0a\u5b89\u88ddMJPG-Streamer \u8a18\u9304"},"content":{"rendered":"<!--more-->\n<h2>CubieBoard \u4e0a\u5b89\u88ddMJPG-Streamer \u8a18\u9304<\/h2>\n<h1>\u74b0\u5883\u6e96\u5099 (Login as root)<\/h1>\n<p>\u5b89\u88dd\u958b\u767c\u5de5\u5177<\/p>\n<pre><code>apt-get install gcc autoconf make\n<\/code><\/pre>\n<p>\u5b89\u88dd\u5fc5\u8981\u5957\u4ef6<\/p>\n<pre><code>apt-get install subversion libjpeg8-dev imagemagick\n<\/code><\/pre>\n<p>\u5b89\u88dd\u5176\u4ed6\u5957\u4ef6(\u975e\u5fc5\u8981), such as lsusb<\/p>\n<pre><code>apt-get install usbutils\n<\/code><\/pre>\n<h1>\u7de8\u8b6f MJPG-Streamer<\/h1>\n<p>\u4e0b\u8f09MJPG-Streamer souce code<\/p>\n<pre><code> cd ~\n svn checkout http:\/\/svn.code.sf.net\/p\/mjpg-streamer\/code\/ mjpg-streamer-code\n cd ~\/mjpg-streamer-code\/mjpg-streamer\n make\n 1.  1. Assume you want to install the mjpg-streamer in \/mjpg-streamer directory\n 1.  mkdir -p \/mjpg-streamer\/bin\n mkdir -p \/mjpg-streamer\/lib\n mkdir -p \/mjpg-streamer\/www\n make DESTDIR=\/mjpg-streamer install\n<\/code><\/pre>\n<h1>\u6e2c\u8a66<\/h1>\n<p>\u63d2\u5165\u652f\u63f4UVC \u7684USB webcam, \u4f7f\u7528lsusb \u67e5\u770b\u88dd\u7f6e<\/p>\n<pre><code>root@bsms:~\/# lsusb\nBus 004 Device 002: ID 045e:0779 Microsoft Corp. \nBus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub\nBus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub\nBus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub\nBus 004 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub\nBus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub\n<\/code><\/pre>\n<p>\u5176\u4e2d\n<em>Bus 004 Device 002: ID 045e:0779 Microsoft Corp<\/em> \u5373\u662f\u6211\u7684USB webcam.<\/p>\n<p>\u800c\u4e14\u5728\/dev \u76ee\u9304\u4e0b, \u61c9\u8a72\u6703\u7522\u751f\u4e00\u500bvideo0 \u7684\u88dd\u7f6e<\/p>\n<pre><code>root@bsms:~\/# ls -al \/dev\/video?\ncrw-rw---T 1 root video 81, 0 10\u6708 21 13:02 \/dev\/video0\n<\/code><\/pre>\n<p>\u57f7\u884cmjpg-streamer<\/p>\n<pre><code>\/mjpg-streamer\/bin\/mjpg_streamer -i &quot;\/mjpg-streamer\/lib\/input_uvc.so&quot; -o &quot;\/mjpg-streamer\/lib\/output_http.so -w \/mjpg-streamer\/www&quot;\n<\/code><\/pre>\n<p>\u7136\u5f8c\u4f7f\u7528Browser \u9023\u63a5\n<em><a href=\"http:\/\/your&#095;cubieboar&#095;ip:8080\">http:\/\/your&#095;cubieboar&#095;ip:8080<\/a><\/em> \u5373\u53ef\u770b\u5230\u756b\u9762<\/p>\n<p>\u8a73\u7d30\u57f7\u884c\u6307\u4ee4\u53c3\u6578\u53ef\u4ee5\u53c3\u8003source code \u76ee\u9304\u4e2d start.sh<\/p>\n<pre><code>less ~\/mjpg-streamer-code\/mjpg-streamer\/start.sh\n<\/code><\/pre>\n<h1>\u958b\u6a5f\u81ea\u52d5\u57f7\u884c<\/h1>\n<p>\u5efa\u7acbscript setting file<br \/>\n<em>\/etc\/default\/mjpg-streamer<\/em><\/p>\n<pre><code>root@bsms:~\/# vi \/etc\/default\/mjpg-streamer\n\n1. Configuration for \/etc\/init.d\/mjpg-streamer\n\n1. The init.d script will only run if this variable non-empty.\nMJPG_STREAMER_USER=&quot;root&quot;\n\n1. Where mjpg-streamer is installed, this is important!\nDAEMON_HOME=\/mjpg-streamer\nDAEMON_EXEC_DIR=$DAEMON_HOME\/bin\nDAEMON_LIB_DIR=$DAEMON_HOME\/lib\nDAEMON_WEB_DIR=$DAEMON_HOME\/www\n\n1. What arguments to pass to mjpg-streamer, here is few examples; You can change them by commenting one and\n1. uncommenting another:\n\nDAEMON_I_ARGS=&quot;$DAEMON_LIB_DIR\/input_uvc.so -r 1280x720 -f 15&quot;   # UVC-mode\n#DAEMON_I_ARGS=&quot;$DAEMON_LIB_DIR\/input_uvc.so -y -r 1280x720 -f 15&quot;  # YUV-mode\n\nDAEMON_O_ARGS=&quot;$DAEMON_LIB_DIR\/output_http.so -w $DAEMON_WEB_DIR -c your_account:your_passowrd&quot;\n\n1. Umask of files mjpg-streamer generates, Change this to 000 if running mjpg-streamer as its own, separate user\nUMASK=022\n\n1. Should we run at startup?\nRUN_AT_STARTUP=&quot;YES&quot;\n<\/code><\/pre>\n<p>\u5c07\u6a94\u6848\u4e2d\u7684\n<em>your&#095;account:your&#095;password<\/em> \u6539\u6210\u4f60\u60f3\u8981\u7684\u5e33\u5bc6<\/p>\n<p>\u4e26\u4e14\u4fee\u6539\u6a94\u6848\u5c6c\u6027\u70ba600<\/p>\n<pre><code>root@bsms:~\/# chmod 600 \/etc\/default\/mjpg-streamer\n<\/code><\/pre>\n<p>\u5efa\u7acbinit script file<br \/>\n<em>\/etc\/init.d\/mjpg-streamer<\/em><\/p>\n<pre><code>root@bsms:~\/# vi \/etc\/init.d\/mjpg-streamer\n\n#!\/bin\/sh\n### BEGIN INIT INFO\n1. Provides:          mjpg-streamer\n1. Required-Start:    $local_fs networking\n1. Required-Stop:\n1. Should-Start:\n1. Should-Stop:\n1. Default-Start:     2 3 4 5\n1. Default-Stop:      0 1 6\n1. Short-Description: mjpg-streamer daemon\n1. Description:       Starts the mjpg-streamer daemon with the user specified in\n1.                    \/etc\/default\/mjpg-streamer.\n### END INIT INFO\n\n1. Author: Sami Olmari\n1. Modified: Hao Tseng\n\nPATH=\/usr\/local\/sbin:\/usr\/local\/bin:\/sbin:\/bin:\/usr\/sbin:\/usr\/bin\nDESC=&quot;mjpg-streamer Daemon&quot;\nNAME=&quot;mjpg-streamer&quot;\nDAEMON=mjpg_streamer\nPIDFILE=\/var\/run\/${NAME}.pid\nPKGNAME=mjpg-streamer\nSCRIPTNAME=\/etc\/init.d\/$PKGNAME\n\n1. Read configuration variable file if it is present\n[ -r \/etc\/default\/$PKGNAME ] &amp;&amp; . \/etc\/default\/$PKGNAME\n\n1. Exit if the mjpg-streamer is not installed\n[ -x &quot;$DAEMON_EXEC_DIR\/$DAEMON&quot; ] || exit 0\n\n1. Load the VERBOSE setting and other rcS variables\n[ -f \/etc\/default\/rcS ] &amp;&amp; . \/etc\/default\/rcS\n\n1. Define LSB log_* functions.\n1. Depend on lsb-base (&gt;= 3.0-6) to ensure that this file is present.\n. \/lib\/lsb\/init-functions\n\nif [ -z &quot;$RUN_AT_STARTUP&quot; -o &quot;$RUN_AT_STARTUP&quot; != &quot;YES&quot; ]; then\n   log_warning_msg &quot;Not starting $PKGNAME, edit \/etc\/default\/$PKGNAME to start it.&quot;\n   exit 0\nfi\n\nif [ -z &quot;$MJPG_STREAMER_USER&quot; ]; then\n\n    log_warning_msg &quot;Not starting $PKGNAME, MJPG_STREAMER_USER not set in \/etc\/default\/$PKGNAME.&quot;\n    exit 0\nfi\n\n1. 1. Function to verify if a pid is alive\n1. is_alive()\n{\n   pid=`cat $1` &gt; \/dev\/null 2&gt;&amp;1\n   kill -0 $pid &gt; \/dev\/null 2&gt;&amp;1\n   return $?\n}\n\n1. 1. Function that starts the daemon\/service\n1. do_start()\n{\n   1. Return\n   1.   0 if daemon has been started\n   1.   1 if daemon was already running\n   1.   2 if daemon could not be started\n\n   is_alive $PIDFILE\n   RETVAL=&quot;$?&quot;\n\n   if [ $RETVAL != 0 ]; then\n       start-stop-daemon --start --background --quiet --pidfile $PIDFILE --make-pidfile \\\n       --exec $DAEMON_EXEC_DIR\/$DAEMON --chuid $MJPG_STREAMER_USER --user $MJPG_STREAMER_USER --umask $UMASK -- -i &quot;$DAEMON_I_ARGS&quot; -o &quot;$DAEMON_O_ARGS&quot; \n       RETVAL=&quot;$?&quot;\n   fi\n}\n\n1. 1. Function that stops the daemon\/service\n1. do_stop()\n{\n   1. Return\n   1.   0 if daemon has been stopped\n   1.   1 if daemon was already stopped\n   1.   2 if daemon could not be stopped\n   1.   other if a failure occurred\n\n   start-stop-daemon --stop --quiet --retry=TERM\/30\/KILL\/5 --user $MJPG_STREAMER_USER --pidfile $PIDFILE\n   RETVAL=&quot;$?&quot;\n   [ &quot;$RETVAL&quot; = &quot;2&quot; ] &amp;&amp; return 2\n\n   rm -f $PIDFILE\n\n   [ &quot;$RETVAL&quot; = &quot;0&quot;  ] &amp;&amp; return 0 || return 1\n}\n\ncase &quot;$1&quot; in\n  start)\n   [ &quot;$VERBOSE&quot; != no ] &amp;&amp; log_daemon_msg &quot;Starting $DESC&quot; &quot;$NAME&quot;\n   do_start\n   case &quot;$?&quot; in\n      0|1) [ &quot;$VERBOSE&quot; != no ] &amp;&amp; log_end_msg 0 ;;\n      2) [ &quot;$VERBOSE&quot; != no ] &amp;&amp; log_end_msg 1 ;;\n   esac\n   ;;\n  stop)\n   [ &quot;$VERBOSE&quot; != no ] &amp;&amp; log_daemon_msg &quot;Stopping $DESC&quot; &quot;$NAME&quot;\n   do_stop\n   case &quot;$?&quot; in\n      0|1) [ &quot;$VERBOSE&quot; != no ] &amp;&amp; log_end_msg 0 ;;\n      2) [ &quot;$VERBOSE&quot; != no ] &amp;&amp; log_end_msg 1 ;;\n   esac\n   ;;\n  restart)\n   log_daemon_msg &quot;Restarting $DESC&quot; &quot;$NAME&quot;\n   do_stop\n   case &quot;$?&quot; in\n     0|1)\n      do_start\n      case &quot;$?&quot; in\n         0) log_end_msg 0 ;;\n         1) log_end_msg 1 ;; # Old process is still running\n         *) log_end_msg 1 ;; # Failed to start\n      esac\n      ;;\n     *)\n        1. Failed to stop\n      log_end_msg 1\n      ;;\n   esac\n   ;;\n  status)\n   status_of_proc -p ${PIDFILE} $DAEMON_EXEC_DIR\/$DAEMON $DAEMON &amp;&amp; exit 0 || exit $?;\n   ;;\n  *)\n   echo &quot;Usage: $SCRIPTNAME {start|stop|restart|status}&quot; &gt;&amp;2\n   exit 3\n   ;;\nesac\n\n:\n<\/code><\/pre>\n<p>\u4fee\u6539\u6a94\u6848\u5c6c\u6027\u70ba755<\/p>\n<pre><code>root@bsms:~\/# chmod 755 \/etc\/init.d\/mjpg-streamer\n<\/code><\/pre>\n<p>\u5c07\/etc\/init.d\/mjpg-streamer \u8a2d\u6210\u958b\u6a5f\u6642\u57f7\u884c<\/p>\n<pre><code>root@bsms:~\/# update-rc.d mjpg-streamer defaults\n<\/code><\/pre>\n<p>\u4f7f\u7528\u4e0b\u5217\u6307\u4ee4\u6e2c\u8a66<\/p>\n<pre><code>root@bsms:~\/# \/etc\/init.d\/mjpg-streamer start\n[ ok ] Starting mjpg-streamer Daemon: mjpg-streamer.\n<\/code><\/pre>\n<h3>\u5df2\u77e5\u554f\u984c<\/h3>\n<ol>\n<li>\u4e0d\u77e5\u70ba\u4f55\u6bcf\u6b21\u958b\u6a5f\u57f7\u884c\u6642, mjpg-streamer \u555f\u52d5\u5f8c, \u7db2\u9801\u9023\u7684\u9032\u53bb, \u4f46\u662f\u537b\u770b\u4e0d\u5230\u756b\u9762. \u53ea\u8981\u624b\u52d5\u95dc\u6389deamon \u518d\u555f\u52d5\u5373\u53ef. <\/li>\n<li>\u9577\u6642\u9593\u4f7f\u7528\u5f8c, \u6709\u6642camera \u756b\u9762\u6703\u51fa\u4e0d\u4f86, \u4f46\u662f\u7db2\u9801\u662fok\u7684.<\/li>\n<\/ol>\n<p>\u57fa\u65bc\u4ee5\u4e0a\u5169\u9ede, \u6240\u4ee5\u6211\u53ea\u597d\u7528crontab \u4f86\u5b9a\u6642restart \u9019\u500bdeamon.<\/p>\n<pre><code>root@bsms:~\/# crontab -l\n\n*\/10 * * * * \/etc\/init.d\/mjpg-streamer restart\n<\/code><\/pre>\n<p>\u6bcf10\u5206\u9418\u81ea\u52d5\u91cd\u8d77daemon<\/p>\n<hr \/>\n<h3>\u53c3\u8003\u8cc7\u6599:<\/h3>\n<ol>\n<li><a href=\"http:\/\/sourceforge.net\/projects\/mjpg-streamer\/\">http:\/\/sourceforge.net\/projects\/mjpg-streamer\/<\/a><\/li>\n<li><a href=\"http:\/\/gsyan888.blogspot.tw\/2013\/04\/raspberry-pi-webcam-time-lapse.html\">Raspberry PI : Webcam + MJPG-streamer \u8b8a Webcam Streamer<\/a><\/li>\n<li><a href=\"http:\/\/www.arthurtoday.com\/2014\/05\/raspberrypi-using-mjpgstreamer-monitoring-multiple-webcams.html\">Raspberry Pi \u7528 Mjpg-Streamer \u76e3\u770b\u4e8c\u53f0 WebCam<\/a><\/li>\n<li><a href=\"http:\/\/www.raspberrypi.org\/forums\/viewtopic.php?t=48597\">How To Install Mjpg-Streamer<\/a><\/li>\n<li><a href=\"https:\/\/gist.github.com\/foosel\/8185988\">MJPG-Streamer init\/default scripts by Sami Olmari<\/a><\/li>\n<li><a href=\"http:\/\/blog.roodo.com\/rocksaying\/archives\/19886844.html\">Debian 6 \u5982\u4f55\u589e\u52a0\u7cfb\u7d71\u555f\u52d5\u7a0b\u5f0f\u8207\u6307\u5b9a\u9806\u5e8f linux debian<\/a><\/li>\n<\/ol>","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,5],"tags":[6,7],"class_list":["post-12","post","type-post","status-publish","format-standard","hentry","category-linux","category-multimedia","tag-mpeg-streamer","tag-webcam"],"_links":{"self":[{"href":"https:\/\/blog.haostudio.net\/hwp\/wp-json\/wp\/v2\/posts\/12","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.haostudio.net\/hwp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.haostudio.net\/hwp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.haostudio.net\/hwp\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.haostudio.net\/hwp\/wp-json\/wp\/v2\/comments?post=12"}],"version-history":[{"count":5,"href":"https:\/\/blog.haostudio.net\/hwp\/wp-json\/wp\/v2\/posts\/12\/revisions"}],"predecessor-version":[{"id":424,"href":"https:\/\/blog.haostudio.net\/hwp\/wp-json\/wp\/v2\/posts\/12\/revisions\/424"}],"wp:attachment":[{"href":"https:\/\/blog.haostudio.net\/hwp\/wp-json\/wp\/v2\/media?parent=12"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.haostudio.net\/hwp\/wp-json\/wp\/v2\/categories?post=12"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.haostudio.net\/hwp\/wp-json\/wp\/v2\/tags?post=12"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}