thay doi tinh nang chay trong mang noi bo
This commit is contained in:
+72
@@ -2,6 +2,21 @@
|
||||
|
||||
Tài liệu này hướng dẫn triển khai trên Orange Pi (Linux). Mục tiêu: MediaMTX chạy như media server, FastAPI chạy như dashboard backend, React build ra static.
|
||||
|
||||
## 0) Mô hình triển khai
|
||||
|
||||
### A) 1 thiết bị (đơn giản nhất)
|
||||
|
||||
- MediaMTX + Dashboard backend + Dashboard frontend chạy cùng máy
|
||||
|
||||
### B) 2 thiết bị (cùng LAN / cùng lớp mạng)
|
||||
|
||||
- Máy A: chạy MediaMTX + lưu recordings
|
||||
- Máy B: chạy Dashboard backend + frontend
|
||||
- Máy B sẽ gọi:
|
||||
- MediaMTX API của máy A (port 9997) để add/remove camera + bật/tắt recording
|
||||
- WebRTC/WHEP của máy A (port 8889 + UDP 8189) để xem live
|
||||
- Playback: máy B cần đọc được recordings của máy A (khuyến nghị mount NFS/SMB)
|
||||
|
||||
## 1) Yêu cầu
|
||||
|
||||
- Orange Pi chạy Debian/Ubuntu
|
||||
@@ -19,6 +34,7 @@ apiAddress: :9997
|
||||
|
||||
webrtc: yes
|
||||
webrtcAddress: :8889
|
||||
webrtcAllowOrigin: '*'
|
||||
|
||||
record: yes
|
||||
recordFormat: fmp4
|
||||
@@ -26,6 +42,13 @@ recordPath: /recordings/%path/%Y-%m-%d_%H-%M-%S-%f
|
||||
recordPartDuration: 5m
|
||||
```
|
||||
|
||||
Nếu chạy mô hình 2 thiết bị, đảm bảo MediaMTX trả về đúng IP LAN để client kết nối ICE:
|
||||
|
||||
```yaml
|
||||
webrtcAdditionalHosts:
|
||||
- 192.168.88.10
|
||||
```
|
||||
|
||||
Trong `paths`, bạn có thể để dashboard tự thêm path bằng API (Settings → Add Camera).
|
||||
|
||||
Tạo thư mục recordings:
|
||||
@@ -42,6 +65,33 @@ Mở firewall/cổng (tuỳ hệ thống):
|
||||
- `9997/tcp` MediaMTX Control API
|
||||
- `8189/udp` ICE
|
||||
|
||||
## 2.1) Playback khi tách 2 thiết bị (mount recordings)
|
||||
|
||||
Vì MediaMTX ghi file recordings trên máy A, nên Dashboard (máy B) cần truy cập được folder này để:
|
||||
|
||||
- list file `/api/recordings`
|
||||
- serve file `/videos/...`
|
||||
|
||||
Khuyến nghị dùng NFS (Linux-Linux):
|
||||
|
||||
Máy A:
|
||||
|
||||
```bash
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y nfs-kernel-server
|
||||
echo "/recordings 192.168.88.0/24(rw,sync,no_subtree_check)" | sudo tee -a /etc/exports
|
||||
sudo exportfs -ra
|
||||
```
|
||||
|
||||
Máy B:
|
||||
|
||||
```bash
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y nfs-common
|
||||
sudo mkdir -p /recordings
|
||||
sudo mount -t nfs 192.168.88.10:/recordings /recordings
|
||||
```
|
||||
|
||||
## 3) Backend FastAPI
|
||||
|
||||
### 3.1 Cài dependencies
|
||||
@@ -63,6 +113,26 @@ Bạn có thể chỉnh:
|
||||
- `mediamtx_webrtc_url` (mặc định `http://127.0.0.1:8889`)
|
||||
- `recordings_dir` (mặc định `/recordings`)
|
||||
|
||||
Nếu chạy mô hình 2 thiết bị, set theo IP máy A (MediaMTX), ví dụ:
|
||||
|
||||
```json
|
||||
{
|
||||
"mediamtx_api_url": "http://192.168.88.10:9997",
|
||||
"mediamtx_webrtc_url": "http://192.168.88.10:8889",
|
||||
"recordings_dir": "/recordings",
|
||||
"cameras": [],
|
||||
"schedule": { "enabled": true, "weekdays_from": "18:00", "weekdays_to": "08:00", "weekend_all_day": true }
|
||||
}
|
||||
```
|
||||
|
||||
Hoặc set ENV trước lần chạy đầu tiên để tạo config mặc định:
|
||||
|
||||
```bash
|
||||
export MEDIAMTX_API_URL="http://192.168.88.10:9997"
|
||||
export MEDIAMTX_WEBRTC_URL="http://192.168.88.10:8889"
|
||||
export RECORDINGS_DIR="/recordings"
|
||||
```
|
||||
|
||||
Nếu MediaMTX API có auth, export biến môi trường:
|
||||
|
||||
```bash
|
||||
@@ -120,6 +190,8 @@ server {
|
||||
}
|
||||
```
|
||||
|
||||
Nếu chạy mô hình 2 thiết bị, phần Nginx ở máy B không cần proxy tới MediaMTX. Frontend sẽ gọi trực tiếp `mediamtx_webrtc_url` (máy A).
|
||||
|
||||
## 5) Systemd service (khuyến nghị)
|
||||
|
||||
### 5.1 Backend service
|
||||
|
||||
Reference in New Issue
Block a user