← avanzati.it · PSA Restreaming RTSP · 01 / 09
§ Deck prodotto · v1.0 · 2026

Una videocamera.
Mille schermi.

SaaS multi-tenant per ingest RTSP, transcoding GPU e ridistribuzione RTMP/HLS verso player web. Per videosorveglianza distribuita, live streaming, portali pubblici.

Progetti e Servizi Avanzati S.r.l. · Torino · AS42425 Avanti →
§ 01 / Il problema 02 / 09

RTSP nudo non basta. Il browser non lo parla.

Tra la camera IP e il player web serve un pezzo di infrastruttura. Altrimenti lo stream non arriva a nessuno.

RTSP nudo

Lo stream non arriva

  • Le cam IP parlano solo RTSP, i player web no
  • Codec vecchi (MJPEG, H.264 baseline) poco portabili
  • Multi-viewer ingolfa la camera: connessioni dirette in parallelo la piegano
  • Nessun adaptive bitrate: se cala la banda, si ferma tutto
  • Zero telemetria, zero storia, zero alert
Con il nostro restreamer

Una pipeline vera

  • Ingest RTSP una sola volta per camera, poi fan-out
  • Transcode GPU Nvidia (NVENC) · H.264 / HEVC · zero CPU
  • Stream una-a-molti via RTMP / HLS / LL-HLS
  • Adaptive bitrate 3 livelli: high · mid · low
  • Monitoring Prometheus + Grafana, alert Slack integrati
Contesto02 / 09
§ 02 / Pipeline 03 / 09

Cinque stadi tra la camera e il player.

Ogni feed passa da qui. Niente script artigianali, niente FFmpeg orfani sulla VM.

RTSP · 554 01 · Camera IP

Ingest RTSP

  • H.264 / HEVC nativo
  • Auth user/pass
  • Una sola connessione
GPU · RTX 4070 02 · Encoder PSA

Restreamer node

  • Container Docker
  • NVENC hardware
  • Stato online/offline
3 profili 03 · Transcode

Adaptive bitrate

  • high · 1080p · 2 Mbps
  • mid · 720p · 800 kbps
  • low · 480p · 300 kbps
RTMP · HLS 04 · MediaMTX

Output server

  • HLS · LL-HLS · DASH
  • Fan-out N viewer
  • CDN-friendly
Web / Mobile 05 · Player cliente

Stream finale

  • hls.js · video.js
  • iOS nativo
  • Embed iframe
Ingest → Transcode → Output03 / 09
§ 03 / Adaptive bitrate 04 / 09

Tre profili, un solo feed di ingest.

Il player sceglie il profilo in base alla connessione. Su fibra parte con high, su LTE scende a mid, in 3G rimane low senza tagliare il flusso.

Ingest
Una sola volta dalla camera. La GPU fa il lavoro, non la cam.
Switch lato player
Transizione automatica · segmenti HLS di 2-4s
Tradeoff
Più profili = più banda in uscita e più GPU occupata. Tre è il punto giusto.
Profilo Risoluzione Bitrate Rete tipica
High 1080p
1920 × 1080 · 25 fpsH.264 high profile
2000 kbpsCBR · NVENC
Fibra · WiFi> 5 Mbps down
Mid 720p
1280 × 720 · 25 fpsH.264 main profile
800 kbpsCBR · NVENC
4G · LTE2–5 Mbps down
Low 480p
854 × 480 · 15 fpsH.264 baseline
300 kbpsCBR · NVENC
3G · mobile scarso< 2 Mbps down
High · Mid · Low04 / 09
§ 04 / Multi-tenant 05 / 09

Clienti, encoder, camere. Gerarchia pulita.

Ogni cliente ha i suoi encoder (dedicati o condivisi) e le sue camere. Niente mix di stream tra tenant: isolamento a livello di path MediaMTX e di credenziali API.

GPU assegnata per encoder, bitrate aggregato monitorato in real-time. Esempi di carico attuale:

Cliente A · Retail
Catena negozi
encoder · 1 × RTX 4070 camere · 12 bitrate agg · 14 Mbps GPU load · 38%
ONLINE · 12/12
Cliente B · Industria
Plant multi-sito
encoder · 2 × RTX 4070 camere · 34 bitrate agg · 48 Mbps GPU load · 71% · 68%
ONLINE · 33/34
Cliente C · Eventi live
Fiera conferenze
encoder · 3 × RTX 4070 camere · 8 bitrate agg · 22 Mbps viewer picco · 1.240
LIVE · 8/8
Cliente D · Portale meteo
Cam pubbliche
encoder · 1 × RTX 4070 camere · 6 outdoor bitrate agg · 7 Mbps GPU load · 22%
ONLINE · 6/6
Isolamento per tenant05 / 09
§ 05 / Casi d'uso 06 / 09

