videnfb

API Docs

Getting Started

VIDEN welcomes all developers to use its super fast video encoding with high scalability to your application. 3 simple steps to complete automation:-

1. Register

Access Videnencoding.com's APIs via a registered account (Try free trial now) that includes API credentials, 200 mb free encoding limit for a month.

When you’re ready to make your video application live, login into Videnencoding.com’s registered account area and click Upgrade Plan. Select one of the Monthly Pre-Paid plans to meet your projected encoding volumes and SLA requirements. High-volume users can connect with us directly for custom plans.

2. Build and Connect

# Build XML Templates
# Send the XML template to our API endpoint via an HTTP Post to verify

3. Integrate

#Speed up your development via our API wrappers written in JAVA and PHP. You can take this logic and implement in your own language
# Design your process-flow right from upload to delivery with the help of API requests and response

Workflow overview

The videnencoding.com API allows you to seamlessly integrate a fast and scalable cloud encoding platform into your application. Our XML API is the most mature, well documented and feature cloud encoding API in the market.

Here is how it works:

Your application sends an API request to videnencoding.com which includes:
  1. Source location of your video.
  2. Watermark Feature.
  3. videnencoding.com responds immediately with a medialink so your application can track the progress of the job.
  4. Easily copy custom or preset XML encoding templates in the client interface and then use with the API
  5. GetStatus: Get a rich job progress reporting, Fore sample Media link PNQh02 is downloading, Media link 6638da is Encoding completed. Perform advanced editing: watermarks, thumbnail generation.
  6. GetmediaInfo: Get detailed media information about your source video to store in your application or customize your encoding recipes.

Authentication

ClientID

A unique Client identifier. This number can be found in the My Account tab of the API Details.

Clientkey

A client's unique authentication key string. Created automatically when a user is created.This key can be found in the My Account tab of the API Details.

Java

  package com.videnencoding;
  import java.io.BufferedWriter;
  import java.io.InputStream;
  import java.io.OutputStreamWriter;
  import java.net.HttpURLConnection;
  import java.net.MalformedURLException;
  import java.net.URL;
  import java.net.URLEncoder;
  public class videnencoding {
      private static int StartvidenEncodingWorkflow() {
           // Add Client ID
          String clientid = "1257";
           // Add Client API Key
          String clientkey = "0095e53cceacdb1ed67e92d7e23af86b";
           // Add Source URL Path
          String sourceurl = "http://videnencoding.com/samplevideos/sample.wmv";
           // Add watermark Logo Path
          String watermarklogo = "http://videnencoding.com/samplelogos/logo.png";
          // Build XML Request
          StringBuffer xml = new StringBuffer();
          xml.append(" <?xml version='1.0'?> "); < 
      xml.append(" <viden> ");
      xml.append(" <query> ");
      xml.append("<action>addmedia</action > ");
      xml.append(" < clientid > "+clientid+" < /clientid> ");
      xml.append(" <clientkey>"+clientkey+"</clientkey > ");
      xml.append(" < source > "+sourceurl+" < /source> ");
      xml.append(" <wm> ");
      xml.append(" <type>image</type > ");
      xml.append(" < path > "+watermarklogo+" < /path> ");
      xml.append(" <positionx>100</positionx > ");
      xml.append(" < positiony > 100 < /positiony> ");
      xml.append(" </wm > ");
	  xml.append("<output>");
      xml.append("<format>MP4</format>");
      xml.append("<outputtype>HD:HPIX-D</outputtype>");
      xml.append("</output>");
	  xml.append("<output>");
      xml.append("<format>MP4</format>");
      xml.append("<outputtype>HD:OPIX-D</outputtype>");
      xml.append("</output>");
	  xml.append("<output>");
      xml.append("<format>MP4</format>");
      xml.append("<outputtype>SD:HPIX-D</outputtype>");
      xml.append("</output>");
	  xml.append("<output>");
      xml.append("<format>MP4</format>");
      xml.append("<outputtype>SD:OPIX-D</outputtype>");
      xml.append("</output>");
	  xml.append("<output>");
      xml.append("<format>MP4</format>");
      xml.append("<outputtype>4G</outputtype>");
      xml.append("</output>");
	  xml.append("<output>");
      xml.append("<format>MP4</format>");
      xml.append("<outputtype>3G</outputtype>");
      xml.append("</output>");
      xml.append(" < /query> ");
      xml.append(" </viden > ");
      // Define viden API Server
      URL server = null;
      try {
      String url = "
          http: //api.videnencoding.com/api/";
          System.out.println("Connecting to:" + url);
          server = new URL(url);
      } catch (MalformedURLException mfu) {
          mfu.printStackTrace();
          return 0;
      }
      // Connect viden API Server
      try {
      	  // Construct viden API Request URL	
          String sRequest = "xml=" + URLEncoder.encode(xml.toString(), "UTF8"); 
          HttpURLConnection urlConnection = (HttpURLConnection) server.openConnection();
          urlConnection.setRequestMethod("POST");
          urlConnection.setDoOutput(true);
          urlConnection.setConnectTimeout(60000);
          urlConnection.setRequestProperty
          ("Content-Type", "application/x-www-form-urlencoded");
          BufferedWriter videnout 
          = new BufferedWriter(new OutputStreamWriter(urlConnection.getOutputStream()));
          videnout.write(sRequest);
          videnout.flush();
          videnout.close();
          urlConnection.connect();
          InputStream is = urlConnection.getInputStream();
          StringBuffer outputbuffer = new StringBuffer();
          byte[] buffer = new byte[1024 * 4];
          try {
              int n = 0;
              while (-1 != (n = is.read(buffer))) {
                  outputbuffer.append(new String(buffer, 0, n));
              }
          } catch (Exception exp) {
              exp.printStackTrace();
          }
          // Print viden API Response
          String output = outputbuffer.toString().trim();
          System.out.println(output);
      } catch (Exception exp) {
          exp.printStackTrace();
      }
      return 0;
  }
  public static void main(String[] args) {
      StartvidenEncodingWorkflow();
  }
  }
  

