Elixir for Live HLS Video Streaming: Architecture and Implementation at Tubi
The article recaps Tubi’s eighth Elixir Meetup, detailing Horvo’s presentation on building a live HLS video streaming backend with Elixir, covering the system’s transcoder, scheduler, HLS server, encryption, ad‑insertion strategies, and why Elixir was chosen for high‑performance backend services.
Tubi sponsored and organized the eighth Elixir Meetup, which attracted more than 660 online and offline functional‑programming enthusiasts. Three senior Elixir users—Horvo, Scott, and Yang Miao—shared their experiences, and the first talk reviewed was “Using Elixir to Develop an HLS Live Backend Service” presented by Tubi senior backend engineer Horvo.
As an online video‑content provider, Tubi offers a wide range of on‑demand movies, TV series, and live TV channels. To power this service, Tubi chose Elixir for its backend, and Horvo demonstrated how Elixir is applied in Tubi’s live streaming infrastructure.
Why HLS
HTTP Live Streaming (HLS) is a streaming protocol introduced by Apple in 2009. Because it runs over HTTP, it works well with most firewalls, can leverage global CDN infrastructure, and enjoys broad platform and device compatibility, making it a preferred choice over RTMP or MPEG‑DASH for Tubi’s live services.
Building Your Own Elixir TV
Horvo walked through the creation of an “Elixir TV” prototype from scratch, dividing the system into several components:
Transcoder – Accepts raw video files (e.g., MP4) and invokes FFmpeg commands to generate multi‑bitrate segments according to a predefined data schema.
Scheduler – The core module built with Elixir’s GenServer . It maintains a real‑time queue of video segments for each channel, periodically updates a sliding window of segments, and provides up‑to‑date playlists for live streaming.
HLS Server – Exposes three HTTP endpoints: GET /playlist.m3u8 → static master playlist GET /:variant/playlist.m3u8 → live variant playlist GET /:variant/:video_id/:media_segment_name.ts → serves individual segment files The first two endpoints allow clients to fetch playlists, while the third provides the actual media segments for playback.
Conclusion
With these modules, the Elixir TV prototype is functional, demonstrating how Elixir can orchestrate live streaming pipelines.
Videos Should Be Encrypted
To protect core video assets, three protection strategies were discussed:
Encrypt segment files with AES‑128.
Require authenticated access to the decryption keys.
Use higher‑level DRM solutions to prevent copying across devices.
Monetary Should Be Addressed
Following Tubi’s ad‑supported model, an Ad Insertion Service (SSAI) can insert personalized ads into the live playlist on the server side, avoiding client‑side ad blocking and enabling revenue generation.
Interactive Q&A
Horvo explained how SSAI creates per‑user media playlists, uses SCTE‑35 tags to mark ad breaks, and prevents client tampering by filtering out ad‑break markers before delivery.
Why Use Elixir?
Elixir inherits Ruby’s developer‑happiness philosophy (its creator Jose Valim was a Ruby core contributor) and offers excellent performance for high‑concurrency web servers, making it well‑suited for production‑grade streaming services.
Additional resources and links to past Elixir Meetups are provided for deeper exploration.
Bitu Technology
Bitu Technology is the registered company of Tubi's China team. We are engineers passionate about leveraging advanced technology to improve lives, and we hope to use this channel to connect and advance together.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.