安装依赖库
sudo apt-get install libjpeg8-dev
下载mjpg-streamer
wget https://codeload.github.com/jacksonliam/mjpg-streamer/zip/master
mv master mjpg-streamer-master.zip
编译mjpg-streamer
安装cmake
sudo apt-get install cmake
切换到mjpg的路径下
cd 目录/mjpg-streamer-master/mjpg-streamer-experimental
sudo make clean all
安装mjpg-streamer
sudo cp mjpg_streamer /usr/local/bin
sudo cp output_http.so input_uvc.so /usr/local/lib/
sudo cp -R www /usr/local/www
启动mjpg_streamer
方法1
LD_LIBRARY_PATH=/usr/local/lib mjpg_streamer -i "input_uvc.so" -o "output_http.so -w /usr/local/www"
方法2
LD_LIBRARY_PATH=/usr/local/lib mjpg_streamer -i "./input_uvc.so -d /dev/video0 -r 320*240 -f 12" -o " ./output_http.so –p 8090 –w /usr/local/www "
其他用法
$ mjpg_streamer --help
mjpg_streamer --help
-----------------------------------------------------------------------
Usage: mjpg_streamer
-i | --input "<input-plugin.so> [parameters]"
-o | --output "<output-plugin.so> [parameters]"
[-h | --help ]........: display this help
[-v | --version ].....: display version information
[-b | --background]...: fork to the background, daemon mode
-----------------------------------------------------------------------
Example #1:
To open an UVC webcam "/dev/video1" and stream it via HTTP:
mjpg_streamer -i "input_uvc.so -d /dev/video1" -o "output_http.so"
-----------------------------------------------------------------------
Example #2:
To open an UVC webcam and stream via HTTP port 8090:
mjpg_streamer -i "input_uvc.so" -o "output_http.so -p 8090"
-----------------------------------------------------------------------
Example #3:
To get help for a certain input plugin:
mjpg_streamer -i "input_uvc.so --help"
-----------------------------------------------------------------------
In case the modules (=plugins) can not be found:
* Set the default search path for the modules with:
export LD_LIBRARY_PATH=/path/to/plugins,
* or put the plugins into the "/lib/" or "/usr/lib" folder,
* or instead of just providing the plugin file name, use a complete
path and filename:
mjpg_streamer -i "/path/to/modules/input_uvc.so"
-----------------------------------------------------------------------
直接命令启动
➜ lib pwd
/usr/local/lib
➜ lib mjpg_streamer -i "input_uvc.so" -o "output_http.so -w /www/mjpg"
MJPG Streamer Version.: 2.0
i: Using V4L2 device.: /dev/video0
i: Desired Resolution: 640 x 480
i: Frames Per Second.: -1
i: Format............: JPEG
i: TV-Norm...........: DEFAULT
UVCIOC_CTRL_ADD - Error at Pan (relative): Inappropriate ioctl for device (25)
UVCIOC_CTRL_ADD - Error at Tilt (relative): Inappropriate ioctl for device (25)
UVCIOC_CTRL_ADD - Error at Pan Reset: Inappropriate ioctl for device (25)
UVCIOC_CTRL_ADD - Error at Tilt Reset: Inappropriate ioctl for device (25)
UVCIOC_CTRL_ADD - Error at Pan/tilt Reset: Inappropriate ioctl for device (25)
UVCIOC_CTRL_ADD - Error at Focus (absolute): Inappropriate ioctl for device (25)
UVCIOC_CTRL_MAP - Error at Pan (relative): Inappropriate ioctl for device (25)
UVCIOC_CTRL_MAP - Error at Tilt (relative): Inappropriate ioctl for device (25)
UVCIOC_CTRL_MAP - Error at Pan Reset: Inappropriate ioctl for device (25)
UVCIOC_CTRL_MAP - Error at Tilt Reset: Inappropriate ioctl for device (25)
UVCIOC_CTRL_MAP - Error at Pan/tilt Reset: Inappropriate ioctl for device (25)
UVCIOC_CTRL_MAP - Error at Focus (absolute): Inappropriate ioctl for device (25)
UVCIOC_CTRL_MAP - Error at LED1 Mode: Inappropriate ioctl for device (25)
UVCIOC_CTRL_MAP - Error at LED1 Frequency: Inappropriate ioctl for device (25)
UVCIOC_CTRL_MAP - Error at Disable video processing: Inappropriate ioctl for device (25)
UVCIOC_CTRL_MAP - Error at Raw bits per pixel: Inappropriate ioctl for device (25)
o: www-folder-path......: /www/mjpg/
o: HTTP TCP port........: 8080
o: HTTP Listen Address..: (null)
o: username:password....: disabled
o: commands.............: enabled
然后浏览器访问ip:8080
即可看到效果。
创建脚本启动
基本内容如下
#!/bin/bash
PORT="8101" #启动端口
USER="admin" # 需要修改
PASSWD="admin" # 需要修改
SIZE="320x480" # 320x240也可以
DEVICE="/dev/video0" # 摄像头设备编号
mjpg_streamer -i "/usr/local/lib/input_uvc.so -d $DEVICE -n -y -f 25 -r $SIZE" -o "/usr/local/lib/output_http.so -w /www/mjpg -p $PORT -c $USER:$PASSWD"
直接运行该脚本即可。