Flussonic Media Server documentation

Contents

Advertisement Insertion

Description

Flussonic allows you to embed ads (commercials) in HLS sessions and configure the display of the ads through the authorization backend.

It is possible to specify a pre-roll video and set an interval for inserting mid-roll videos, and specify ads that are unique for each user/view.

Requirements

  • An advertising video must have the same set of audio and video tracks as the main stream, if the main stream has both audio and video tracks, the ad must have both audio and video tracks too.
  • An advertising video must have a GOP size equal to one second.
  • The first 1-5 seconds of the pre-roll video can be skipped, this is a feature of most HLS players. This can be solved only by inserting black frames into the beginning of the video.
  • Plugins such as AdBlock can block commercials. If something is not working, try disabling the plugins.

This mechanism of ad insertion is an extension of the authorization system, so please read about it first.

Warning! You must use files with advertisement videos that are located on the Flussonic server in configured VOD locations. Don't specify a path to the local file system or an HTTP resource. So it is necessary to create a VOD location and place the files in it.

Lua example

For launching advertising, the auth backend should return this structure:

user_ads = {["preroll"] = "vod/ad1.mp4", ["midroll_interval"] = 180, ["midroll"] = {"vod/ad2.mp4", "vod/ad3.mp4"}}
return true, {["ad_inject"] = user_ads}

Flussonic will show the file vod/ad1.mp4 as pre-roll and then will show mid-roll files every 3 minutes (180 seconds).

HTTP auth backend example

Example of PHP auth script for ad insertion:

<?php

header('Content-type: application/json');

$user_ads = [
    "preroll" => "vod/ad1.mp4",
    "midroll_interval" => 180,
    "midroll" => ["vod/ad2.mp4", "vod/ad3.mp4"]
];

echo json_encode(array("ad_inject" => $user_ads));
?>

Flussonic Media Server will show the file vod/ad1.mp4 as pre-roll and then will show mid-roll files every 3 minutes (180 seconds).