Flussonic Media Server documentation

Contents

The Dynafile Plugin

Flussonic Media Server can transcode VOD content on the fly by using the dynafile plugin. This plugin starts the transcoder when a file is requested. The plugin allows overlaying a unique per-user watermark on top of video content. This feature can be used, for example, to determine the source of a content leak.

We recommend using the plugin with caution because such transcoding is very resource-consuming operation and it can create unpredictable loads on the CPU. A better way is to prepare (transcode) video beforehand and then deliver it.

Setting up the plugin

The plugin is disabled by default, and must be activated through the configuration file. Open /etc/flussonic/flussonic.conf and add the entry:

plugin dynafile {
  cache /tmp/dynacache 2G;
  transcoder vb=2048k size=1280x720 vb=600k size=360x-1 hw=nvenc;
}

In the above configuration, all VOD files will be transcoded into two profiles, using NVENC hardware acceleration. You must also specify a cache directory with the cache directive.

Learn more about transcoder options.

Important! The dynafile plugin enables transcoding of video files in every VOD location. You cannot configure transcoding for specific directories.

To view the video through the plugin, add /dynafile/ to the file's URL:

  • http://FLUSSONIC-IP/vod/bunny.mp4/embed.html — viewing a VOD file directly, without on-the-fly transcoding.
  • http://FLUSSONIC-IP/dynafile/vod/bunny.mp4/embed.html — viewing a VOD file transcoded by the dynafile plugin.

Overlaying a watermark

Flussonic Media Server can overlay a unique, per-user watermark (logo) on a video stream. The watermark can contain a client ID and IP address - such a watermark must be created in an external system, Flussonic does not create it.

Now configure in Flussonic an authorization backend so that it returns PNG images in the base64 format. Below is a lua backend script that requests a watermark from an external system and passes it to the transcoder:

prepare = function(key)

  name = string.gsub(req.name, "vod/", "")
  qs = {ip = req.ip, token = req.token, name = name, resolution = key}
  url = "http://example.com/getWatermark?"..http.qs_encode(qs)
  response = http.get(url, 10000)

  if not (response.code == 200) then
    return false,{code = response.code}
  end

  png = base64.decode(response.body)
  -- path = "/tmp/"..crypto.sha1(key..name..request.token)..".png"
  return png
end

extra = {}

string.gsub(req.sizes, "([^,]+)", function(w) extra[w] = prepare(w) end)

flussonic.log(table.tostring(req))
return true,{extra = extra}

Save this file as /etc/flussonic/dynafile.lua and configure Flussonic Media Server to use the new authorization backend:

file vod {
  path /storage/vod;
  cache /tmp/cache 10G;
  auth /etc/flussonic/dynafile.lua;
}
plugin dynafile {
  cache /tmp/dynacache 2G;
  transcoder vb=2048k size=1280x720 vb=600k size=360x-1 hw=nvenc;
}