Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
| cdn [2020/02/04 00:25] – CDN-Bild ischluff | cdn [2025/11/03 12:23] (current) – ischluff | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| = CDN | = CDN | ||
| - | Diese Doku beschreibt unser Live-Streaming CDN, wie es seit dem 34C3 gilt. | ||
| - | == Architektur | + | < |
| - | Die CDN-Kaskade hat 5 Stufen: Master-Encoder, | + | This documentation describes our Livestreaming |
| - | {{:cdn_overview.png?1200|}} | + | The File-CDN for media.ccc.de is described on [[software:voctoweb]]. |
| + | </ | ||
| - | === 1. Master-Encoder | + | ==== Repo Links |
| - | Das Master-Encoding entsteht auf dem encoder-cube im Saal aus dem Ausgabesignal des Voctomix. Das Master-Encoding enthält den Mix als 1080p25 in h264 sowie die Slides als 1080p5 in h264 sowie aac von bis zu drei Audiospuren (Native, Translated, Translated-2). Wahlweise können die Übersetzerspuren sowie die Slide-Spur weggelassen werden. Alle Spuren werden in einem Matroska-Container verpackt. | + | * Stream-api, Upload-Proxy, Upload-Server: https:// |
| + | * rtmp-auth daemon: https:// | ||
| + | * Transcoding-Script: https:// | ||
| - | Das Master-Encoding wird von einem Script erzeugt, welches vom ansible aus folgendem Template erzeugt wird: https:// | + | == Architecture |
| + | The CDN-Cascade has 6 stages: Encoder, Ingest, Transcoder, Origin-Relays, Edge-Relays and finally Load-balancers. | ||
| + | {{: | ||
| - | Das Master-Encoding wird auf den lokalen (= auf dem encoder-cube laufenden) Icedist | + | === 1. Encoder |
| + | The initial stream encoding is created near the stage on the encoder | ||
| + | The encoding usually contains a 1080p25 H264 video signal, the slides as 1080p5 and up to 3 tracks of audio encoded in AAC (Native, Translated, Translated-2). | ||
| + | The translated audio tracks and the slide video track are optional. | ||
| + | The origin encoding is pushed as MPEG-TS via SRT to the ingest stage. | ||
| - | ==== Debugging | + | === 2. Ingest |
| + | The ingest machines run both [[https:// | ||
| - | http://195.54.164.164: | + | Additionally the ingest machines run a stream-api daemon which scrapes the local stream information from both srtrelay and nginx-rtmp and publishes it to consul KV. |
| + | The consul KV path is /stream/<stream slug> | ||
| ``` | ``` | ||
| - | voc@live.ber: | + | # consul kv get /stream/s96 |
| - | ● icedist.service - distribution Icecast | + | {" |
| - | | + | |
| - | | + | |
| - | Main PID: 794 (icecast2) | + | |
| - | Tasks: 25 (limit: 4915) | + | |
| - | | + | |
| - | | + | |
| - | + | ||
| - | sudo tail -f / | + | |
| ``` | ``` | ||
| - | === 2. Transcoder | + | === 3. Transcoder |
| - | Das Transcoding läuft auf Speedy & Tweety im RZ " | + | The stream transcoding transforms the mpegts stream into multiple segmented streams |
| - | * **speedy**: '' | + | The transcoding script can be found here https:// |
| - | * **tweety**: '' | + | |
| - | < | + | A python script runs constantly on each transcoder which fetches streams from consul and tries to claim streams which don't have a transcoder assigned yet. |
| + | The consul KV path is /stream/< | ||
| + | ``` | ||
| + | # consul kv get / | ||
| + | myloc-transcoder3 | ||
| - | Diese Verteilung wird über Host-Attribute im cm geregelt: https://github.com/voc/ | + | # To reallocate a transcoder for a stuck stream |
| + | consul kv delete | ||
| + | ``` | ||
| - | Die Transcoding-Scripte holen sich die Master-Streams von http://live.ber.c3voc.de: | + | Every time a transcoder claims a stream it writes an env file and starts a systemd unit to run the transcoding script. |
| + | The transcode updates are also published to the #voc-wok IRC. | ||
| - | Die Scripte dazu werden vom ansible aus folgenden Templates erzeugt: | + | The transcoding outputs are directly pushed with HTTP uploads to the Origin relays. To ensure proper retries the uploads are sent over a local http-proxy (https:// |
| - | Die drei Scripte | + | === 4. Origin Relays |
| + | Origin relays run the upload server | ||
| + | The upload server has some additional logic to rewrite the HLS playlists on the fly in order to properly handle stream restarts. | ||
| - | * http://live.lan.c3voc.de: | + | The segmented streams, thumbnails etc. are currently served by nginx. |
| - | * http:// | + | |
| - | * http:// | + | |
| - | Da jeder Format-Stream aus einem einzelnen ffmpeg-Prozess stammt und in einem Container landet sind die darin enthaltenen Videoströme Zeitsynchron zueinander. Die Trennung nach Formaten soll ermöglichem einzelne Format-Transport-Chains bei Problemen neustarten zu können, ohne die andere zu stören. | + | === 5. Edge-Relays |
| + | The edge relays run nginx with caching proxy config and upstream set to the active origin relay. | ||
| - | Die Pull-Quelle und das Push-Ziel ist über Group-Vars konfigurierbar: | + | === 6. Loadbalancer |
| + | The end-user facing domains '' | ||
| + | ==== streaming.media.ccc.de | ||
| + | The load-balancers serve the [[: | ||
| - | ==== Verwaltung | + | ==== cdn.c3voc.de |
| - | Je nach Event und Situation möchte man ggf. die Verteilugn der Streams zwischen Speedy und Tweety anders einstellen. Dazu existieren auf beiden Rechnern systemd-Targets für jeden Raum. Um einen Überblick über die derzeit aktivierten Transcodings zu erhalten kann folgender Befehl verwendet werden: | + | Requests to '' |
| - | < | + | The relay weight distribution is stored in consul KV and can be tweaked in real time. The haproxy configs automatically get updated by consul-template after a change. |
| - | voc@tweety.int:~$ systemctl list-units ' | + | |
| - | UNIT LOAD | + | |
| - | transcode_s1_audio.service | + | |
| - | transcode_s1_h264.service | + | |
| - | transcode_s1_vpx.service | + | |
| - | transcode_s2_audio.service | + | |
| - | … | + | |
| - | transcode_s1.target | + | |
| - | transcode_s2.target | + | |
| - | … | + | |
| - | </ | + | |
| - | Zum auflisten aller verfügbaren Transcoder kann folgender Befehl benutzt werden: | + | ``` |
| - | < | + | # Get the current weight distribution, |
| - | voc@tweety.int: | + | consul kv get -recurse / |
| - | UNIT FILE | + | services/ |
| - | transcode_s1_audio.service | + | services/ |
| - | transcode_s1_h264.service | + | ``` |
| - | transcode_s1_vpx.service | + | |
| - | transcode_s2_audio.service | + | |
| - | … | + | |
| - | transcode_s1.target | + | |
| - | transcode_s2.target | + | |
| - | transcode_s3.target | + | |
| - | transcode_s4.target | + | |
| - | transcode_s5.target | + | |
| - | transcode_s6.target | + | |
| - | </ | + | |
| - | Einzelne Räume können über die Targets aktiviert bzw. Deaktiviert werden: | + | Because of the behavior of HLS/DASH clients if a client fetches a playlist file and gets a redirect, all further requests go to the same origin. With this trick the clients stay persistently on one relay until they are redirected. |
| - | < | + | |
| - | sudo systemctl start transcode_s5.target | + | |
| - | sudo systemctl stop transcode_s1.target | + | |
| - | </ | + | |
| - | < | + | == Stream-URLs |
| - | === 3. Fanout | + | The resulting stream URLs are as follows |
| - | Diese 3 Format-Streams je Raum werden von der nächsten Stufe auf '' | + | |
| - | Dabei entstehen alle Kombinationen aus '' | + | HLS (H.264 multi-quality + multi-language) |
| + | * http://cdn.c3voc.de/ | ||
| - | Die Scripte dazu werden vom ansible aus folgenden Templates erzeugt werden: https://github.com/voc/cm/tree/master/ansible/roles/relay/files/fanout. | + | Moar HLS |
| + | * http:// | ||
| + | * http://cdn.c3voc.de/hls/@slug/translated-2_hd.m3u8 | ||
| + | * http://cdn.c3voc.de/hls/ | ||
| + | * http:// | ||
| + | * http:// | ||
| + | **Currently not active:** | ||
| - | Um einen Überblick über die deployten Fanout Skripte zu erhalten kann folgender Befehl verwendet werden: | + | MPEG-DASH (VPx multi-quality |
| - | + | * http:// | |
| - | < | + | |
| - | voc@live.ber: | + | |
| - | + | ||
| - | </ | + | |
| - | + | ||
| - | Die Pull-Quelle und das Push-Ziel sowie der Pfad unter dem die HLS/DASH-Schnipsel und Playlisten abgelegt werden ist über Group-Vars konfigurierbar: | + | |
| - | + | ||
| - | < | + | |
| - | + | ||
| - | * Youtube ist derzeit deaktiviert und wird üblicherweise nur für den Congress aktiviert. | + | |
| - | + | ||
| - | Das Transcoding und Fanout reagiert dynamisch auf die Konfiguration des Streams der vom encoder-cube gesendet wird. Fehlt die Slides-Spur oder die Translation-Spuren wird diese nicht in den Master-Playlists und Dash-Manifestd für Adaptives streaming angeboten. Dadurch kann von Event zu Event entschieden werden, ob der Einsatz der Slide-Spur bzw. von Translations sinn ergibt. Siehe dazu [[voctomix: | + | |
| - | + | ||
| - | === 4. Transport- und Master-Nodes | + | |
| - | Im Non-Congress Setup ist '' | + | |
| - | + | ||
| - | === 5. Edge-Nodes | + | |
| - | Die ganzjährigen Edge-Nodes lauten: | + | |
| - | * '' | + | |
| - | * '' | + | |
| - | * '' | + | |
| - | * '' | + | |
| - | * '' | + | |
| - | + | ||
| - | Diese pullen alle Icecast-Streams (Port :8000) – *nicht* die Icedist-Streams – von '' | + | |
| - | Für die schlussendliche Auslieferung kommt ein nginx zum Einsatz, der abhängig von der URL Daten von einem der unterschiedlichen Backend proxied: | + | |
| - | * Für Anfragen zu einem WebM, MP3 oder Opus-Stream (z.B: http:// | + | |
| - | * Für Anfragen nach HLS oder DASH-Schnipseln, | + | |
| - | + | ||
| - | == Teststream | + | |
| - | Für den Teststream < | + | |
| - | + | ||
| - | Alle bereitgestellten Test-URLs lauten | + | |
| - | + | ||
| - | VPx-HD: | + | |
| - | * http:// | + | |
| - | * http:// | + | |
| - | * http:// | + | |
| - | + | ||
| - | VPx-SD: | + | |
| - | * http:// | + | |
| - | * http:// | + | |
| - | * http:// | + | |
| - | + | ||
| - | VPx-Slides: | + | |
| - | * http:// | + | |
| - | * http:// | + | |
| - | * http:// | + | |
| - | + | ||
| - | h264-HD: | + | |
| - | * http:// | + | |
| - | * http:// | + | |
| - | * http:// | + | |
| - | + | ||
| - | h264-SD: | + | |
| - | * http:// | + | |
| - | * http:// | + | |
| - | * http:// | + | |
| - | + | ||
| - | h264-Slides: | + | |
| - | * http:// | + | |
| - | * http:// | + | |
| - | * http:// | + | |
| - | + | ||
| - | WebM Multi-Qualität | + | |
| - | * http:// | + | |
| Audio-MP3: | Audio-MP3: | ||
| - | * http:// | + | * http:// |
| - | * http:// | + | * http:// |
| - | * http:// | + | * http:// |
| Audio-Opus: | Audio-Opus: | ||
| - | * http:// | + | * http:// |
| - | * http:// | + | * http:// |
| - | * http:// | + | * http:// |
| - | + | == Dynamic SRT/RTMP endpoints with RTMP Auth | |
| - | === Vollständiges deaktivieren des Teststreams | + | SRT and RTMP Endpoints can be created under https://ingest.c3voc.de/backend/ (Password in keepass under ansible/ |
| - | auf '' | + | |
| - | < | + | |
| - | sudo systemctl stop transcode_sX.target | + | |
| - | sudo systemctl disable transcode_sX.target | + | |
| - | </code> | + | |
| - | + | ||
| - | auf '' | + | |
| - | < | + | |
| - | sudo systemctl stop fanout_sX.target | + | |
| - | sudo systemctl disable fanout_sX.target | + | |
| - | + | ||
| - | screen -rd source-for-teststream | + | |
| - | :quit | + | |
| - | </ | + | |
| - | == Loadbalancer | + | The RTMP-URL for the endpoint '' |
| - | Neben den Transport- und Edge-Relays gibt es noch zwei Loadbalancer: | + | |
| - | * '' | + | The SRT-URL would be : '' |
| - | * '' | + | |
| - | Diese sind sowohl für die Domains '' | + | == Future improvements |
| - | === streaming.media.ccc.de | + | The diagram below shows the envisioned architecture as of 2020. In the meantime many of the improvements have been integrated into the CDN. |
| - | Unter dieser Domain liefern beide LBs unabhängig von einander die [[:software: | + | Some more potential improvements are as follows: |
| + | * Dynamically adapting the streaming-website to the existence/ | ||
| + | * Building a live status dashboard which shows the current stream-> | ||
| + | * To gracefully shutdown a relay it could be instructed via consul KV to redirect all clients back to a load balancer while taking it out of the haproxy redirects. That way all clients would be redistributed to different relays. | ||
| + | * Build origin relay redundancy using dynamic upload client and relay upstream configuration. (Relay upstreams need to be sticky, because the HLS playlists generated on the origin relay are not deterministic) | ||
| + | * Use DNS rotation on ingest | ||
| + | * Finalize srtrelay meshing to allow pushed streams to be pulled from any ingest machine. | ||
| - | === cdn.c3voc.de | + | {{drawio> |
| - | Die Domain '' | + | |
| - | Der HAProxy verteilt dabei ausschließlich per Redirect, er proxied (entgegen seines Namens) nicht. | ||
| - | == RTMP Ingest | ||
| - | Für Spezialanwendungen (z.B. Cam-Only Streaming im Fritz-Studio) existieren die RTMP-Endpunkte '' | ||
| - | Die Push-Targets lauten '' | ||
| - | Achtung: Aufgrund der langen rtmp-Timeouts in ffmpeg kann es bis zu 40 Sekunden dauern, bis die Streams auftauchen und weitere 30 Sekunden, bis alle Formate zur Verfügung stehen. Keine Ungeduld. | ||