PHP

  <?php
  function videnencoding_api($sourceurl,$wm,$posx,$posy)
  {
  $medialink="";
  $clientid="1257";
  $clientkey="0095e53cceacdb1ed67e92d7e23af86b";
  $xml="<?xml version='1.0' encoding='UTF-8'?>
  <viden>
   <query>
    <action><addmedia</action>
    <clientid>".$clientid."</clientid>
    <clientkey>".$clientkey."</clientkey>
    <source>".$sourceurl."</source>
    <wm>
     <type>image</type>
     <path>".$wm."</path>
     <positionx>".$posx."</positionx>
     <positiony>".$posy."</positiony>
    </wm>
	<output>
      <format>MP4</format>
      <outputtype>HD:HPIX-D</outputtype>
    </output>
	<output>
      <format>MP4</format>
      <outputtype>HD:OPIX-D</outputtype>
    </output>
	<output>
      <format>MP4</format>
      <outputtype>SD:HPIX-D</outputtype>
    </output>
	<output>
      <format>MP4</format>
      <outputtype>SD:OPIX-D</outputtype>
    </output>
	<output>
      <format>MP4</format>
      <outputtype>4G</outputtype>
    </output>
	<output>
      <format>MP4</format>
      <outputtype>3G</outputtype>
    </output>
    </query>
  </viden>
  ";
  $post_data = array ('XML' => urlencode($xml));
 
  $headers=array("Content-Type:application/x-www-form-urlencoded;charset=UTF-8",
  "Accept: text/xml",
  "Content-length: " . strlen($xml),
  "Connection: close");
  $URL = "http://api.videnencoding.com/api/";
  try
  {
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL,$URL);
  curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); // set the form fields.
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // we want the html of the request returned into the variable
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); // we get redirected, so follow
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); // DO RETURN HTTP HEADERS
  curl_setopt($ch, CURLOPT_HEADER, true); // this need to be an html form post.
  curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
  curl_setopt($ch, CURLOPT_POST, true); // this need to be an html form post.
  curl_setopt($ch, CURLOPT_TIMEOUT, 60000); //times out after X seconds
  curl_setopt($ch, CURLOPT_POSTFIELDS, $xml); 
  $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); 
  //Execute the request and also time the transaction
  $start = array_sum(explode(' ', microtime()));
  $data = curl_exec($ch); 
  //echo var_dump(curl_getinfo($ch));
  echo $data;
  $stop = array_sum(explode(' ', microtime()));
  $totalTime = $stop - $start;
  //convert the XML result into array
  if(curl_errno($ch))
  {
  //Check for errors
  $result = 'ERROR -> ' . curl_errno($ch) . ': ' . curl_error($ch);
  // die('error occured');
  }
  else
  {
  switch($data)
  {
  case 200:
  break;
  default:
  $result = 'HTTP ERROR -> ' . $data;
  break;
  curl_close($ch);
  }
  }
  }
  catch(Exception $e)
  {
  echo 'Message : '.$e->getMessage();
  die("Error");
  }
  return $medialink;
  }
  $vale=videnencoding_api("http://videnencoding.com/samplevideos/sample.wmv",
  "http://videnencoding.com/samplelogos/logo.png",100,100);
  ?>
          

