下载到树莓派本地:
$ wget https://github.com/jacksonliam/mjpg-streamer/archive/master.zip $ unzip master.zip # 会解压为 mjpg-streamer-master 目录
安装依赖库及C/C++项目编译工具:
sudo apt-get install libjpeg8-dev sudo apt-get install cmake
修改属性配置c文件:
$ cd mjpg-streamer-master/mjpg-streamer-experimental/plugins/input_raspicam $ sudo vim input_raspicam.c # 搜索 fps(帧率),分别将 fps = 30; width = 320; height = 240;
编译 mjpg
$ cd ../.. $ sudo make clean all
创建 mjpg 的启动脚本:
$ sudo vim pi_monitor.sh
写入如下命令:
cd ~/mjpg-streamer-master/mjpg-streamer-experimental ./mjpg_streamer -i "./input_raspicam.so" -o "./output_http.so -w ./www"
并将该脚本设置为可执行文件:
$ sudo chmod 744 pi_monitor.sh
启动启动脚本(pi_monitor.sh)
$ sh pi_monitor.sh
在浏览器地址栏打开:http://localhost:8080(localhost 替换为你树莓派的 ip)
![](https://img2024.cnblogs.com/blog/35695/202408/35695-20240826070647288-243310440.jpg)