A service to capture relevant video clips from an online camera. The service can run as worker in 2 modes:
Capture video from a stream using Python libraries (cv2.VideoCapture), save as video clips in configurable resolution and duration. Video is stored locally and then uploaded to cloud bucket.
Line crossing detection. The service run as stand alone worker and pick up videos from the cloud bucket. Configuration from database (default values in global_settings.json) will always be shared between the workers while each worker's mode will be defined through environment (env) configuration.
Sets usage of local file storage or cloud services such as Buckets valid storage modes (VIDEO_STORAGE_MODE): local_storage - pushing video to cloud bucket cloud_storage - pushing image detectsions to cloud bucket
Install uv, e.g.:
% curl -LsSf https://astral.sh/uv/install.sh | shThen install the dependencies:
% uv sync
curl https://pyenv.run | bash
python -m venv .venv
pyenv install 3.13
source .venv/bin/activateset -a
source .env
set +a
python -m video_service.app
Dependencies (services & db):
docker compose up integration-service race-service competition-format-service photo-service user-service event-service mongodb photo-service-gui% git clone https://github.com/heming-langrenn/video-service.git % cd video-service
LOGGING_LEVEL=INFO ADMIN_USERNAME=admin ADMIN_PASSWORD=password EVENTS_HOST_SERVER=localhost EVENTS_HOST_PORT=8082 PHOTOS_HOST_SERVER=localhost PHOTOS_HOST_PORT=8092 USERS_HOST_SERVER=localhost USERS_HOST_PORT=8086 GOOGLE_CLOUD_PROJECT=sigma-celerity-257719 GOOGLE_STORAGE_BUCKET=langrenn-sprint GOOGLE_STORAGE_SERVER=https://storage.googleapis.com GOOGLE_CLOUD_REGION=europe-north1 MODE=CAPTURE_LOCAL
We use pytest for contract testing.
To run linters, checkers and tests:
% uv run poe releaseTo run tests with logging, do (/home/heming/Nedlastinger/20250525_GKOpp1.mp4):
% uv run pytest -m integration -- --log-cli-level=DEBUGhttps://storage.googleapis.com/langrenn-sprint/photos/20240309_Ragde_lang.mp4 http://10.0.0.27:8080/video
docker system prune -a --volumesdocker compose build docker login ghcr.io -u github password: Use a generated access token from GitHub (https://github.com/settings/tokens/1878556677) docker tag ghcr.io/langrenn-sprint/video-service:test ghcr.io/langrenn-sprint/video-service:latest docker push ghcr.io/langrenn-sprint/video-service:latest
gcloud artifacts repositories create docker-repository
--repository-format=docker
--location="europe-north1"
--description="Docker repository"
gcloud projects add-iam-policy-binding [PROJECT_ID]
--member="serviceAccount:[SERVICE_ACCOUNT_EMAIL]"
--role="roles/artifactregistry.writer"
This is handled by github_actions - see .github/workflows/deploy_google.yml
- Go to Worker Pools and Click Deploy Container
- Select "Depoloy one revision" and paste container image uri (or select from the list)
- Configure scaling (recommendation: ?)
- Paste environment variables from this file - remember to modify passwords!
- Environment - make sure MODE = DETECT
- Click create!