2.5 KiB
2.5 KiB
IPCam Orange Pi Dashboard
Dashboard giám sát camera IP gọn nhẹ chạy trên Orange Pi, dựa trên MediaMTX:
- Live View (WebRTC WHEP) dạng grid, auto reconnect, lazy load
- Playback fMP4 theo camera + ngày (file list + HTML5 video)
- Settings: quản lý camera + lịch ghi hình (scheduler ở backend)
Cấu trúc thư mục
src/: frontend Reactapi/: backend FastAPI.trae/documents/: tài liệu yêu cầu/kiến trúc
Backend API
GET /api/healthGET /api/configPOST /api/cameras/DELETE /api/cameras/{name}GET /api/paths(proxy trạng thái từ MediaMTX)POST /api/recording(bật/tắt ghi hình ngay)POST /api/scheduler/enabled/POST /api/scheduler/scheduleGET /api/recordings?camera=cam1&date=YYYY-MM-DDGET /videos/<camera>/<file>.fmp4
Chạy dev (máy dev)
0) Tạo file .env
cp .env.example .env
Sửa các biến trong .env theo IP/port thực tế (MediaMTX, recordings, CORS).
1) Chạy backend
python3 -m venv api/.venv
source api/.venv/bin/activate
pip install -r api/requirements.txt
python3 api/run.py
2) Chạy frontend
npm install
npm run dev
Frontend dev server đã được cấu hình proxy /api và /videos sang http://localhost:8008.
Cấu hình
Khuyến nghị cấu hình bằng file .env (copy từ .env.example).
Backend tự tạo file cấu hình tại api/data/config.json khi chạy lần đầu.
mediamtx_api_url: ví dụhttp://127.0.0.1:9997mediamtx_webrtc_url: ví dụhttp://127.0.0.1:8889recordings_dir: ví dụ/recordingscameras: danh sách camera (name + rtsp_url)schedule: lịch ghi hình
Có thể override WebRTC base URL ở frontend bằng biến môi trường VITE_MEDIAMTX_WEBRTC_URL.
Có thể set giá trị mặc định khi chạy lần đầu bằng ENV (backend):
MEDIAMTX_API_URL(ví dụhttp://192.168.88.10:9997)MEDIAMTX_WEBRTC_URL(ví dụhttp://192.168.88.10:8889)RECORDINGS_DIR(ví dụ/recordingshoặc đường dẫn mount NFS/SMB)
Chạy tách 2 thiết bị (cùng LAN)
- Máy A (MediaMTX + ổ lưu recordings): chạy MediaMTX, mở cổng
9997/tcp,8889/tcp,8189/udp,8554/tcp - Máy B (Dashboard backend + frontend): chạy FastAPI + serve web UI
- Playback: máy B cần đọc được thư mục recordings của máy A (khuyến nghị mount NFS/SMB về
RECORDINGS_DIR)
Chi tiết xem INSTALL.md.
Triển khai
Xem hướng dẫn chi tiết trong INSTALL.md.