2026-01-06 - Cctv service design

From Izara Wiki
Jump to navigation Jump to search

CCTV Server Configuration

This configuration is used for the CCTV server. A Python FastAPI server will be created to:

  • Pull video from cameras
  • Save video locally on the computer
  • Upload video to S3

Video File Naming Convention: {cameraName}_{videofeedId}_{startTimeRecordTimeStamp}_{endTimeRecordTimeStamp}

Configuration File (config.json)

{
  "cameras": [
    {
      "cameraName": "camera1",
      "ipAddress": "192.168.0.1",
      "userName": "admin",
      "password": "password123",
      "frameRate": 2,
      "resolution": "1920x1080",
      "videoDuration": 600,
      "videoFeedId": "xx"
    },
    {
      "cameraName": "camera2",
      "ipAddress": "192.168.0.2",
      "userName": "admin",
      "password": "password456",
      "frameRate": 5,
      "resolution": "1280x720",
      "videoDuration": 300,
      "videoFeedId": "xx"
    }
  ],
  "s3Config": {
    "s3Bucket": "my-cctv-bucket",
    "s3Path": "recordings/2025"
  },
  "awsCredentials": {
    "accessKeyId": "YOUR_ACCESS_KEY",
    "secretAccessKey": "YOUR_SECRET_KEY",
    "region": "us-east-1"
  },
  "storageConfig": {
    "savePath": "/var/cctv/recordings",
    "clearAfterUpload": false,
    "clearWhenFilePathReachGB": 100
  }
}

Camera Configuration Parameters

Parameter Description Example
cameraName Name identifier for the camera camera1, camera2
ipAddress IP address of the camera 192.168.0.1
userName Username for camera authentication admin
password Password for camera authentication password123
frameRate Video frame rate (frames per second) 2, 5
resolution Video resolution 1920x1080, 1280x720
videoDuration Duration of each video recording in seconds 600, 300
videoFeedId Unique identifier for the video feed xx

S3 Configuration

Parameter Description Example
s3Bucket AWS S3 bucket name for storing videos my-cctv-bucket
s3Path Path within S3 bucket for video storage recordings/2025

AWS Credentials

Parameter Description Example
accessKeyId AWS access key ID YOUR_ACCESS_KEY
secretAccessKey AWS secret access key YOUR_SECRET_KEY
region AWS region us-east-1

Local Storage Configuration

Parameter Description Example Type
savePath Local directory path for saving videos /var/cctv/recordings string
clearAfterUpload Whether to delete local files after S3 upload false boolean
clearWhenFilePathReachGB Delete old videos when storage reaches this limit (GB) 100 number

Implementation Notes

  • Use FastAPI to create a Python web server
  • Connect to cameras via configured IP addresses using appropriate video capture libraries
  • Record video according to specified duration and frame rate
  • Save videos locally with the naming convention: {cameraName}_{videofeedId}_{startTimeRecordTimeStamp}_{endTimeRecordTimeStamp}
  • Upload completed videos to the configured S3 bucket and path
  • Implement storage management to clear old files if configured