Flussonic Media Server documentation


Viewing video from cameras on external websites

In Flussonic Media Server, you can view video streams not only in its web interface, but also on external websites. A special page embed.html is used for this purpose.

Flussonic Watcher has a similar feature. Watcher API allows generating a link for the player that you can then use for integration of Watcher with external web pages such as a corporate website or the user's account. A link can be to a live stream, to the stream's archive or to a specified part in the archive.

This section will tell you how to embed video from IP cameras in Watcher to a webpage outside Watcher, including:

  • forming a link to a video
  • different types of links (live, archive, part of an archive)
  • ways to use the link and parameters that you can add to the URL (see in the documentation of Flussonic Media Server)

Getting the URL for embedding video to a website

You will need to generate a token that will be used in a special URL for accessing video. We recommend creating a dedicated Watcher user to get the token. A session ID and token are requested by using the Watcher API v2. A token is effective until the user's password is changed.

Then you can generate the URL. See examples of scripts after the description of the sequence of steps.

To create a link for embedding video to a webpage:

  1. Create a user that will be used to generate a token for accessing a camera. For example, let's create the user webuser and add it to your Organization.

    Create a Watcher user in Organization

  2. Give this user permissions to manage cameras in an Organization. These cameras must be the ones that you want to display on an external website.

    In the user properties, on the Access to cameras tab, click the camera icon next to the folder that you want to give the user access to.

    User permissions to Watcher folders

  3. Get the session ID for this user. Use the following API v2 call:

    curl http://watcher-ip/vsaas/api/v2/auth/login -H 'Content-Type: application/json' --data-binary '{"login":"admin_temp", "password":"admin_temp"}'

    The server's response looks like the following:

    "groups_count": 0,
    "notification_email": null,
    "session": "Z-aCeqoKapk-DhfnqSGEOI5kVT0",
    "is_admin": true,
    "login": "webuser"

    Details about /api/v2/auth/login

    You'll need to copy "session": "Z-aCeqoKapk-DhfnqSGEOI5kVT0" from the response.

  4. Get cameras available for the created user:

    curl http://WATCHER-IP/vsaas/api/v2/cameras/ -H "x-vsaas-session:Z-aCeqoKapk-DhfnqSGEOI5kVT0"

    Alternatively, if you need only certain cameras, get them by their names:

    curl http://WATCHER-IP/vsaas/api/v2/cameras/CAMERA_NAME -H "x-vsaas-session:Z-aCeqoKapk-DhfnqSGEOI5kVT"

    The server's response looks like the following:

    'stream_url': 'fake://fake',
    'playback_config': {'token': 'WyIxMzgzIiwyXQ.DrEHcw.h7RL4o83OSbFMrW-wMWJXcdXfgU'},
    'dvr_path': None,
    'title': 'test',
    'substream_url': '',
    'agent_id': None,
    'access': 'private',
    'static': True,
    'onvif_url': None,
    'agent_serial': None,
    'agent_status': None,
    'external_id': None,
    'groups': [],
    'owner': 'tst',
    'agent_model': None,
    'comment': '',
    'user_attributes': {},
    'dvr_space': None,
    'coordinates': '37.768665 55.652579',
    'enabled': True,
    'server': 'WATCHER-IP',
    'postal_address': '',
    'thumbnails': True,
    'permissions': {'dvr': None, 'ptz': False, 'edit': True, 'view': True},
    'dvr_depth': None,
    'stream_status': {'lifetime': 1963704,
    'source_error': None,
    'alive': True,
    'https_port': None,
    'http_port': None,
    'bitrate': 183,
    'rtmp_port': 1935,
    'rtsp_port': 8554,
    'server': 'WATCHER-IP'},
    'onvif_profile': None,
    'name': 'CAMERA_NAME',
    'dvr_protected': False,
    'thumbnails_url': None,
    'onvif_ptz': False,
    'agent_key': None}

    You'll need server, name, and token.

  5. Use the values of server, name, and token to form a URL for accessing the camera through embed.html. An example of such a URL:


Scripts for getting the URL to embed a camera to websites

After you create a dedicated user (webuser in the procedure above), you can run the following script that takes the login and password as input data and returns for each camera the code for embedding it to a web page.

Python script for creating RTSP URL with output in Linux CLI

import os
import sys
import requests

server = sys.argv[1]
s = server.split('//')
path = ''
file = str(path) + s[1] + '.txt'

sysargv_auth = {"login": sys.argv[2], "password": sys.argv[3]}

url = sys.argv[1] + '/vsaas/api/v2/'

print(url, sysargv_auth)

def get_session():
    r = requests.post(url + 'auth/login', json=sysargv_auth)
    if r.status_code == 200:
        session_id = r.json()['session']
        file_auth = open(file, 'w+')
        return session_id
        print('Get session: delete file')

def get_cams():

    if os.path.isfile(file):
        print('Is file')
        file_auth = open(file, 'r')
        session_id = file_auth.read()
        print('no file')
        session_id = get_session()

    headers = {'x-vsaas-session': session_id, 'X-Page-Limit':'99'}

    r = requests.get(url + 'cameras', headers=headers)

    if r.status_code == 403:

    cam_list = 'link\n'

    for el in r.json():
        if el['stream_status']['server']:
            server = str(el['stream_status']['server'])
            link = 'rtsp://' + server + ':554/' + el['name'] + '?token=' + el['playback_config']['token']
            server = 'null'
            link = 'null'
        cam_list += link + '\n'

    return cam_list


PHP script for creating an HTTP URL to insert a camera to a website


$server = $_GET["server"];

$auth = [ 'login' => $_GET['login'], 'password' => $_GET['pass']]; // 1 line instead of 3

if(empty($server)) {
        echo "The server address and auth data not provided";
        header('HTTP/1.0 204 No Content');
        error_log('No server address provided', 4);

$options = array(
  'http' => array(
    'method'  => 'POST',
    'content' => json_encode( $auth ),
    'header'=>  'Content-Type: application/json'

$context  = stream_context_create( $options );
$result = file_get_contents( "http://$server/vsaas/api/v2/auth/login", false, $context );
$response = json_decode($result, true);
$session = $response['session'];

$get_cams = array(
        'http' => array(
                'method' => 'GET',
                'header' => 'Content-Type: application/json',
                'header' => "x-vsaas-session: $session"
        'header' => 'x-page-limit: 99'

$context_cam = stream_context_create($get_cams);
$result_cam = file_get_contents("http://$server/vsaas/api/v2/cameras", false, $context_cam);
$resp_cam = json_decode($result_cam, true);

foreach($resp_cam as $key => $cam) {
        $cam_token = $cam['playback_config']['token'];
        $cams_url[] = "http://" .$cam['stream_status']['server']. '/' .$cam['name']."/embed.html?token=$cam_token";

foreach($cams_url as $url){
        echo "<iframe style=\"width:640px; height:480px;\" allowfullscreen src=\"$url\"></iframe>";

Examples of URLs for embedding video to websites

The example uses a camera named CAMERA_NAME. Time should be specified in Unix Timestamp.

Live video with low latency:


Live video with low latency with controls to view the DVR archive:


DVR archive starting from the specified time: