树莓派:配置MJPG

树莓派:配置MJPG 1、安装依赖项
sudo apt-get install libjpeg8-dev cmake
2、下载软件
#创建文件夹
cd /home/pi/Desktop
mkdir mjpg
cd mjpg
wget http://github.com/jacksonliam/mjpg-streamer/archive/master.zip
unzip master.zip
cd mjpg-streamer-master
#重名名
sudo mv mjpg-streamer-experimental mjpg
#复制至运行目录
sudo cp -r mjpg /usr/local/bin/
cd /usr/local/bin/mjpg
3、编辑配置文件
# 编辑配置文件
sudo nano plugins/input_raspicam/input_raspicam.c

#搜索fps,更改以下参数
#static int fps = 20;
#static int width = 1280;
#static int height = 960;
#static int quality = 100;
#static int usestills = 0;
#static int wantPreview = 0;
#static int wantTimestamp = 0;
#static RASPICAM_CAMERA_PARAMETERS c_params;
4、编译
sudo make clean all
5、启动摄像头
//启动普通 USB摄像头
./mjpg_streamer -i "./input_uvc.so" -o "./output_http.so -w ./www"  
//启动树莓派专用摄像头
./mjpg_streamer -i "./input_raspicam.so" -o "./output_http.so -w ./www"
//openwrt下启动,8090端口
mjpg_streamer -i "input_uvc.so -f 10 -r 320*240" -o "output_http.so -p 8090 -w www"
#多参数启动
sudo mjpg_streamer -i "./input_uvc.so -r 640x480 -f 10 -n" -o "./output_http.so -p 8080 --w ./www"
# 密码访问 userid:password 改成自己的就可以,使用一下指令测试
sudo /usr/local/bin/mjpg/mjpg_streamer -i "/usr/local/bin/mjpg/input_uvc.so -r 1280x960 -f 20 -q 100 -n" -o "/usr/local/bin/mjpg/output_http.so -p 8081 --w /usr/local/bin/mjpg/www -c jlau:jlau223223"
6、配置为Systemed自启动

添加启动文件

sudo nano /usr/lib/systemd/system/mjpg.service

输入

[Unit]
Description=mjpg
After=network.target

[Service]
#User=mjpg
ExecStart=/usr/local/bin/mjpg/mjpg_streamer -i "/usr/local/bin/mjpg/input_uvc.so -r 1280x960 -f 20 -q 100 -n" -o "/usr/local/bin/mjpg/output_http.so -p 8081 --w /usr/local/bin/mjpg/www -c jlau:jlau223223"

[Install]
WantedBy=multi-user.target
# 启动 frp 并设置开机启动,通过IP地址加端口号,即可访问
sudo systemctl enable mjpg
sudo systemctl start mjpg
sudo systemctl status mjpg
最新回复(0)
/jishuSN1k2gcPLFGDKywKR4AuJMvjaIJfOBkKPVOjrZnLSR8_3D4858124
8 简首页