BÀI ĐANG VIẾT
Đây là những ghi chép trong quá trình triển khai nhúng live streaming camera video lên website trangtraihuounai.com.
1. Yêu cầu
Không quá nhiều điểm đặc biệt:
- Nhúng livestream camera của trang trại lên website
- Hệ thống đơn giản, có thể dễ dàng mở rộng khi cần thiết
2. Ý tưởng
Gọn nhẹ nhất có thể:
- Sử dụng máy tính all-in-one cho tất cả các tác vụ
- Lấy luồng RTSP từ camera phát lại bằng go2rtc
- Nhúng trực tiếp vào website hoặc phát kênh Youtube?
2.1. Thiết bị thử nghiệm
Đang có sẵn các thứ sau:
- Mini PC N4100: 4x1GB Ethernet
- PoE Switch không biết tên
- Imou Cruiser 2 (5MP Outdoor Wi-Fi P&T Camera)
Thay thế thiết bị khác sau khi chạy thử:
- All-in-one box: HP / Dell
- Camera: Dahua / Hikvision
2.2. Sơ đồ hệ thống
Sẽ tách router trong tương lai, hiện tại chạy ImmortalWrt trên môi trường ảo hóa.
2.3. Các bước triển khai
Task List
- Cài đặt FreeBSD box
- Cấu hình hệ thống mạng sẵn sàng cho máy ảo
- Cài đặt máy ảo chạy ImmortalWrt làm router
- Cấu hình ImmortalWrt, quy hoạch VLAN
- Cài đặt máy ảo chạy Debian làm docker host
- Cài đặt nginx làm reverse proxy, nat port 80/443 từ router
- Cài đặt go2rtc lấy luồng RTSP / ONVIF từ camera
- Cài đặt nginx làm web server, nhúng stream vào trang web
- Chuyển thiết bị đến trang trại, quay pppoe mở port 80/443
- Chạy thử trong 30 ngày
3. Các vấn đề gặp phải
- high latency from cameras to web media player: check bridge+tap on bhyve, maybe passthru all nics and use something like vether / epair / vale / netgraph.. done.
- Deploy TURN server and stream by WebRTC, much better latency
- transcoding video requires high CPU load, checked bhyve GPU passthru but it didn’t work. moved to Linux instead of FreeBSD. needed something like CUDA
- can not pull rtsp stream from EZVIZ camera, they use their own protocol. best camera brand for this job: Dahua, Imou
- security risk when expose go2rtc API
- Deploy a mediamtx WebRTC endpoint, expose via a reverse proxy
4. New proposal
4.1. Network
Router on baremetal:
- HINLINK OPC-H28K Board run KWrt
- DHCP Static Mappings for services and cameras
4.2. Server
Hardware:
- PC: HP EliteDesk 800 G4 SFF Business PC
- Graphics card: NVIDIA Quadro P600
Software:
- Operating System
- Ubuntu 24.04 (Noble Numbat)
- HP BIOS config
- Advanced -> Secure Boot Configuration -> Legacy Support Disable and Secure Boot Enable
- Install detail
- Ubuntu Server (minimised)
- No LVM
- GPU Driver
- NVIDIA Driver Installation Guide for Linux: use legacy kernel module flavor
cuda-drivers
for this card - NVIDIA CUDA Installation Guide for Linux
- NVIDIA Container Toolkit
- NVIDIA Driver Installation Guide for Linux: use legacy kernel module flavor
- Virtualization
- Docker
- KVM
- Streaming
- DDNS
- STUN/TURN
- Reverse proxy
- Website
- Remote access
- Tailscale / WireGuard on a KVM virtual machine