Quattro scenari reali, non slide di marketing.

Dal capannone industriale alla webcam sulla spiaggia. Stessa pipeline, dimensionamento diverso.

01
Videosorveglianza multi-sito industriale.
24/7 · 34 cam su 3 plant · 2 encoder GPU · retention locale.
02
Live streaming eventi.
Conferenze e fiere · picchi di 1k-5k viewer simultanei · LL-HLS per bassa latenza.
03
Feed pubblici per portali.
Cam spiaggia, parcheggi, meteo · embed iframe per i siti clienti.
04
Monitoring processo industriale.
Time-lapse da cam fissa · registrazione su rolling buffer · export on-demand.
mediamtx · encoder-02.live
# encoder-02 · RTX 4070 · MediaMTX v1.8 · gen 08:14 UTC
[INGEST] rtsp://cam01.clienteB:554/stream
codec · h264 · 1920×1080 · 25 fps
[TRANSCODE] h264 → h264 · GPU 0 · NVENC · 47% load
high · 2000 kbps · 1080p25 · ok
mid · 800 kbps · 720p25 · ok
low · 300 kbps · 480p15 · ok
[PUBLISH] rtmp://stream.avanzati.it/clientB/cam01
[PUBLISH] hls://stream.avanzati.it/clientB/cam01/high.m3u8
viewer · 23 · latenza hls · 4.2s
[INGEST] rtsp://cam02.clienteB:554/stream
[TRANSCODE] hevc → h264 · GPU 0 · NVENC · 62% load
[WARN] cam07.clienteB · frame drops 1.8% · link?
[PUBLISH] hls://stream.avanzati.it/clientB/cam02/high.m3u8
viewer · 41 · latenza ll-hls · 2.1s
...
[STAT] 34 ingest · 102 output stream · GPU 68% · 48 Mbps out
Videosorveglianza · Live · Portali06 / 09
§ 06 / Monitoring 07 / 09

Ogni stream lascia traccia. Prometheus + Grafana.

Metriche raccolte ogni 15s da ogni encoder e da MediaMTX. Alert su soglie editabili, dashboard per cliente.

68%
GPU load per encoder
per-card · NVENC + CUDA
48 Mbps
Bitrate out aggregato
per tenant · per path
1.240
Viewer count picco
per stream · real-time
4 s
Latenza HLS tipica
LL-HLS 2-3s · DASH 2s
0,3%
Frame drops
rolling 5 min per cam
0,01%
Packet loss ingest
RTSP over TCP preferito
99,7%
Uptime encoder 30g
docker healthcheck · 30s
30 gg
Retention metriche
Prometheus tsdb locale
Alert · critical
Encoder offline > 60s · Slack #allarmi-critici
Alert · warning
GPU > 90% sostenuta · latenza > 10s
Alert · info
Deploy nuovo feed · restart pianificato
Prometheus · Grafana · Slack07 / 09
§ 07 / Stack 08 / 09

Stack solido, nessuna magia.

Componenti open source maturi, scelti per stare in piedi da soli. Niente vendor-lock, niente SaaS esterni nel percorso critico.

API · admin Control plane

Django + DRF

  • Tenant, encoder, cam
  • Autorizzazioni per ruolo
  • OpenAPI schema
Async Job runner

Celery + Redis

  • Health check encoder
  • Restart stream
  • Scheduler config
Source of truth Storage

PostgreSQL 16

  • Tenant · encoder · cam
  • Stream configs versioned
  • Audit log
GPU · NVENC Transcoder

Restreamer

  • FFmpeg wrapper
  • H.264 / HEVC
  • Un processo per cam
RTMP · HLS Output server

MediaMTX

  • Path per tenant
  • Auth esterna
  • Prometheus exporter
Django · Celery · Postgres · Restreamer · MediaMTX08 / 09
§ 08 / Adozione 09 / 09

Una pipeline robusta tra la camera e il vostro player.

Setup tipico in un pomeriggio di lavoro. Primo feed online entro 48h. Multi-tenant, un encoder per voi o condiviso, a scelta.
PSA S.r.l. · Torino · AS42425 · Restreaming RTSPFine