Magic line when HLS video manifest is mixed with encrypted / unencrypted video chunks

CK CK 3788 
Created at
Updated at  
1,452 0 0

HLS (HTTP Live Streaming) is an adaptive streaming technology that uses widely supported HTTP protocols to deliver video and audio content to viewers. This makes it highly accessible and compatible across a vast range of devices and platforms. 
Here's a breakdown of why HLS is considered "widely supported":

  • HTTP: HLS relies on HTTP, which is the foundational protocol for the internet. Nearly all devices and platforms have built-in support for HTTP, making HLS readily accessible.
  • Common Formats: HLS uses standard media formats like MP4 and AAC, which are widely supported across devices and browsers.
  • Multiple Bitrates: HLS offers multiple bitrates for video and audio, allowing the stream to adapt to varying network conditions and device capabilities. This ensures smooth playback even with limited bandwidth.
  • Fragmentation: HLS breaks the video into small fragments, making it efficient for streaming and allowing for faster buffering and playback initiation.
  • Apple's Influence: Apple pioneered HLS, and its widespread adoption on iOS devices and Safari browsers has contributed to its popularity.

 

Secure HLS (HTTP Live Streaming) is widely used for secure streaming services. When mixing encrypted and unencrypted streams within the same HLS playlist, it's crucial to understand the implications and ensure proper implementation. 

Magic line when HLS video manifest is mixed with encrypted / unencrypted video chunks

This is crucial points when we service with Advertisement. We may have to mix both streams (encrypted/unencrypted):
1. Playlist Security:
- Secure Playlist: If your playlist is encrypted, it's generally considered best practice to encrypt all of the media segments within it. This ensures that the entire stream is protected.
- Unsecured Playlist: If your playlist is unencrypted, you cannot include encrypted media segments. This would create an inconsistent and potentially vulnerable stream.


2. Key Management:
- Encryption Key: For encrypted segments, you need a mechanism to manage the decryption key. This could involve server-side key management, or client-side key exchange using technologies like DRM (Digital Rights Management).


3. Stream Behavior:
- Switching Between Streams: If your stream starts with unencrypted segments and then transitions to encrypted segments, the player needs to be able to:
- Identify the switch: The player must recognize the shift in the playlist's content.
- Obtain the encryption key: If necessary, the player needs to acquire the decryption key to continue playback.
- Smooth Transition: The transition should be seamless for the user, avoiding any disruptions or buffering issues.


In terms of HLS Manifests we should keep in mind is EXT-X-KEY:METHOD right after EXT-X-DISCONTINUITY between transition:

 

The manifest should contain key information like below when switch from unencrypted to encrypted:

#EXTINF:5.000,ad0
plain_stream0009.ts
#EXT-X-DISCONTINUITY
#EXT-X-KEY:METHOD=AES-128,URI="https://foo.net/your_key.cgi?id=....",IV=0x0123456789abcdef0123456789abcdef
#EXTINF:5.000,
encrypted_stream0010.ts
#EXTINF:5.000,
encrypted_stream0011.ts
.
.
.


You should let player aware when switch from encrypted to unencrypted like below:

#EXTINF:5.000,ad0
encrypted_stream0009.ts
#EXTINF:5.000,ad0
encrypted_stream0010.ts
#EXTINF:5.000,ad0
encrypted_stream0011.ts
#EXT-X-DISCONTINUITY
#EXT-X-KEY:METHOD=NONE
#EXTINF:5.000,ad1
plain_stream0012.ts
#EXTINF:5.000,ad1
plain_stream0013.ts
.
.
.

 

 

