Author Archives: Vibhav Sinha

Import videos from

We have just added support for imports. If you can upload your videos to, you can import videos directly from

Steps to Import Videos from Box.Com

  1. In your dashboard, go to Import from and choose “Add from Box”. This will open a new pop-up window on
  2. You should be able to choose your video file by selecting the check box. You can select multiple files at the same time.
  3. On clicking choose, we shall take up the list of videos and add it to your dashboard. The video will come with Queued status at the beginning.
  4. You can have a cup of coffee now.
  5. Return in some time and your videos will be ready. You can now embed these videos in your website or mobile app. Click here to read more on embedding options and how our secure embed code makes it impossible somebody to grab the embed URL. If your videos are on Amazon S3 you can import directly to VdoCipher dashboard using these instructions.

VdoCipher import videos from pop window screenshot

VdoCipher import from select from box file picker screenshot

Set IP Geo restriction on videos via API/Dashboard: VdoCipher DRM

VdoCipher provides a complete DRM with encryption, backend licensing and viewer specific watermarking to safeguard video content. Sometimes owing to the rights and permissions to distribute a video, businesses look to white-list or blacklist content for certain geographies & IPs. Here is an API guide to do IP & Geo restriction for your VdoCipher account. This should allow you to configure any complicated setting of IP and country restrictions.

Rules are defined by a JSON string called rule-set. This JSON contains an array of rule objects:

  1. Every rule is an object containing action, ipSet and countrySet
  2. Each matching rule overrides the previous matching rule.
  3. Action can be either ‘true’ or ‘false’, whether to allow or deny
  4. ipSet and countrySet are string arrays.
  5. Subnet CIDR block can also be set in ipSet string array.
  6. Both IPv4 and IPv6 addresses and subnet are allowed
  7. countrySet has two-digit country codes (ISO 3166-1 alpha-2.).
  8. Empty set matches everything of that type.
    "action": "false",
    "ipSet": ["", "49.323.23.56"],
    "countrySet": []
    "action": "true",
    "ipSet": [],
    "countrySet": ["IN", "GB"]

The first part of above code will block your videos from playing in the mentioned IP addresses. The second part of the code will allow the video to play only in countries – UK & India. As mentioned in point 2 , the second rules is the dominant one for common users. Thus as an example, if some user has IP – 49.323.23.56 and resides in UK, his videos will not play. So various combination of codes can be used to create custom restrictions. If there is any confusion, drop us a mail and we can provide sample codes.

Benefit of subnet restriction is that you don’t have to write specifically multiple IP addresses. You can configure it to restrict a group of IPs under subnet.

API for setting IP-Geo restriction is the same as the video update API as provided in docs.

Here is a sample HTTP Request:

Content-Type: application/json'
Accept: application/json
Authorization: Apisecret ____________

  "ipGeoRules": "string_containing_json_encoded_ruleset"

Dashboard interface for IP & GEO restriction

*This feature is also present in dashboard. Please click on the top right circular button on any video to open video settings. In it, there will be an IP/geo restriction section. Using above documentation, you can add any restriction.

Let us know at for queries & doubts.

IP & Geo Restrict Video DRM

Import videos from S3 bucket with “Import from AWS S3”

Import videos directly from Amazon S3 bucket to VdoCipher for secure video hosting

Import videos directly from Amazon S3 bucket to VdoCipher for secure video hosting

AWS is the most popular cloud service provider at the moment and a lot of our customers have their videos stored in their S3 bucket. Their usual method of import was to generate temporary download URL and using them to import videos. This usually involved a bit of programming to AWS S3 API. With this new feature, we plan to make import videos from S3 to VdoCipher process a lot easier.

Steps to import videos from S3 Bucket

Import from AWS S3 for Secure Video Streaming

Interface for Importing video from AWS S3 Bucket for secure video hosting

  1. You need to create a new IAM user in your AWS account with the permission to do action ListObjects and GetObjects in the desired bucket. AWS IAM console will give you the aws_access_key_id and aws_secret_key.
  2. In your VdoCipher dashboard, click on import and chose the option to “import from S3”.
  3. You can enter the region, bucket, key_id, and secret_key. Upon connecting, you will see a list of your root objects and you can navigate around like a regular file browser.
  4. On clicking the import button, our backend will create temporary download URL for the video object and add it to your list of videos. You will be able to see the video id and current status.
  5. Once you have the videos imported, you can go back to the dashboard to set correct title, description, and tags for the video. Adding tags is recommended because it helps to sort and manage your videos. The files should now be processing. Give the video some time to process. Once their status is ready, you can embed it in your website or mobile app.

