Flipboard Blog

Advanced SSAI and HLS Manifest Manipulation for Dynamic Ad Insertion

HTTP Live Streaming (HLS) and Over-the-Top (OTT) technologies offer unprecedented flexibility in delivering video content. One of their most underutilized advantages is the ability to manipulate manifests in real-time, allowing for the modification of audio and video segments before they reach the viewer. This opens up various opportunities, particularly in personalized ad insertion, content transformation, and dynamic overlays. Having worked on solutions specializing in L-shaped, overlay, and Picture-in-Picture (PiP) ads, I’ve seen firsthand how these techniques can be leveraged for monetization and enhanced viewer experiences.

Understanding Manifest Manipulation


HLS streaming relies on manifests (M3U8 playlists) that direct the player to the appropriate media segments. By intercepting and modifying these manifests, it’s possible to:
  • Transcode video and audio segments on-the-fly.
  • Inject targeted advertisements at predetermined intervals.
  • Overlay graphical elements like L-shaped ads or PiP content.
  • Adapt content dynamically based on network conditions or viewer preferences.

Ad Insertion and Content Modification


One of the most effective applications of manifest manipulation is server-side ad insertion (SSAI). Unlike client-side methods, where ads are requested separately, SSAI allows for seamless integration within the media stream, making it indistinguishable from the main content. This approach avoids ad blockers and improves viewer retention.

Some key methods include


  • Segment SplicingReplacing specific video/audio segments with ad content.
  • Transcoding on Demand: Adjusting bitrate and format in real-time to optimize playback across devices.
  • Metadata Injection: Embedding additional markers or triggers for interactive elements.

Technical Challenges: Understanding GOP, PTS, FFmpeg, and SCTE-35 Markers


Achieving seamless manipulation of video segments requires an in-depth understanding of Group of Pictures (GOP), Presentation Timestamp (PTS), SCTE-35 markers, segment duration, media sequencing, and the role of the packager. These elements are crucial in maintaining smooth playback and synchronization while minimizing processing time.
  • GOP Structure: Ensuring ad segments align with the original stream’s GOP structure prevents playback glitches and excessive re-encoding. A consistent GOP structure allows for frame-accurate ad insertion without unnecessary transcoding.
  • PTS Handling: Correctly managing PTS ensures seamless transitions between modified and original segments, avoiding lip-sync issues and playback artifacts.
  • FFmpeg Optimization: Leveraging FFmpeg’s parameters (e.g., `-copyts`, and `-map`) enables efficient processing while maintaining segment compatibility with the HLS manifest.
  • SCTE-35 Markers: These markers are critical for ad signaling in live and VOD streams. Proper insertion and recognition of SCTE-35 cues ensure that ad breaks align correctly with playback, enabling frame-accurate ad switching.
  • Segment Duration: Maintaining consistent segment duration is essential for smooth playback. If segment lengths vary too much, buffering issues may occur, especially in live streaming environments.
  • Media Sequence Handling: Ensuring media sequence numbers remain accurate is critical for avoiding desynchronization issues when modifying manifests on the fly.
  • Packager Considerations: The role of the packager (e.g., Apple’s Media Stream Segmenter, FFmpeg, or commercial solutions) is crucial in ensuring segment integrity and optimizing playback performance.


Frame-Accurate Transcoding and Optimization


For high-quality content insertion and minimal latency, frame accuracy is a crucial consideration. Ensuring frame-accurate splicing requires:
  • I/IDR Frames at Segment Boundaries: Ensuring that each segment starts with an I-frame or an IDR frame is essential to prevent decoding issues and allow smooth ad insertion.
  • Low-Latency Processing: Optimizing encoding settings such as hardware acceleration (e.g., NVENC, QuickSync, or Apple VideoToolbox) minimizes processing overhead while maintaining visual quality.
  • Segment Alignment: Avoiding excessive re-encoding by aligning inserted content with the source material’s codec and bitrate helps reduce playback issues and optimizes CDN caching efficiency.


Use Case: Non-Intrusive L-Shaped, Overlay, and PiP Ads


For a project specializing in L-shaped, overlay, and PiP ads, we utilized manifest manipulation to dynamically introduce these elements without altering the original stream. Non-intrusive ad formats are particularly effective because they keep the main content visible while displaying ads in the periphery, reducing user frustration and maintaining engagement. By modifying segment references, we were able to:
- Insert non-intrusive graphical ads that overlay without disrupting content.
- Scale and position elements dynamically based on screen resolution.
- Synchronize PiP elements with live content, maintaining an engaging experience.
- Ensure that ads do not interrupt or replace key moments of the content, leading to better viewer retention and higher ad impressions.

Technical Considerations


Implementing manifest manipulation requires careful handling to ensure smooth playback:
- Latency Management: Since modifications introduce a slight delay, optimizing processing times is crucial.
- Cache Handling: CDN caching must be accounted for to avoid unintended ad repetition.
- Player Compatibility: Not all HLS players support advanced metadata or dynamic manifest updates equally.

Advanced SSAI and HLS manifest manipulation offer powerful capabilities for content personalization and monetization. Whether through SSAI, segment modification, or interactive overlays, these techniques provide new revenue opportunities and richer user experiences. As streaming evolves, leveraging these methods will become a key differentiator for platforms looking to enhance engagement while maximizing ad revenue.

For those looking to implement similar strategies, careful planning around latency, caching, player behavior, encoding optimization, SCTE-35 handling, frame accuracy, segment duration, media sequence tracking, and packager configuration is essential to ensure seamless integration into live or on-demand streaming workflows.

Get your own TV channel on iOS, Android, Roku, Fire TV and Connected TV like this one easily

Multiple, automated, AI-assisted 24/7 TV Channels from your content

Cars and Roads - Brands (https://ireplay.tv/carsandroads/brands.m3u8)

A portion of iReplay.TV's revenues, specifically 1%, is being allocated towards funding research and providing assistance for children's cancer treatment at Gustave Roussy Institute
Learn more about Gustave Roussy cancer Institute