Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ No vendor cloud, no subscription, no account with us.

## What you get

- **Works with your cameras.** Brand presets for Tapo, Eufy, UniFi, Reolink, Hikvision, Dahua, Amcrest, Axis, Foscam, EZVIZ, Imou, Annke and Wyze, ONVIF discovery on your network, one-step UniFi Protect import. Cameras that can only send video can push RTMP or RTSP to the server.
- **Works with your cameras.** Brand presets for Tapo, Eufy, UniFi, Reolink, Hikvision, Dahua, Amcrest, Axis, Foscam, EZVIZ, Imou, Annke and Wyze, ONVIF discovery on your network, one-step UniFi Protect import, and eufy account import for battery and solar cameras that have no RTSP (SoloCam, eufyCam, doorbells). Cameras that can only send video can push RTMP or RTSP to the server.
- **Live view in under a second.** WebRTC with MSE and HLS fallback, HD and SD streams, snapshots, two-way audio and PTZ on supported cameras.
- **Recording.** Continuous or motion-only per camera, stored the way the camera sends it (no re-encoding), with a timeline, motion markers and clip export.
- **Your own cloud.** Recordings are copied to Google Drive, S3-compatible storage, FTP, SFTP, SMB, WebDAV, Dropbox, OneDrive or a local folder and deleted automatically after the number of days you choose. Ideal for cameras without an SD card or cloud plan.
Expand Down
17 changes: 16 additions & 1 deletion docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Shared contract between `server/` and `app/`. JSON everywhere, ISO 8601 UTC time
```ts
type Camera = {
id: string; name: string; brand: BrandId; group?: string; order: number; enabled: boolean;
source: { kind: 'rtsp' | 'onvif' | 'tapo' | 'unifi' | 'http' | 'rtmp-push' | 'rtsp-push' | 'demo'; url: string /* password masked as *** */; subUrl?: string };
source: { kind: 'rtsp' | 'onvif' | 'tapo' | 'unifi' | 'eufy' | 'http' | 'rtmp-push' | 'rtsp-push' | 'demo'; url: string /* password masked as *** */; subUrl?: string };
recording: { mode: 'continuous' | 'motion' | 'off'; useSubstream: boolean };
motion: { enabled: boolean; sensitivity: number /* 1-10 */; notify: boolean };
capabilities: { audio: boolean; twoWayAudio: boolean; ptz: boolean; substream: boolean };
Expand All @@ -53,6 +53,21 @@ type BrandId = 'tapo' | 'eufy' | 'unifi' | 'reolink' | 'hikvision' | 'dahua' | '
| POST | `/api/cameras/:id/ptz` | `{ action:'move', pan, tilt, zoom }` (-1..1) / `{ action:'stop' }` / `{ action:'preset', preset }` | `{ ok }` |
| GET | `/api/discover` | | `{ candidates: { host, port, brand?, name?, model?, onvif: boolean, rtsp: boolean, alreadyAdded: boolean }[] }` (ONVIF WS-Discovery + LAN port probe, ≤ 8 s) |
| POST | `/api/integrations/unifi/import` | `{ host, username, password, cameraIds? }` | `{ cameras: { id, name, model, added: boolean }[] }` |
| GET | `/api/integrations/eufy` (admin) | | `EufyAccount` |
| POST | `/api/integrations/eufy/login` (admin) | `{ email, password, country }` (ISO country of the eufy account, e.g. `DE`) | `EufyAccount` (`status` is `connected`, `2fa`, `captcha` or `error`) |
| POST | `/api/integrations/eufy/verify` (admin) | `{ code }` (code eufy sent by email) | `EufyAccount` |
| POST | `/api/integrations/eufy/captcha` (admin) | `{ answer }` | `EufyAccount` |
| POST | `/api/integrations/eufy/refresh` (admin) | | `EufyAccount` |
| POST | `/api/integrations/eufy/import` (admin) | `{ serials?: string[] }` | `{ cameras: { id, name, model, added: boolean, cameraId?, error? }[] }` |
| DELETE | `/api/integrations/eufy` (admin) | | `EufyAccount` (signs out, cameras stay but go offline) |

```ts
type EufyAccount = { status: 'disconnected' | 'connecting' | 'captcha' | '2fa' | 'connected' | 'error'; email?: string; country?: string;
captcha?: string /* data URL of the image to solve */; method?: string; error?: string;
cameras: { serial: string; name: string; model: string; battery: boolean; batteryLevel?: number; rssi?: number /* WiFi dBm */; station?: string; added: boolean; cameraId?: string }[] }
```

eufy cameras (`source.kind: 'eufy'`) are reached through the eufy account, the way the eufy app does it, so models without RTSP work. The stream is pulled only while someone watches or a recording runs; imported cameras start with recording `off` and motion events come from the camera itself. The eufy client runs in a Node.js 24.5+ worker process next to the server (bundled in the Docker image, found on `PATH` or downloaded once otherwise; override with `OPENCCTV_NODE`).

## Recordings, timeline, events

Expand Down
3 changes: 3 additions & 0 deletions server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,13 @@ RUN curl -fsSL -o /tmp/rclone.zip "https://downloads.rclone.org/rclone-current-l

FROM mwader/static-ffmpeg:9.0.2 AS ffmpeg

FROM node:24-bookworm-slim AS node

FROM debian:bookworm-slim
RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates tzdata && rm -rf /var/lib/apt/lists/*
COPY --from=ffmpeg /ffmpeg /ffprobe /usr/local/bin/
COPY --from=tools /usr/local/bin/go2rtc /usr/local/bin/rclone /usr/local/bin/
COPY --from=node /usr/local/bin/node /usr/local/bin/node
COPY --from=build /out/opencctv /usr/local/bin/opencctv
COPY demo/media/ /opt/opencctv/demo/
ENV OPENCCTV_DOCKER=1 \
Expand Down
93 changes: 93 additions & 0 deletions server/bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@
"test": "bun test",
"typecheck": "tsc --noEmit",
"build": "bun run scripts/build.ts",
"build:local": "bun build --compile --production src/index.ts --outfile dist/opencctv"
"build:local": "bun run scripts/build.ts local"
},
"dependencies": {
"@mega-yfue/eufy-sdk": "0.4.0",
"qrcode-generator": "^1.4.4",
"react": "^19.1.0",
"react-dom": "^19.1.0"
Expand Down
15 changes: 13 additions & 2 deletions server/scripts/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { mkdirSync } from "node:fs";
import pkg from "../package.json" with { type: "json" };

const ALL = ["linux-x64", "linux-arm64", "darwin-arm64", "darwin-x64", "windows-x64"];
const args = process.argv.slice(2);
const host = `${process.platform === "win32" ? "windows" : process.platform}-${process.arch}`;
const args = process.argv.slice(2).map((a) => (a === "local" ? host : a));
const targets = args.length ? args : ALL;

const defines: string[] = [];
Expand All @@ -11,6 +12,12 @@ for (const [name, value] of [
["OPENCCTV_BUILTIN_GOOGLE_CLIENT_SECRET", process.env.GOOGLE_CLIENT_SECRET],
]) if (value) defines.push("--define", `${name}=${JSON.stringify(value)}`);

const GEN = "src/eufy-worker.gen.ts";
const worker = await Bun.build({ entrypoints: ["src/eufy-worker.mjs"], target: "node", format: "esm", minify: true });
if (!worker.success) throw new Error(`eufy worker bundle failed: ${worker.logs.join("\n")}`);
await Bun.write(GEN, `export default ${JSON.stringify(await worker.outputs[0]!.text())};\n`);
const restoreGen = () => Bun.write(GEN, 'export default "";\n');

mkdirSync("dist", { recursive: true });
for (const t of targets) {
if (!ALL.includes(t)) throw new Error(`unknown target ${t}`);
Expand All @@ -25,6 +32,10 @@ for (const t of targets) {
],
{ stdout: "inherit", stderr: "inherit" },
);
if ((await p.exited) !== 0) process.exit(1);
if ((await p.exited) !== 0) {
await restoreGen();
process.exit(1);
}
}
await restoreGen();
console.log(`built OpenCCTV ${pkg.version}`);
Loading
Loading