cctv-ingest-service
Handles CCTV video frame ingestion and real-time analysis. Uses Durable Objects (IngestSession) to manage session state and Workers AI (@cf/google/gemma-3-12b-it) for multimodal frame analysis. Dispatches analyzed frame batches to the interaction service via queues.
Worker name: crow-cctv-ingest-service
Domain (prod): cctv.crowai.dev
Domain (dev): dev.cctv.crowai.dev
Schema
The service uses a D1 database (crow-cctv-ingest-service-db) for session metadata and frame tracking. Schema is in src/db/schema.ts.
Durable Object
IngestSession
Manages the lifecycle of a CCTV ingestion session:
- Receives video frames from the client
- Buffers frames within a session window
- Runs vision analysis on each frame using
@cf/google/gemma-3-12b-it - Batches frame analyses and dispatches to queues
Routes
Key routes (gateway path cctv):
| Method | Path | Description |
|---|---|---|
| POST | /api/v1/cctv/frames | Submit video frames for analysis |
| POST | /api/v1/cctv/sessions | Create a new ingest session |
| GET | /api/v1/cctv/sessions/{id} | Get session status |
Environment Variables
| Variable | Example |
|---|---|
| ENVIRONMENT | dev |
| API_GATEWAY_URL | https://dev.api.crowai.dev |
Bindings
| Binding | Type | Name |
|---|---|---|
| DB | D1 | crow-cctv-ingest-service-db |
| AI | Workers AI | Vision model inference |
| INGEST_SESSION | Durable Object | IngestSession |
| INTERACTION_QUEUE | Queue (producer) | crow-interaction-queue |
| PATTERN_QUEUE | Queue (producer) | crow-pattern-queue |
Queue Production
The CCTV ingest service produces to two queues:
| Queue | Purpose |
|---|---|
crow-interaction-queue | Sends analyzed frame batches to interaction service |
crow-pattern-queue | Sends data for pattern analysis |
Dependencies
- Inbound: gateway (client frame submissions), CCTV daemon on-premise
- Outbound: interaction service (via queue), pattern service (via queue)
Key Behaviors
- Vision model:
@cf/google/gemma-3-12b-itanalyzes individual frames, describing customer movements, behaviors, and product interactions - Session management: Durable Objects maintain session state across frame submissions
- Hourly sessions: One hour of continuous footage equals one session
- Batch dispatch: Frame analyses are grouped into batches before being queued for interaction synthesis