Skip to main content

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):

MethodPathDescription
POST/api/v1/cctv/framesSubmit video frames for analysis
POST/api/v1/cctv/sessionsCreate a new ingest session
GET/api/v1/cctv/sessions/{id}Get session status

Environment Variables

VariableExample
ENVIRONMENTdev
API_GATEWAY_URLhttps://dev.api.crowai.dev

Bindings

BindingTypeName
DBD1crow-cctv-ingest-service-db
AIWorkers AIVision model inference
INGEST_SESSIONDurable ObjectIngestSession
INTERACTION_QUEUEQueue (producer)crow-interaction-queue
PATTERN_QUEUEQueue (producer)crow-pattern-queue

Queue Production

The CCTV ingest service produces to two queues:

QueuePurpose
crow-interaction-queueSends analyzed frame batches to interaction service
crow-pattern-queueSends 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-it analyzes 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