Any file with video extensions will have an import button. Currently, we support five extensions (MP4, AVI, FLV, WMV, MOV). Let us know, if you like to have another file extension in this list. learn more about using the dashboard

Permission required for IAM key

AWS recommends creating a new IAM user for every purpose. In this case, you should create a new user with permission to ListBucket and GetObject. Here is a sample policy file that you can use for this purpose. Replace the NAME_OF_BUCKET with the real name of your bucket.

Find details on importing videos from

Details on importing from other video hosting services and from cloud video hosting providers can be found here

Auto play, Loop Video, Time Calculation, Custom Video Player

Many a times, video streaming sites look to autoplay the video through the video player as soon as the page is loaded. Also, you may wish to loop the media in the video player and present the content again and again to the same viewer. It is generally desired that the bandwidth does not get consumed again on the same page when a video is repeated.

Some of you may want to hide player skin or use custom colors and controls for the video player. Certain times, you will need to get total time viewed by each viewer for each video to put certain restrictions on the user.

VdoCipher along with secure video streaming aims to give a complete suite to our customers to make a custom player. Here are the details for the following functionalities. Do check our embed api first to see how to embed videos.

  1. Autoplay in video player

    Here is the code –

    window.onVdoCipherAPIReady = function(){
       var videos = vdo.getObjects(); // use global variable vdo to query
       var video = videos[videos.length - 1];
       video.addEventListener('loaded', function(){
           video.start(); // set video to autoplay

    Just add this to your HTML will cause the video to autoplay

  2. Loop Video in player – Replay the video when it reaches end

    window.onVdoCipherAPIReady = function(){
       var videos = vdo.getObjects(); // use global variable vdo to query
       var video = videos[videos.length - 1];
       video.addEventListener('end', function(){
  3. Time Calculation per video playback

<div id="vdo<?= $OTP ?>" style="height: 300px; width: 520px;"></div>
<input type="text" id="totalPlayed" value="" />

/// this is the embed code

    (function(v,i,d,e,o){v[o]={}; v[o].a = v[o].a || function V(a){ (v[o].d=v[o].d||[]).push(a);};
    if(!v[o].l) { v[o].l=1*new Date(); a=i.createElement(d), m=i.getElementsByTagName(d)[0];
    a.async=1; a.src=e; m.parentNode.insertBefore(a,m);}
        o: "<?= $OTP ?>",

/// this is the script

function onVdoCipherAPIReady(){
    console.log("VdoCipher API init");
    var videoObjects = vdo.getObjects();
    var video_ = videoObjects[0];
    video_.addEventListener("ready", function(data){
        console.log("ready event called" , data);
    video_.addEventListener("progress", function(data){
        document.getElementById('totalPlayed').value = data.totalPlayed;

Note: Make sure you are using the latest embed script in your code as described at

4. Some useful player events to capture

Returns the complete list of vdocipher videos ever loaded on page

var videoObjects = vdo.getObjects();

Go the proper index. In most cases, the last embedded video is required

var video_ = videoObjects[videoObjects.length -1];

Pause and Resume

video_.pause()               // pause
video_.resume()              // resume
Listening to events:
To get the start of a video –
var videos = window.vdo.getObjects();
var video = videos[videos.length - 1]; // use the last added video
video.addEventListener('start', function() {
    console.log('video has started');
Similarly. replace ‘start’ in the above code for the below events for –
  • “end”
  • “start”
  • “resume”
  • “pause”
  • “mute”
  • “unmute”
  • “changeVolume”

5. Custom Video Player – Beta Feature

This is the link to custom video player – the colors, controls, themes, call to actions on the video player all can be customized.

For a free full version 5GB  secure video streaming, custom video player trial, Sign up at VdoCipher.


Custom Video Player

Custom Video Player – Autoplay, Loop video

Where does VdoCipher DRM video fit in your tech stack.

Traditional Video integration

In case of most media integration, a static media URL is sent to the client. The client can use this to begin playing media. A client in this case can be either a web app or a mobile/tv application. The data to provided to the client is a long-lived url which can be used multiple times.

DRM video integration

When you are working with premium content, a requirement for secure video hosting is that you give only a one-time usable resource. This URL to DRM video should be generated only when the client is authenticated and has the permission to get access to the file. Only the server component has the authority to generate this temporary resource access.

DRM Video for Secure Video Hosting

Workflow for DRM videos

In case of Vdocipher, the temporary access URL is the otp while the authority to generate this OTP is the api secret key.

The API secret key must never be shipped along with the app code. The app SDK just needs an OTP for playback. Hence, the right way of doing this is to create an API endpoint as part of the app backend that you already have. This API endpoint should receive an authenticated HTTP request for playing a video (assuming you are authenticating users by some means such as login, etc.) and respond with an OTP. It is the backend system which should be responsible for making API calls. The viewer simply asks to play a particular video. This is followed by an access check on your web server. Your web server then takes the VdoCipher id for that video, and calls for OTP on the VdoCipher API.

A workflow in this case will be:
1. Client logs in and has an auth token for your backend framework
2. Client requests to play that hot new video.
3. Your Backend translates that hot new video into the corresponding VdoCipher id
4. Your Backend makes the API call to Vdocipher to get an otp.
5. Your Backend responds to the request with OTP
6. Client uses this OTP to play the video.

Setting desired bitrate for video playback for multiple devices

Different devices and internet speeds require different bitrate to be served. Based on device type and your viewer connection, some of you may opt to provide particular bitrates forcefully.  Often you like to provide playback at the certain quality or constrain the network data. Bitrate, Dimensions ,Quality thus can be configured. Below are the steps.

First, Send in an extra parameter while setting up the otp. Append a post parameter called “forcedBitrate”. This need to be an integer. During load time, the player obtains the list of available resolutions from the server. If the forcedBitrate is set, it starts playing the bitrate which is closest to that one.


If you have a video with bitrates created at [300, 900, 1500, 2100].  By default, the player will try to guess the correct bitrate based on a number of factors. If you believe that the default rate should be 900, set the value of forcedBitrate to 900. If the forcedBitrate is set to 1100, then player will calculate the bitrate closest to it and play it. This will ensure that the player will continue playing inspire of any error.

Here is a sample curl command for the otp call with forcedBitrate included:

curl '' -H 'Content-Type: application/x-www-form-urlencoded' --data 'clientSecretKey=CLIENT_SECRET_KEY&forcedBitrate=1100'

Check the Api page under /otp for more info and other APIs. C# web forms embed vdocipher video

The following code is the complete set up for embedding video in ASP.NET Web forms using vdocipher secure streaming. This code has been generated using Visual Studio Community 2015.

For the MVC implementation, please check:

For  vbscript implementation of aspx, check this:

Vdocipher video in aspx and aspx.cs files:

Do not save API Secret in the code

API secret is a key which gives your website authority to generate access tokens (OTPs) for video playback. This secret key can also be used to upload, delete videos in your vdocipher account. Hence, it should not be hard-coded in the application. It should be kept as an app secret. In the above example, it has been added to the web.config file which is not the recommended method. Please read this official article on best practices of saving secret keys in ASP.NET.

Complete code

Download the complete sample application from the Github.

Adding watermark to the videos

Watermark can be added when generating the OTP in the controller file. Please read this article on structuring your watermark and a sample code. The watermark has to be URLencoded and sent as a post data. You shall need to change around line 33 to send annotation information. Let us know if you find any trouble with the watermark setup.

A note about caching

OTP generated here is temporary. You can not cache this OTP and send it to multiple users as it might cause trouble. The OTP once used gets expired and can no longer be used to play video. Some extensions might try to automate the page rendering and especially when on pages which do not need login. The configuration must be set to make sure pages with embedded videos are not cached and cause error while playback.

vdocipher api illustration

For reference about how everything works, please check API reference.

Do let us know about your experiences setting up your secure video in to create your own PPV or subscription-based video portal. and how we can make the integration simpler.

PHP sample video upload from browser to VdoCipher

[This article is based on API v2 as document here.]

The Upload API workflow and overview can be found here.

Please find below a sample code for enabling video upload from your PHP website’s users. Note that this is sample code and you will need to configure it according to the controller-view structure in your application. It is not a recommended to put Controller logic and HTML output in a single file.

When setting up your front-end, you will like to enable better interface with AJAX upload such that your user’s can have a seamless experience. For this it is recommended to use one of the available libraries(angularjs, jquery or standalone, etc.) . Note that all these can be modified to be used in this set up. You can also see a sample implementation of the angular’s ng-file-upload library in your vdocipher dashboard itself.

Drupal module to embed vdocipher videos

Your videos on vdocipher are protected and can only be played when generating an access token for each video view. This access token needs to be generated securely in your website backend. The Drupal module does this thing in your Drupal website without getting your hands dirty in API programming.  With this module you can add videos inside any text field in content_type in your Drupal website.

The module uses a shortcode like syntax to parse and display videos inside any node such as an article or a page or a custom content type. The markup of the content body is processed and the shortcode syntax is replaced with the player code.

Download here

  1. Download the module file from the link above.
  2. Upload the module file from the install new module page in your Drupal “install new module” page.
  3. Enable the uploaded module.
  4. Click on the configure link in the module page to complete your setup.
  5. Copy your API secret key from vdocipher dashboard > config > general.
  6. Enter the API key in Drupal and save your settings.
  7. Save the configuration.
  8. Copy a video id from your vdocipher dashboard. Edit an existing node in Drupal and add this code in any text field (replace aaaaaaa with id of a video).
    1. [vdo id=aaaaaaa]
  9. Open the article on a page. You should see the video player in your Drupal website.

Q. I am seeing the message: Unauthorized
A. Most probably, you have extra spaces in the API key configuration. Go to the module configuration for vdocipher and make sure the API key is correct.

Q. I am seeing message: Video not found
A. This would probably mean that the video id is not correct. The rich-text editor you are using to add the shortcode might have added extra characters. Content saved in the database is HTML while you are shown rendered HTML in the editor. Click on one of the “view source” option in your editor and try re-pasting the shortcode. Also, make sure there are no spaces before or after the equality sign.

Q. How to set this up for selling video as PPV or subscription?
A. The video can only be viewed by the person who has purchased a membership or a video. You need to set up Drupal permissions such as only those persons can view the assigned content-type which has video.

Q. The height and width are not what I want
A. The height and width are taken from the module configuration and overridden from the shortcode. Did I tell you, you can also add the height and width info like the following. In case the provided width is greater than the available width, the width is set to 100% of available width and height is adjusted to keep the same aspect ratio as provided by the settings.

Q. Why is this not integrated with the media module
A. That what was the idea when we started working on it. But turns out there are certain permission concerns that we need to understand to make sure that using the media module is alright for your video accessibility.

Q. How to manage permission on creating video playable contents
A. The shortcode for video can be added to any node and thus anybody who has the permission to create node(any content type) can add a shortcode to play the video. Note that comment is not a node. We understand this might be a problem for your set-up in a multi-user environment. We plan to solve this problem in the next version with either a custom content type or using the media module to make it easy to control permissions. At the very least, we can add a white-list of content-types which can only have a video embedded in it but it might not work in all cases.

Note on watermark adding.

The watermark can be added to your videos to imprint info about the logged in user or an image for branding. You can configure the watermark from the module configuration page. Check this article for more information on the structure and format required to add watermark text or image in the video. We are going to add a new article on how to configure the watermark in Drupal.

A note about caching

OTP generated here is temporary. You can not cache this OTP and send it to multiple users as it might cause trouble. The OTP once used gets expired and can no longer be used to play video. Some extensions might try to automate the page rendering and especially when on pages which do not need login. The configuration must be set to make sure pages with embedded videos are not cached and cause error while playback.

vdocipher api illustration

For reference about how everything works, please check API reference.

Do let us know about your experiences setting up your secure video in Drupal to create your own PPV or subscription-based video portal. and how we can make the integration simpler.