Showing posts with label Azure. Show all posts
Showing posts with label Azure. Show all posts

Thursday, 12 October 2017

Azure video indexer - Get text from the Video


Question: What is Video Indexer API?
This API is used to Get the Visual Text from the Video. It will give you all the text that appear in the video.



Question: How to Get Text from the video?
  1. Get the API key
  2. Get the VIdeo URL from Azure OR Amazon S3 Or any public video URL.
  3. Pass the Video URL with API key and get the video Id token.
  4. Pass the video Id token with API key and get the all Text



Question: How to Get the API Key?
Follow the below link, you will get the API key which can be used further.
https://docs.microsoft.com/en-us/azure/cognitive-services/video-indexer/video-indexer-use-apis#subscribe-to-the-api


Question: How to Get the videoId token from the video?
$subScriptionKey = 'AZURE_SUBSCRIPTION_KEY_HERE';   
$videoUrl='https://foldername.blob.core.windows.net/bucketname/GV-NNokn-989-5175_360p.mp4';

$curl = curl_init();
curl_setopt_array($curl, array(
  CURLOPT_URL => "https://videobreakdown.azure-api.net/Breakdowns/Api/Partner/Breakdowns?name=new%20video%20test&privacy=Private&videoUrl=".urlencode($videoUrl),
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => "",
  CURLOPT_HTTPHEADER => array(
    "cache-control: no-cache",
    "content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW",
    "ocp-apim-subscription-key: {$subScriptionKey}",    
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}

OR Using Zend Framework
$subScriptionKey = 'AZURE_SUBSCRIPTION_KEY_HERE';   
$videoUrl='https://foldername.blob.core.windows.net/bucketname/GV-NNokn-989-5175_360p.mp4';
$jsonData = '';        
$config = array(
       'adapter' => 'Zend_Http_Client_Adapter_Curl',
       'curloptions' => array(CURLOPT_FOLLOWLOCATION => true,CURLOPT_SSL_VERIFYPEER =>FALSE),            
   );
    $url='https://videobreakdown.azure-api.net/Breakdowns/Api/Partner/Breakdowns';
   $client = new Zend_Http_Client($url, $config);
   //Set the Header value
    $client->setHeaders('Content-Type', "multipart/form-data");
    $client->setHeaders('Ocp-Apim-Subscription-Key', $subScriptionKey);

    $postData = array(
    'name'=>'GV-NNokn-989-5175',
    'privacy'=>'Private',
    'videoUrl'=>$videoUrl
    );
    $client->setParameterGet($postData);

   $response = $client->request('POST'); 
   $jsonData= ($response->getBody());



Output
9a10d9d0002



Question: How to get video text from videoId token?
$subScriptionKey = 'AZURE_SUBSCRIPTION_KEY_HERE';   
$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://videobreakdown.azure-api.net/Breakdowns/Api/Partner/Breakdowns/VIDEOIDTOKEN",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => array(
    "cache-control: no-cache",
    "ocp-apim-subscription-key: {$subScriptionKey}",
    "postman-token: 43c1c192-1de6-ac3d-42e0-b1ddc7cc0ee0"
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}

OR Using Zend Framework
$subScriptionKey = 'AZURE_SUBSCRIPTION_KEY_HERE';   
        $language = 'English';
        $body = 'How to you?';
        $breadDownsId='2bc89c5ec1';

        //Main Data
        $client = new Zend_Http_Client('https://videobreakdown.azure-api.net/Breakdowns/Api/Partner/Breakdowns/' . $breadDownsId, array(
            'maxredirects' => 0,
            'timeout' => 30
        ));       
        
        $client->setHeaders('Ocp-Apim-Subscription-Key', $subScriptionKey);

        $parameters = array(
            'language' => $language,
        );
        $client->setParameterGet($parameters);

        try {
            $response = $client->request('GET');
            $data = $response->getBody();
        } catch (Exception $ex) {
            $data = $ex;
        }
        echo $response->getBody();die;

Output
{
    "accountId": "2b525a6-3a5408006294",
    "id": "9a10d9d912",
    "partition": null,
    "name": "new video test",
    "description": null,
    "userName": "Ram Kumar",
    "createTime": "2017-10-12T04:41:20.8986398+00:00",
    "organization": "",
    "privacyMode": "Private",
    "state": "Processed",
    "isOwned": true,
    "isEditable": false,
    "isBase": true,
    "durationInSeconds": 1373,
    "summarizedInsights":{/* It will have data*/},
    "breakdowns":{/* It will have data*/},
    "social":{/* It will have data*/}
}




Friday, 14 July 2017

Download the Azure SDK for PHP and upload the video in Azure

Download the Azure SDK for PHP and upload the video in Azure

Download the Azure SDK for PHP

  1. Install Git. (If already, move to next)
  2. Create composer.json and add following contents.
    {
             "require": {
               "microsoft/azure-storage": "*"
             }
           }
  3. Download composer.phar in your project root.
  4. Execute following Command.
    php composer.phar install
  5. It will download the Library, which I have tested.



Upload the Media in Azure

  1. Include following files:
    use WindowsAzure\Common\ServicesBuilder;
    use MicrosoftAzure\Storage\Common\ServiceException;
    require_once 'azure/vendor/autoload.php';
  2. Get the Credentials
    $azureUserName='XXXXXXXXXXXX';
    $azureKey='XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
    $containter='XXXXXXXXX';
    
  3. Set the Credentias
    $connectionString = "DefaultEndpointsProtocol=http;AccountName={$azureUserName};AccountKey={$azureKey}";
    $blobRestProxy = ServicesBuilder::getInstance()->createBlobService($connectionString);
  4. Upload the File in Azure
    $blobName='textFile.txt';
    $content = fopen('../data/test6.txt', "r");
    try    {
                
                $blobRestProxy->createBlockBlob($containter, $blobName, $content);
                echo 'Uploaded successfully';
            }
            catch(ServiceException $e){
                $code = $e->getCode();
              $e->getMessage();
    
            }

Thursday, 27 April 2017

Azure Blob storage Architecture

 Azure Blob storage

Question: What is Azure Blob storage?
Azure Blob storage is a service that stores unstructured large data in the cloud in form of objects/blob.
Blob storage can store any type of file like image, video OR text etc.
Stored data can be accessed through HTTP or HTTPS.


Question: What is Blob?
It is large file like an image, video or binary data.


Question: Why Blob Storage are used?
  1. Streaming Audio/Video.
  2. Storing data for backup and restore.
  3. Store heavy data like images, audio and videos.
  4. Access the data in browser.
  5. Storing files for distributed access.



Question: What is structure of Blob storage?
An account can have one OR More container.
User can store the data in container.
For Example:
One Account 
    Movies (Container 1)
        movie1.mp4 (Blob data)
        movie2.mp4 (Blob data)
        movie3.mp4 (Blob data)

    videos (Container 2)
        video1.mp4 (Blob data)
        video1.mp4 (Blob data)
        video1.mp4 (Blob data)

    photos (Container 3)
        photo1.jpg (Blob data)
        photo2.jpg (Blob data)
        photo3.jpg (Blob data)
        photo4.jpg (Blob data)



Question: How to get azure client Libraries (using composer)?
  1. 1. Create a folder where you want to download the library.
  2. Install composer (If not) php -r "readfile('https://getcomposer.org/installer');" | php
  3. Create a composer.json (with following data)
    {
       "require": {
         "microsoft/windowsazure": "^0.4"
       }
     }
  4. Download the library with following command.
    php composer.phar install



Question: Give a tutorial from where i can do list/add/update/delete the azure blob data?
https://docs.microsoft.com/en-us/azure/storage/storage-php-how-to-use-blobs


Question: In how many programming language code is available?
  1. .NET
  2. Java
  3. Node.js
  4. C++
  5. Python
  6. P?HP
  7. Ruby
  8. iOS
  9. Xamarin



Question: What is mount in linux?
Mounting a filesystem means making the particular filesystem accessible.
When mounting a filesystem it does not matter if the filesystem is a hard disk partition, CD-ROM, floppy, or USB storage device.


Question: Differences between Azure Block Blob and Page Blob?
Block blobs are for your discrete storage objects like jpg's, log files, etc.
Page blobs are for random read/write storage, such as VHD's. Max size 1TB.


Question: What is the maximum length of an Azure blob name?
1024 max character.