使用 VLC 播放安全监控摄像头视频
目标
建立一个流媒体视频解决方案,方便小型场所用于广播小型活动、安全监控视频或其他用途。由于这些场所可能没有静态 IP,因此将视频流量从您的主静态 IP(在您的 openvpn 服务器上)通过隧道路由到远程场所。
概述
远程场所将需要互联网接入。他们将获得以下设备
- Minibox 风格 x86 计算机
- 显示器/键盘/鼠标
- Axis P1344 摄像头(带 POE 供电器)或 Axis Q-7401 采集盒
- 网络线缆(2 根蓝色线缆为直通线,红色为交叉线)+ 电源线
设置说明
Axis 摄像头
- 给摄像头供电。
- 连接到摄像头的 Web 界面。
- 设置管理员密码(例如 root:test123)。
- 设置 -> 视频流 -> 音频 -> 勾选启用音频复选框。
- 设置 -> 视频流 -> 图像 -> 分辨率 = 640x480。
Axis 采集盒
- 给采集盒供电。
- 连接到摄像头的 Web 界面。
- 设置管理员密码(例如 root:test123)。
- 设置 -> 视频流 -> 音频 -> 勾选启用音频复选框。
- 设置 -> 视频流 -> 图像 -> 分辨率 = 720x480。
- 启用匿名视频查看器。
Minibox
- 使用 Alpine Linux 2.4.5 设置 USB 密钥。
- 启用 apk 缓存。
- 安装以下软件包
alpine-base xscreensaver xf86-input-evdev openssh vlc rsync vim openvpn gawk bash vlc-xorg alsa-utils alsaconf alsa-lib vlc-daemon gstreamer gstreamer-tools gst-plugins-ugly gst-plugins-good gst-plugins-base chrony xf86-video-vesa linux-firmware pciutils usbutils iptables dnsmasq beep shorewall dnscache slim udev nmap tcpdump xf86-video-openchrome abiword busybox evince firefox gnumeric lxdm ristretto sudo xf86-input-keyboard xf86-input-mouse xfce4 xorg-server iftop
- /etc/network/interfaces
auto eth0 iface eth0 inet dhcp auto eth1 iface eth1 inet static address 10.14.197.1 netmask 255.255.255.224 auto lo iface lo inet loopback
- /etc/ssh/sshd_config - 禁用密码验证
- /root/.ssh/authorized_keys - 安装所有需要的密钥
- adduser jbilyk
- /etc/chrony/chrony.conf
chrony/chrony.conf # default config server time.nrc.ca initstepslew 10 time.nrc.ca commandkey 10 keyfile /etc/chrony/chrony.keys driftfile /etc/chrony/chrony.drift cmdallow 127.0.0.1 allow all
- rc-update add chronyd
- /etc/conf.d/dnscache
# DNSCACHE configuration variables: # IPSEND - ip address to use for requests use 0.0.0.0 for default route IPSEND=0.0.0.0 # CACHESIZE - Num bytes to use for the cache CACHESIZE=1000000 # IP - IP addr to listen on IP=127.0.0.1 #------------------------------------------------------------------------ # The following are flags. Setting them to ANY value # (even "false" or "off") will turn the feature on. #------------------------------------------------------------------------ # HIDETTL - always return TTL as 0 #HIDETTL= # FORWARDONLY - servers/@ are parent caches, not root servers #FORWARDONLY= # UPDATEHINTS - refresh zone hints UPDATEHINTS=1
- rc-update add dnscache
- /etc/dnsmasq.conf (根据需要替换 dhcp-host 行上的 MAC 和 IP)
domain-needed bogus-priv no-resolv no-poll server=10.14.197.1 interface=eth1 except-interface=lo bind-interfaces expand-hosts domain=example.com dhcp-authoritative cache-size=0 # dnscache does caching no-negcache log-dhcp dhcp-range=10.14.197.10,10.14.197.20,255.255.255.224,12h dhcp-option=option:ntp-server,10.14.197.1 dhcp-option=6,10.14.197.1,10.14.0.1 dhcp-option=option:domain-search,example.com dhcp-host=00:40:8c:c4:7e:99,10.14.197.5,24h # Axis Camera dhcp-option=option:ntp-server,10.14.197.1 dhcp-option=2,-18000
- rc-update add dnsmasq
- /etc/openvpn/openvpn.conf
client dev tun proto udp remote public.ip.addr.ess 1194 resolv-retry infinite nobind persist-key persist-tun ca ca.pem cert cert.pem key key.pem comp-lzo verb 3 script-security 2 up /etc/openvpn/up.sh down /etc/openvpn/down.sh
- 将您的 openvpn 证书部分提取到 /etc/openvpn/ 中
openssl pkcs12 -in %CERTPFX% -cacerts -nokeys -out ca.pem openssl pkcs12 -in %CERTPFX% -nocerts -nodes -out key.pem openssl pkcs12 -in %CERTPFX% -nokeys -clcerts -out cert.pem
- rc-update add openvpn
- /etc/resolv.conf.tail
nameserver 127.0.0.1
- /etc/conf.d/vlc
# Sample vlc params suitable for running as a daemon ## --daemon detach from prompt ## --file-logging enable file logging ## --logfile logfile name/path ## -vvv verbose logging ## -I dummy disable X11 interface ## --sout PARAMS encoding parameters ## Do NOT quote 'PARAMS' otherwise shell expansions will broke vlc VLC_OPTS="-I dummy --daemon --file-logging --logfile /var/log/vlc/vlc.log --loop --rtsp-caching=200 rtsp://10.14.197.5:554/axis-media/media.amp?videocodec=h264 --sout #standard{access=http,mux=ts,dst=0.0.0.0:8080}"
- rc-update add vlc
- /etc/shorewall/params
A_IF=tun0 B_IF=eth1 E_IF=eth0
- /etc/shorewall/interfaces
A $A_IF detect dhcp B $B_IF detect dhcp E $E_IF detect dhcp
- /etc/shorewall/policy
A all REJECT info B A ACCEPT B E ACCEPT all all REJECT info
- /etc/shorewall/rules
# FW management ACCEPT A fw tcp 22,80,443 # Manage the camera from the HQ if need be ACCEPT A B tcp 80 ACCEPT fw all icmp 8 ACCEPT fw E tcp 53,80 ACCEPT fw E udp 53,1194 ACCEPT fw B ACCEPT B fw udp 53 ACCEPT B fw tcp 53 ACCEPT A fw tcp 8080
- /etc/shorewall/zones
fw firewall A ipv4 B ipv4 E ipv4
- /etc/shorewall/shorewall.conf
STARTUP_ENABLED=Yes ... IP_FORWARDING=On
- rc-update add shorewall
- rc-update add lxdm
- home/jbilyk/.config/autostart/firefox.desktop
[Desktop Entry] Encoding=UTF-8 Version=0.9.4 Type=Application Name=firefox Comment= Exec=nice -n 5 firefox OnlyShowIn=XFCE; StartupNotify=false Terminal=false Hidden=false
- 将 FF 主页设置为 10.14.197.5(替换为 Axis 的 IP 地址)
- lbu commit
- 将互联网连接插入 eth0。
- 将交叉线缆插入 axis PoE 供电器,并将直通线缆插入 Axis。
- 将混音器的线路输出插入 axis。
- 给连接了显示器、键盘、鼠标的黑盒子供电。
- 桌面出现后,给 axis 供电。
OpenVPN 路由器
- /etc/shorewall/rules
DNAT E G_196:10.14.196.10 tcp 8080 - public.ip.addr.ess
- /etc/shorewall/masq
tun0 0.0.0.0/0 10.14.196.1 tcp 8080
最终用户说明
请验证所有以下组件是否正确发货
- 路由器
- 显示器
- 摄像头
- 摄像头电源供电器
- 2 根 50 英尺蓝色网线
- 1 根 14 英尺红色网线
- 2 根 6 英尺黑色电源线
- 1 个 AC 电源适配器
- 1 根显示器视频线缆
- 1 个键盘
- 1 个鼠标
- 将路由器放置在所需位置。应将其放置在平坦、稳定的表面上。
- 将显示器放置在路由器附近。
- 使用一根 6 英尺电源线,连接到显示器并打开显示器电源。
- 将显示器视频线缆从显示器的“RGB”端口连接到路由器上相应的端口。
- 将摄像头电源供电器放置在所需位置。
- 将红色网线从电源供电器的“Data In”插孔连接到路由器上标记为“Camera”的端口。
- 使用蓝色网线将互联网连接连接到路由器上标记为“Internet”的端口。
- 将键盘和鼠标连接到路由器背面的 USB 端口。
- 将 AC 电源适配器插入路由器,然后插入可用的电源插座。路由器将自动开机。
- 等待路由器发出 3 声提示音,桌面环境出现。(注意:Mozilla Firefox 将打开并显示错误消息“哎呀,真尴尬”。这是正常的。)。
- 将蓝色网线从摄像头连接到电源供电器的“Data & Power Out”插孔。
- 一旦摄像头顶部的指示灯变为绿色,请单击 Firefox 中的“Start New Session”。视频窗口应在短暂延迟后出现。
- 使用摄像头正面的拨盘手动调整摄像头的焦点和变焦。
- 要在远程位置端测试流,请在具有互联网连接的计算机上打开 VLC,然后运行 文件 -> 打开网络流 并连接到 http://public.ip.addr.ess:8080。