use WindowsAzure\MediaServices\Templates\FairPlayConfiguration; // read user settings from config include_once 'userconfig.php'; $mezzanineFileName = __DIR__ . '/resources/Azure-Video.wmv'; $tokenRestriction = true; $tokenType = TokenType::JWT; // FairPlay $fairPlayASK = '<your apple ASK>'; $fairPlayPFXFile = '<path to the pfx file>'; $fairPlayPFXPassword = '******'; $fairPlayIV = bin2hex(openssl_random_pseudo_bytes(16)); echo "Azure SDK for PHP - FairPlay Dynamic Encryption Sample" . PHP_EOL; // 0 - set up the MediaServicesService object to call into the Media Services REST API. $restProxy = ServicesBuilder::getInstance()->createMediaServicesService(new MediaServicesSettings($account, $secret)); // 1 - Upload the mezzanine $sourceAsset = uploadFileAndCreateAsset($restProxy, $mezzanineFileName); // 2 - encode the output asset $encodedAsset = encodeToAdaptiveBitrateMP4Set($restProxy, $sourceAsset); // 3 - Create Content Key $contentKey = createCommonCBCTypeContentKey($restProxy, $encodedAsset); // 4 - Create the ContentKey Authorization Policy $tokenTemplateString = null; if ($tokenRestriction) { $tokenTemplateString = addTokenRestrictedAuthorizationPolicy($restProxy, $contentKey, $tokenType, $fairPlayASK, $fairPlayPFXPassword, $fairPlayPFXFile, $fairPlayIV); } else { addOpenAuthorizationPolicy($restProxy, $contentKey, $fairPlayASK, $fairPlayPFXPassword, $fairPlayPFXFile, $fairPlayIV); } // 5 - Create the AssetDeliveryPolicy createAssetDeliveryPolicy($restProxy, $encodedAsset, $contentKey, $fairPlayIV); // 6 - Publish publishEncodedAsset($restProxy, $encodedAsset);
include_once 'userconfig.php'; $mediaFileName = __DIR__ . '/resources/Azure-Video.wmv'; $destinationPath = __DIR__ . '/IndexerOutput'; $indexerTaskPresetTemplate = file_get_contents(__DIR__ . '/resources/indexerTaskPresetTemplate.xml'); // Configuration parameters for Indexer task $title = ''; $description = ''; $language = 'English'; $captionFormats = 'ttml;sami;webvtt'; $generateAIB = 'true'; $generateKeywords = 'true'; echo "Azure SDK for PHP - Media Analytics Sample (Indexer)" . PHP_EOL; // 0 - Set up the MediaServicesService object to call into the Media Services REST API. $restProxy = ServicesBuilder::getInstance()->createMediaServicesService(new MediaServicesSettings($account, $secret)); // 1 - Upload the mezzanine $sourceAsset = uploadFileAndCreateAsset($restProxy, $mediaFileName); // 2 - Create indexing task configuration based on parameters $taskConfiguration = sprintf($indexerTaskPresetTemplate, $title, $description, $language, $captionFormats, $generateAIB, $generateKeywords); // 3 - Run indexing job to generate output asset $outputAsset = runIndexingJob($restProxy, $sourceAsset, $taskConfiguration); // 4 - Download output asset files downloadAssetFiles($restProxy, $outputAsset, $destinationPath); // Done echo 'Done!'; //////////////////// // Helper methods // //////////////////// function uploadFileAndCreateAsset($restProxy, $mediaFileName) { // Create an empty "Asset" by specifying the name $asset = new Asset(Asset::OPTIONS_NONE);