Skip to content


Ad Injector is no longer supported by the Flussonic Core team. Still, if you need it, you can install it with the flussonic-deprecated package only.

Ad Injector

Ad Injector for embedding commercials into stream


Download flussonic-deprecated package to work with Ad Injector using the following command:
apt install flussonic-deprecated.

Ad Injector is a Flussonic tool for inserting video ads into a video stream.

How does it work?

You set certain time segments (time slots) within the main stream for your ads to be broadcasted. So that at a certain point in time the main stream is interrupted by an advertisement of your choice. By the end of the time segment, defined to play the ad, the main stream will be resumed. Time slots and ad videos are defined within a schedule. One schedule can have as many time slots and ad videos as you wish.

It also allows you to view the number of playbacks and the number of unique playback sessions of a video ad.

Number of playbacks is a number of times an advertisement is being played during the stream.

Number of unique playback sessions is a number of times an advertisement is being watched by viewers.

Time (advertising) slot is a time segment within the stream for an advertisement playback.

You can add a schedule using API or with the help of Flussonic UI.

Setting up Ad Injector in the UI

To configure Ad Injector follow the steps below:

Step 1. Add the following line to the Plugins section of the configuration file (/etc/flussonic/flussonic.conf):

plugin ad_injector;

and then restart the Flussonic instance:

service flussonic restart

Step 2. Download videos with ads to the server into a VOD files directory. For details about VOD, see VOD settings.

Step 3. Open Flussonic UI and head to Config -> Ad Injector tab. Here you can find Ad Injector settings:

Ad Injector settings

Step 4. Create a schedule.

To do this, click Add schedule button in the Ad Schedules section. Enter the name of your schedule in the Schedule name field and click Add Schedule to save it. In the Ad Schedules section you will see a list of advertising schedules in the following format: Schedule: :

Advertising schedules

In the example above we created three schedules named example_schedule, another_schedule and new_schedule. To remove the schedule click the Remove button.

Step 5. Set your time slots.

To do this, click on your newly created schedule Schedule: to see the Time slots settings. Then click the Add slot button to edit the time slot:

Add time slot

Set the time (in UTC format: HH:MM:SS) in the From field and the duration (in seconds) in the Duration field for each slot:

Configuring time slot

In the example above schedule is set for two time slots: one starts at 12 PM (noon) and is played for 60 seconds and the second starts at 12:15 PM and lasts 15 seconds. To remove the slot click the Recycling bin button. You can add a new slot by clicking the Add slot button.

Step 6. Select videos for your advertising slots.

To add the video to the slot head to the Files section. Select a folder with the stored video files from Step 2. In the drop-down list check all the videos you want to be played within your ad schedule. Chosen video files will be displayed in the Filename field of the Schedule files section:

Video files for time slots

To remove a video from a schedule click the Remove button to the right of the file name or remove the tick from the checkbox to the left of the file name in the list.

Step 7. Configure priorities for added videos.

Set the "weight" (integer) in the Weight field of the Schedule files section to the right of the file name. The greater the "weight", the sooner this file will be played. If all weights are equal, the files will be played one by one. As each file is played, its "weight" is reduced by 1 and as soon as it reaches 0, weights are rolled back to their original values.


If duration of a video file is longer than corresponding slot duration, system skips this file and moves on to the next one to check whether it fits the time slot. This way system selects the next video according to its "weight" value.

If duration of a video file is shorter than corresponding slot duration, then this video is played and the next one in line starts. In case the remaining length of a time slot is too short to show the entire video file, it will be terminated prematurely and the main video stream will be resumed.

  1. Save your settings by clicking the Save button.


Any existing Ad Injector settings will be overwritten.

  1. Create a stream with the advertising schedule.

Stream can be created either by editing the config file /etc/flussonic/flussonic.conf or through Flussonic UI.

The source URL of such a stream will look as follows:


Given the advertising schedule example_schedule and some stream named channel1, let's configure our stream channel1_adv with ad injections:

stream channel1 {
    input udp://;
stream channel1_adv {
    input ad_injector://channel1/example_schedule;

Here are the examples of links to the ad video stream over various protocols:

  • RTMP: rtmp://SERVER-IP/static/channel1_adv

  • HLS: http://SERVER-IP/channel1_adv/index.m3u8


Ad Injector also allows you to view the ad playback statistics. You can find it in the Adverted streams section of the Ad Injector settings page. If a schedule is attached to a video stream, and it has been shown at least once, it will be displayed in this section under its name.

For each ad the number of unique playback sessions (views) and the number of playbackы (shows) is displayed:


Statistics is stored for one day only.

Now you know how to configure the Ad Injector.