Developer Blog

Transcoding

  What is transcoding and how does this help my business? We hear this question quite often. Transcoding is the conversion of one format to another, for example, conversion of windows media video to Flash or .avi to h.264. Since the launch of the beta functionality, we have been gathering feedback and monitoring usage to get the engine to a point where we can quickly add output formats and at the same time simplify the input format.

Codecs tend to be complex which often makes the parameters coming in quite difficult to manage. Adding to that complexity each codec has its own "best" settings which will vary largely between each. The goal of any good API is always to strip away complexity and leave you with a simple interface that does everything you want it to which is what PresetTranscode attempts to do. The goal from the outset was to provide a simple way to convert video from one format to another eliminating the need for the user to know every nuance of the codec and automatically use the “best” settings. At the same time we introduced a new more robust transcoding engine under the hood to achieve this and support new features we will be adding in coming releases.

While our old engine and API are still available through the Transcode call we will be migrating all of the functionality over to the new engine and PresetTranscode over time. We will continue to provide updates and work with customers as we phase the Transcode call out.

You may be asking what the advantage of using the new engine over the old is for you other than the simplified interface. With the new call we have introduced three levels of quality which were not previously available and made the engine easier to configure. What this translates to is a fast and easy way to introduce more presets allowing for a large number of new options and quality levels.

Using the PresetTranscode call is simplifies the task since the majority of the parameters are wrapped up in the preset. To further simplify our example I am using the Nirvanix SDK in the Zend framework to do the sample below. This sample assumes you already uploaded a file called vacation01.mpg to your /video directory under the account you wish to access.

PHP Zend Code Example:
<?php
set_include_path(get_include_path() . PATH_SEPARATOR .'C:/Zend/incubator/library' . PATH_SEPARATOR .'C:/Zend/library');
require_once 'Zend/Service/Nirvanix.php';
// First create the Zend object and get a Session

$appkey = 'APPKEY';
$username = 'USERNAME';
$password = 'PASSWORD';
$auth = array('username' => $username,'password' => $password,'appKey' => $appkey);
try {

// This authenticates the user and retrieves session

$nirvanix = new Zend_Service_Nirvanix($auth);

// This retrieves the Video Namespace object

$video = $nirvanix->getService('Video');
$params = array('srcFilePath' => '/videos/vacation01.mpg',
'destFilePath' => '/videos/vacation01.flv',
'preset' => 'H263 FLV Medium',
'scaleWidth' => '320',
'scaleHeight' => '200');

// We won't wait for the response code to come back since the
// Zend SDK will thrown an exception if the reponse code is not 0
   $video->PresetTranscode($params);
}

?>

 

This will output a flash video file to /videos/vacation01.flv. This file can then be embedded in a flash player and streamed back to the user.  You can read more about transcoding in the SDK document at:

http://developer.nirvanix.com/sitefiles/1000/API.html#_TocPresetTranscode


Comments

No Comments