Tags EXT-X-KEY EXT-X-KEY:METHOD Encrypted Video Chunk Secure HLS Unencrypted Video Chunk Facebook X
Comments 0
  1. Smooth switching with EXT-X-DISCONTINUITY in HLS
    426
  2. Disabling Audio Tracks in HLS.js
    371
  3. A Deep Dive Into Internet Advertising Ecosystem on Video Streaming Industry
    643
  4. When to use #EXT-X-DISCONTINUITY in HLS?
    1,423
  5. A prefect Apache server settings to avoid CORS error for HLS
    602
  6. CloudFront Settings for Dynamic HLS Streaming
    650
  7. SafeFrame is a web standard developed by IAB
    505
  8. CSAI vs SSAI
    574
  9. Ad Marker: SCTE-35 Message Encoder based in Python
    794
  10. Ad marker: SCTE-35 enhanced
    570
  11. FFmpeg compile options based on configure
    1,110
  12. Script checking internet restriction with FFmpeg
    678
  13. FFmpeg compile option to support SCTE-35
    837
  14. HTTP Proxy when your URL access is blocked with FFmpeg
    1,885
  15. Limit Maximum Resolution in HLS.js
    663
  16. Recovering a crashed HLS.js player
    1,274
  17. How do I create animated background for Google Meet?
    19,712
  18. Secure HLS encoding using AES-128 encryption with FFmpeg
    1,130
  19. Machine Learning Models for Ad Detection from a Video Stream
    185
  20. Unlock Flawless HLS Audio Sync: The Power of #EXT-X-INDEPENDENT-SEGMENTS
    372
  21. NVIDIA CUDA library which can be integrated with C/C++
    375
  22. Approaches to Scene Detection in Video Processing
    643
  23. FFmpeg CLI to remove audio track from MP4
    540
  24. Building GPU as a Service aka Dockerized GPU
    1,566
  25. IAB Categories (a.k.a. OpenRTB Code)
    1,012
  26. FFmpeg library that can be directly integrated into C/C++/Rust/Python without CLI
    2,056
  27. HTTP Live Streaming (HLS) was developed by Apple as part of QuickTime X in iOS3.0, and became an official standard (RFC 8126) in 2017
    593
  28. Progressive MP4 is an application of streaming techniques using the standardized MP4 container invented by MPEG LA consortium
    1,071
  29. FFmpeg CLI to mix two different audios in a single audio file such as mp3
    599
  30. FFmpeg CLI to merge a video only mp4 and mp3 audio file
    332
Recently updated
  1. Why 100% SEO Guarantees Better User Engagement and How to Achieve It in Your Service
    27
  2. Why SPF and DKIM Are Essential for Linux Email Servers?
    24
  3. How do I create animated background for Google Meet?
    19,712
  4. MaxMind GeoLite2 vs. DB-IP Lite vs. ip-api.com: Choosing the Right Free IP Geolocation Solution
    217
  5. Meet Valkey: Why Redis Changed Its License, Why Valkey is Better, and How to Use It as a Drop-in Replacement
    85
  6. How Rogue Web Scrapers Are Stealing My Content and Destroying My Server
    153
  7. Array of arguments passed to script in PHP
    85
  8. Invalid Auction Storms in Ad Tech
    93
  9. Building MRC-Compliant Instrumentation in Ad Tech: Implementation Steps and Key Challenges
    198
  10. The Two Clocks of Ad Server Architecture
    63
  11. Frequency Cap Architecture Overview
    509
  12. Collecting Proof-of-Play from 100,000 Screens
    141
  13. Vector Search in Relational Databases (RDBs): Trends & Usage Environments
    280
  14. What is RedisVL?
    105
  15. Designing a Skill Registry Architecture: Minimize Token Usage and Maximize AI Performance
    224
  16. TPU & GPU Cluster Management Tools
    232
  17. The Concept of Scaffolding in AI Agents
    221
  18. Beyond Static Pipelines: Architecting LLM Multi-Agent Systems for Autonomous Workflow Orchestration
    576
  19. AI-DLC vs. AI-SDLC: Model-Centric vs. System-Centric AI Development
    253
  20. Fine-Tuning Open-Weight LLMs: Training, Licensing, and Deploying Custom Models with Ollama
    327
  21. Inside the Next-Generation Streaming Architecture: Ultra-Low Latency, SGAI, and AI Codecs
    197
  22. Machine Learning: Training vs. Ranking
    213
  23. The Continuous Learning Machine: Designing a Loop That Actually Turns
    217
  24. The Next-Gen Low-Latency Standards: LL-HLS & MoQ
    189
  25. Designing a Data Curation System Around a Vector Database
    215
  26. Extracting Context from Live Video: The Architecture Got Simpler When We Stopped Building Features
    229
  27. The New Ad Stack Behind Live Sports Streaming: Inside SGAI, EABN, and the Standards Race to Fix Live Monetization
    649
  28. Designing MLOps Architectures to Handle Seasonal Data Drift in EV Fleet Models
    185
  29. From 15 to 40+ FPS: Accelerating PyTorch Object Detection on Automotive ECUs
    207
  30. Understanding Data Lineage
    252