mjpg-streamer是一个命令行应用程序,可将JPEG帧从一个或多个输入插件复制到多个输出插件。
它可用于通过基于IP的网络将JPEG文件从网络摄像头流传输到各种类型的查看器,例如Chrome,Firefox,Cambozola,VLC,mplayer和其他能够接收MJPG流的软件。
它最初是为RAM和CPU资源非常有限的嵌入式设备编写的。之所以创建它的前身“uvc_streamer”,是因为与Linux-UVC兼容的摄像机直接产生JPEG数据,即使来自运行OpenWRT的嵌入式设备,也可以实现快速,高性能的M-JPEG流。输入模块“ input_uvc.so”从连接的网络摄像头捕获此类JPG帧。mjpg-streamer现在支持多种不同的输入设备。
- 克隆源代码
eric@eric-PC:~/Documents/linux-c$ git clone https://gitee.com/hainan89/mjpg-streamer.git
正克隆到 'mjpg-streamer'...
remote: Enumerating objects: 2902, done.
remote: Counting objects: 100% (2902/2902), done.
remote: Compressing objects: 100% (1030/1030), done.
remote: Total 2902 (delta 1844), reused 2902 (delta 1844), pack-reused 0
接收对象中: 100% (2902/2902), 3.46 MiB | 969.00 KiB/s, 完成.
处理 delta 中: 100% (1844/1844), 完成.
- 安装依赖性libjpeg8-dev、gcc、g++
eric@eric-PC:~/Documents/linux-c$ sudo apt-get install cmake libjpeg8-dev
eric@eric-PC:~/Documents/linux-c$ sudo apt-get install gcc g++
- 进入mjpg-streamer/mjpg-streamer-experimental,make
如果提示error: ‘CV_IMWRITE_JPEG_QUALITY’ was not declared in this scope,则手动添加定义
file:mjpg-streamer/mjpg-streamer-experimental/plugins/input_opencv.cpp
// eric++
#define CV_IMWRITE_JPEG_QUALITY 1
#define CV_IMWRITE_PNG_COMPRESSION 16
#define CV_IMWRITE_PXM_BINARY 32
// eric<<
eric@eric-PC:~/Documents/linux-c/mjpg-streamer/mjpg-streamer-experimental$ ls
cmake Dockerfile LICENSE Makefile mjpg_streamer.h plugins README.md start.sh utils.c www
CMakeLists.txt docker-start.sh makedeb.sh mjpg_streamer.c [email protected] postinstall.sh scripts TODO utils.h
eric@eric-PC:~/Documents/linux-c/mjpg-streamer/mjpg-streamer-experimental$
eric@eric-PC:~/Documents/linux-c/mjpg-streamer/mjpg-streamer-experimental$
eric@eric-PC:~/Documents/linux-c/mjpg-streamer/mjpg-streamer-experimental$ make
...
[100%] Linking C shared library output_udp.so
/usr/bin/cmake: /usr/local/lib/libcurl.so.4: no version information available (required by /usr/bin/cmake)
make[3]: 离开目录“/home/eric/Documents/linux-c/mjpg-streamer/mjpg-streamer-experimental/_build”
/usr/bin/cmake: /usr/local/lib/libcurl.so.4: no version information available (required by /usr/bin/cmake)
[100%] Built target output_udp
make[2]: 离开目录“/home/eric/Documents/linux-c/mjpg-streamer/mjpg-streamer-experimental/_build”
/usr/bin/cmake: /usr/local/lib/libcurl.so.4: no version information available (required by /usr/bin/cmake)
make[1]: 离开目录“/home/eric/Documents/linux-c/mjpg-streamer/mjpg-streamer-experimental/_build”
- 安装 install
eric@eric-PC:~/Documents/linux-c/mjpg-streamer/mjpg-streamer-experimental$ sudo make install
- 启动mjpeg-streamer
eric@eric-PC:~/Documents/linux-c/mjpg-streamer/mjpg-streamer-experimental$ ./start.sh
MJPG Streamer Version: git rev: 501f6362c5afddcfb41055f97ae484252c85c912
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/
o: HTTP TCP port........: 8080
o: HTTP Listen Address..: (null)
o: username:password....: disabled
o: commands.............: enabled
i: select() timeout
i: cleaning up resources allocated by input thread
- 测试:浏览器输入http://localhost:8080