CDN integration

The CDN is easily intergated into you project. Before you start, please read the instructions below.

How CDN works

The primary purpose of our CDN is broadcasting / streaming video on your site and reducing Internet traffic costs.

You should do some very simple steps to start:

  1. Setup your project in CDN control panel
  2. Upload data to our cloud storage
  3. Configure CDN integration with your site
  4. install the player code on your website
  5. Enjoy the result

Project settings

Go to CDN control panel:

Settings→Projects→New

  • Name - the field for project name. It may be a URL or nickname of the project, for example tube. The name will be the FTP folder name where you will place your files. In the manual it can also be referred as ProjectName
  • Secret - create a unique secret code. We recommend the code length to be between 14 and 20 characters. In the manual it can also be referred as SecretKey
  • Storage group - оставляем как есть
  • Default - This option enables or disables the default project. If you already have a default project, this option should not be turned on. Before that, you need to disable the current default project.
  • Public - the option defines if this project is public or not. If the project is public, you can set additional security options of the project: by referrer
  • Protect by referrer - activates the protection by referrer for this project
  • Allow empty referrer - This option is useful when your users are watching video via mobile devices players. Below you can specify the allowed referrers for your project - domains which allowed to broadcast content of your project. You can add a few domains.
  • ID - In the upper right corner of the page there is the project ID. It is necessary to identify your project in the system. In the manual it can also be referred as ProjectID
  • When the settings are done - click Save at the top left corner

Integration with the player

Standard HTML5 player example is below:

HTML in the standard player example:

  <video controls="controls" width="640" height="480" poster="/cdn.php?path=/test/cinema.jpg&link=1">
      <source src="https://mentor.dfcdn.net?v=1&p=311989d4-4799-455e-a645-ca4899527504&f=%2Ftest%2Fx1080.mp4&e=1571113545&s=-120&sig=QSKjTsUfHYpzVNWMxVAuXKspvbBpTF%2FofRaZ7UPTtkM%3D&b=60&a=86400" type="video/mp4">
  </video>

CDN integration with KVS

CDN for Kernel Video Sharing (KVS) is configured very simply.

First of all you need to doproject settings

Then download 2 files:

to FTP of your site /admin/cdn на FTP вашего сайта

Next, go to the settings in the admin panel of the KVS: add a new server group and a storage server.

Configure the storage server in the following way:

  • Title: - Dragonfly
  • Server group: - выбирайте группу хранения, котрую Вы только что создали
  • URL: - http://dragonfly.cdn
  • Streaming type: - CDN
  • CDN control script: - dragonflycdn.php
  • Streaming key: - SecretKey;ProjectID;PreloadTime;SpeedLimit (example:5zpoHYdoCqAcxq;311989d4-4799-455e-a645-ca4899527504;30;-120 )
    SecretKey - take from project settings
    ProjectID - take from project settings
    PreloadTime - Video preload time in seconds before hitting the speed limit, if you set a negative value - percentage (example: 30 - this is 30 sec of preloading time or -30 - 30 percent)
    SpeedLimit - Limiting video broadcast in kbps, if you set a negative value - percentage (example: 320 - 320 kbps -120 - 120 percent relative to the video bit rate)
  • Connection type: - FTP
  • FTP host: - ftp.dfcdn.net
  • FTP port: - 21
  • FTP user: - see FTP access credentials, which were sent to you during the registration
  • FTP password - see FTP access credentials, which were sent to you during the registration
  • FTP folder: - /projects/ProjectName/files, ProjectName take from project settings
  • FTP timeout - 120

Save the server configuration. Add or migrate new video to the storage server via KVS.

PHP library

Download PHP-library for working with the CDN dragonfly.php and save it to the root folder of your website

Variables that are used in library functions and their usage.

  • $SecretKey - SecretKey of your project. For example: 5zpoHYdoCqAcxq
  • $ProjectID - $ProjectID of your project. For example: 311989d4-4799-455e-a645-ca4899527504
  • $burst - Video preload time in seconds before hitting the speed limit, if you set a negative value - percentage. Example: 30 - this is 30 sec of preloading time or -30 - 30 percent
  • $SpeedLimit - Limiting video broadcast in kbps, if you set a negative value - percentage. Example: 320 - 320 kbps -120 - 120 percent relative to the video bit rate
  • $secondsTTL - Link lifetime in seconds. Example: 600 - 600 seconds or 10 minutes; 60 * 60 * 2 - 2 hours
  • $maxAge - Sets the value of a HTTP-header Expires. Example: 86400 - a day, 1d; 60 * 60 * 24 * 7 - A week, 7d, 1w. For the ease of perception
  • $downloadFn - Sets the value of a HTTP-header filename. Example: out.pdf - the downloaded file will be named out.pdf false - empty field and the file will be broadcasted
  • $fileId (by Path) - path to the file relative to the root folder of the CDN (/projects/ProjectName/files) project CDN. Example: set the value 100/10/11.mp4 and receive files: /projects/tube/files/100/10/11.mp4. Also, this value is an ExtID of an element
  • $fileId (by UID) - for some functions, this variable is the UUID of the file in the system, and it has a unique value. The system works with these functions in order of magnitude faster. This value can be got in the CDN control panel - ID column

Is the most common example of integration and video link creation is below:

    <?php
    	require_once 'dragonfly.php';
    	$file_name = $_GET['path'];
    	$dragonfly = new Dragonfly("//mentor.dfcdn.net", "5zpoHYdoCqAcxq");
    	$link = $dragonfly->getUrlByExtId("311989d4-4799-455e-a645-ca4899527504", $file_name, 30, -110, 60 * 60 * 2, 0, $download);
    	header('Location: ' . $link );
    ?>

Functions of the dragonfly.php library:

  • getUrlByExtId($projectId, $fileId, $burst, $speedLimit, $secondsTTL, $maxAge, $downloadFn) - generates a URL with a limited lifetime by filename $fileId (by Path)
  • getUrl($fileId, $burst, $speedLimit, $secondsTTL, $maxAge, $downloadFn) - generates a URL with a limited lifetime by filename $fileId (by UID)
  • getPermanentUrlByExtId($projectId, $fileId, $burst, $speedLimit, $maxAge, $downloadFn) - generates permanent URL by the file name $fileId (by Path)
  • getPermanentUrl($fileId, $burst, $speedLimit, $maxAge, $downloadFn) - generates permanent URL by the file name $fileId (by UID)

We have tried to use the advanced functionality in a very convenient form but if you will need extra features, you can always contact us and we will implement it

Cloud storage

The letter that you received after signing up has you FTP access credentials.
That is the most convinient way to store your file on the CDN

  • There may be slight delays at the end of file uploads when the FTP access method is used. During that time the system distributes and stabilized data in the cluster storage. That is a normal behaviour.
  • There is no FTP server, there is a clustered FTP service which can be scaled infinitely. Currently we can scale it up to 40Gbps of upload bandwidth.
  • The size of our storage is also not limieted by the system. Currently we can increase our storage up to 18 exabytes (1 Ebayt = 1000 PB)
  • We keep at least 2 copies of each file on different nodes - this ensures maximum safety of your data.