Add Media Request

  
  <?xml version="1.0"?> //ADD Media without Watermark Request 
   <viden>
    <query>
     <action>addmedia</action>
     <clientid>[clientid]</clientid>
     <clientkey>[clientkey]</clientkey>
     <source>[sourceurl]</source>
	  <output>
      <format>[Format]</format>
      <outputtype>[TYPE]</outputtype>
    </output>
    </query>
   </viden>
  
  
  <?xml version="1.0"?> ///ADD Media with Image Watermark Request
   <viden>
    <query>
     <action>addmedia</action>
     <clientid>[clientid]</clientid>
     <clientkey>[clientkey]</clientkey>
     <source>[sourceurl]</source>
   <wm>
    <type>image</type>
    <path>[watermarklogo]</path>
    <positionx>100</positionx>
    <positiony>100</positiony>
   </wm>
    <output>
      <format>[Format]</format>
      <outputtype>[TYPE]</outputtype>
    </output>
   </query>
  </viden>
 
  <?xml version="1.0"?>  ///ADD Media with Text Watermark Request
   <viden>
    <query>
     <action>addmedia</action>
     <clientid>[clientid]</clientid>
     <clientkey>[clientkey]</clientkey>
     <source>[sourceurl]</source>
     <wm>
      <type>text</type>
      <text>[TEXT]</text>
      <positionx>100</positionx>
      <positiony>100</positiony>
      <font-size>10</font-size>
     </wm>
	 <output>
      <format>[Format]</format>
      <outputtype>[TYPE]</outputtype>
    </output>
    </query>
   </viden>
    

Get Status Report

  
  <?xml version="1.0"?> /// Get Media Info Request
   <viden>
    <query>
     <action>getstatus</action>
     <clientid>[clientid]</clientid>
     <clientkey>[clientkey]</clientkey>
     <medialink>[medialink]</medialink>
    </query>
   </viden>
  

Get Media Info

   
  <?xml version="1.0"?>  /// Get Media Info Request
   <viden>
    <query>
     <action>getmediainfo</action>
     <clientid>[clientid]</clientid>
     <clientkey>[clientkey]</clientkey>
     <medialink>[medialink]</medialink>
    </query>
   </viden>
  

Delete Media Info

  
  <?xml version="1.0"?> //Delete Media Info
   <viden>
    <query>
     <action>deletemedia</action>
     <clientid>[clientid]</clientid>
     <clientkey>[clientkey]</clientkey>
     <medialink>[medialink]</medialink>
    </query>
    </viden>
  

Add Media Response

  
  <?xml version="1.0" encoding="UTF-8"?> //Add Media Response
   <response>
    <message>Basic Encoding</message>
    <messagecode>3.1</messagecode>
    <messagedescription>Media added successfully</messagedescription>
    <media>
     <mediaid>[mediaid]</mediaid>
     <medialink>[medialink]</medialink>
     <mediastatus>Started</mediastatus>
    </media>
   </response>
  

Get Status Response

       
  <?xml version="1.0" encoding="UTF-8"?>  // Get Status Response   
   <response>
    <message>Get Status</message>
    <messagecode>4.1</messagecode>
    <messagedescription>Media status fetched successfully</messagedescription>
    <media>
     <medialink>[medialink]</medialink>
     <mediastatus>
     [Media Status - Download Started/Downloading.../Download Completed
     /Media Info Gathering.../  Media Info Completed/Encoding.../Encoding Completed/Error/Finished]
     </mediastatus>
    </media>
  

Get Media Info

  <?xml version="1.0" encoding="UTF-8"?>
   <response>
    <message>Get Mediainfo</message>
    <messagecode>6.3</messagecode>
    <messagedescription>Media information fetched successfully</messagedescription>
    <media>
     <medialink>[medialink]</medialink>
     <mediawidth>[Media Width]</mediawidth>
     <mediaheight>[Media Height]</mediaheight>
     <mediaduration>[Media Duration]</mediaduration>
     <mediavcodec>[Media Video codec]</mediavcodec>
     <mediaframerate>[Media Video Framerate]</mediaframerate>
    </media>
   </response> 
  

Delete Media Info

  <?xml version="1.0" encoding="UTF-8"?>
   <response>
    <message>Delete Media</message>
    <messagecode>7.1</messagecode>
    <messagedescription>Media deleted successfully</messagedescription>
    <media>
     <medialink>[medialink]</medialink>
    </media>
   </response>
  

Common Errors

S.no Error Message Description
1. Validation Faliure Invalid Client ID (or) Key
2. API XML Error Invalid API XML structure
3. API Action Name Invalid API Request
4. API Non Valid Invalid API Key. Upgrade the plan

Media Errors

S.no Error Message Description Action
1. Invalid media link Media Link is not found Get Status, Get Mediainfo, Delete Media
2. Wrong Source URL Unable to download the media due to invalid URL Add Media
3. Media Error Unable to encode the media due to error Add Media
4. Input File Format Invalid file format Add Media