File size: 2,164 Bytes
2156b71
 
 
 
 
 
 
 
 
 
 
 
 
 
652ed56
 
2156b71
 
a010e8e
2156b71
652ed56
2156b71
652ed56
a010e8e
 
 
 
 
 
 
a8673cc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
---
title: Monteeq Video Service
emoji: πŸŽ₯
colorFrom: blue
colorTo: indigo
sdk: docker
app_port: 7860
pinned: false
---

# Monteeq Video Service

High-performance, asynchronous Rust service for processing and transcoding video to HLS.

- **Health Check**: [/health](https://monteeqorg-readme.hf.space/health)

## Configuration

In your Hugging Face Space settings, add the following **Secrets** (AWS S3 β€” match `backend/.env`):

| Secret Name | Value |
|---|---|
| `REDIS_URL` | Redis Cloud connection URL |
| `AWS_ACCESS_KEY_ID` | AWS access key |
| `AWS_SECRET_ACCESS_KEY` | AWS secret key |
| `AWS_STORAGE_BUCKET_NAME` | `monteeq-2` |
| `AWS_S3_REGION_NAME` | `eu-central-1` |
| `AWS_CLOUDFRONT_DOMAIN` | `cdn.monteeq.com` |

Leave `S3_ENDPOINT` unset (or empty) so the service uses native AWS S3.

## Performance knobs

| Variable | Default | Purpose |
|---|---|---|
| `MAX_CONCURRENT_JOBS` | `min(cpus / 2, RAM GB / 1.5, DISK_IO_LIMIT)` | Worker slots. Override when the host reports throttled/shared CPUs. |
| `DISK_IO_LIMIT` | `4` | Upper bound used by the automatic slot calculation. |
| `UPLOAD_CONCURRENCY` | `12` | Parallel S3 segment PUTs. |

## Processing pipeline

1. **Validate** β€” one `ffprobe` call returns dimensions, duration, audio presence and codecs.
2. **Download** β€” streamed from S3 straight to disk (no full-file buffering), with progress reported to Redis.
3. **Plan** β€” if the source is already H.264/AAC and inside the tier cap it is **remuxed** (`-c copy`) instead of re-encoded. Otherwise the ladder is filtered against the source height, so the service never upscales, and the free tier emits a single rendition.
4. **Package** β€” ffmpeg writes HLS to a temp dir while a background task uploads each segment to S3 as soon as it is complete, so transfer overlaps the encode.
5. **Cover** β€” a frame is pulled from an already-encoded segment (~10% into the video), falling back to the source only if needed, then uploaded to `thumbnails/{task_id}.jpg`.
6. **Report** β€” `task:status:{task_id}` carries progress, and `variants` (the playlist names actually produced) so the backend only advertises renditions that exist.