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?
- Get the API key
- Get the VIdeo URL from Azure OR Amazon S3 Or any public video URL.
- Pass the Video URL with API key and get the video Id token.
- 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*/} }