使用USB摄像头远程监控

安装 motion

sudo apt-get install motion

配置motion,我们用sudo diff motion.conf /usr/share/motion/examples/motion-dist.conf命令看看我修改了那些:

25c25
< logfile /tmp/motion.log
---
> ;logfile /tmp/motion.log
28c28
< log_level 9
---
> log_level 6
68c68
<  v4l2_palette 17
---
> v4l2_palette 17
97c97
< framerate 100
---
> framerate 2
250c250
< output_pictures off
---
> output_pictures on
474c474
< stream_maxrate 100
---
> stream_maxrate 1
477c477
< stream_localhost off
---
> stream_localhost on
503c503
< webcontrol_localhost off
---
> webcontrol_localhost on

根据自己的需求,修改相应的配置。

在启动motion之前,我们还要修复个小坑。/var/lib/motion 目录是存放视频缓存的目录,我们需要改下权限:

sudo chown motion:motion /var/lib/motion

最后启动motion

sudo systemctl start motion

用浏览器访问http://192.168.31.11:8081/即可看到视频。