How to get a Thumbnail from a Video on Azure Media Services?

877 views Asked by At

I start new with Azure and Azure PHP sdk because I'm PHP developer. With Azure PHP sdk, I can store video and get video url. Now I want to know how to create video thumbnails with Azure. But I don't know how to do.

1

There are 1 answers

0
rnrneverdies On BEST ANSWER

To create a thumbnail you should create a job as usual but setting the Thumbnail xml via setConfiguration.

This is untested code but should work.

// sets the thumbnail configuration
$thumbnailConfig = <<<EOT 
<?xml version="1.0" encoding="utf-8"?> 
<Thumbnail Size="50%,*" Type="Jpeg" Filename="{OriginalFilename}_{Size}_{ThumbnailTime}_{ThumbnailIndex}_{Date}_{Time}.{DefaultExtension}"> 
<Time Value="10%"/>
</Thumbnail>
EOT;

$xmlTask = '<taskBody><inputAsset>JobInputAsset(0)</inputAsset>' 
         . '<outputAsset>JobOutputAsset(0)</outputAsset></taskBody>';

$mediaProcessor = $restProxy->getLatestMediaProcessor('Azure Media Encoder');

$task = new Task($xmlTask, $mediaProcessor->getId(), TaskOptions::NONE);
$task->setConfiguration($thumbnailConfig);

$restProxy->createJob(new Job(), array($inputAsset), array($task));

You should connect to media services first, for more information go here

Connection snippet:

$restProxy = ServicesBuilder->getInstance()->createMediaServicesService(
          new MediaServicesSettings([YourAccountName],
                           [YourPrimaryOrSecondaryAccessKey]));