Linux安装Motion
作者QQ:67065435 QQ群:669756510
本站内容全部为作者原创,转载请注明出处!
安装摄像头
- 将摄像头安装到主机上
推荐设备: 罗技:C270、C920、C922、C930e、BRIO 微软:Microsoft LifeCam全系列摄像头 双飞燕:A4Tech 夜视摄像头 其它:UVC 兼容摄像头
安装Motion
下载安装Motion
cd /root yum -y --nogpgcheck install https://download1.rpmfusion.org/free/el/rpmfusion-free-release-7.noarch.rpm yum -y --nogpgcheck install alsa-utils yum -y --nogpgcheck install v4l-utils yum -y --nogpgcheck install motion创建数据目录
useradd www usermod -a -G video www usermod -a -G audio www mkdir -p /www/motion chmod 660 /dev/video* chown -R www:video /etc/motion chown -R www:video /www/motion # 摄像头自带的麦克风所属用户组修改 chown -R www:video /dev/snd/pcmC*修改配置文件
vim /etc/motion/motion.conf # 后台运行 daemon on # 调试模式 setup_mode off # 工作目录 target_dir /www/motion # 日志配置 log_level 5 log_file /www/motion/motion.log # 侦察设置 emulate_motion off threshold 3000 threshold_tune on lightswitch_percent 10 lightswitch_frames 5 noise_level 64 despeckle_filter Ed minimum_motion_frames 3 event_gap 45 pre_capture 3 post_capture 0 # 事件设置 ; on_event_start /event_start.sh ; on_event_end /event_end.sh ; on_movie_end /movie_end.sh # 网页参数 webcontrol_port 0 webcontrol_localhost off # 流媒参数 stream_port 0 stream_localhost off # 设备细配 camera /etc/motion/camera0.conf ; camera /etc/motion/camera1.conf ; camera /etc/motion/camera2.conf ; camera /etc/motion/camera3.conf ESC :wq修改配置文件
vim /etc/motion/camera0.conf # 设备标识 camera_id 100 camera_name Camera0 # 输入设备 videodevice /dev/video0 # 输入设备(树莓派) ; mmalcam_name value ; mmalcam_control_params value # 输入设备(流媒体) ; netcam_url rtsp://<IP>:8883/path # 视频设置 width 1280 height 720 framerate 30 text_left %t text_right %Y-%m-%d\n%T-%q # 图片输出 picture_output off # 视频输出 movie_output on movie_max_time 60 movie_quality 45 movie_codec mp4 movie_passthrough off movie_filename %t-%Y%m%d%H%M%S-%v movie_bps 4000000 # 保存目录 camera_dir /www/motion ESC :wq开机启动Motion
vim /usr/lib/systemd/system/motion.service [Unit] Description=Motion监控 Documentation=Motion监控软件 [Service] User=www Group=video # 64位系统 Environment=LD_PRELOAD=/usr/lib64/libv4l/v4l2convert.so # 32位系统 #Environment=LD_PRELOAD=/usr/lib/libv4l/v4l2convert.so ExecStart=/usr/bin/motion -n ExecReload=/bin/kill -HUP $MAINPID PrivateTmp=yes [Install] WantedBy=multi-user.target ESC :wq systemctl daemon-reload systemctl enable motion systemctl start motion systemctl status motion