public static async Task <HttpResponseMessage> Run([HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequestMessage req, TraceWriter log) { log.Info("C# HTTP trigger function processed a request."); string jsonContent = await req.Content.ReadAsStringAsync(); dynamic data = JsonConvert.DeserializeObject(jsonContent); // Validate input objects if (data.destinationContainer == null) { return(req.CreateResponse(HttpStatusCode.BadRequest, new { error = "Please pass destinationContainer in the input object" })); } MediaServicesConfigWrapper amsconfig = new MediaServicesConfigWrapper(); Asset inputAsset = null; IAzureMediaServicesClient client = CreateMediaServicesClient(amsconfig); string assetName = data.destinationContainer.ToString(); inputAsset = client.Assets.Get(amsconfig.ResourceGroup, amsconfig.AccountName, assetName); if (inputAsset == null) { return(req.CreateResponse(HttpStatusCode.BadRequest, new { error = $"Asset {assetName} not found" })); } client.Assets.Delete(amsconfig.ResourceGroup, amsconfig.AccountName, assetName); return(req.CreateResponse(HttpStatusCode.OK, $"Asset {assetName} deleted")); }
private static IAzureMediaServicesClient CreateMediaServicesClient(MediaServicesConfigWrapper config) { ArmClientCredentials credentials = new ArmClientCredentials(config.serviceClientCredentialsConfig); return(new AzureMediaServicesClient(config.serviceClientCredentialsConfig.ArmEndpoint, credentials) { SubscriptionId = config.SubscriptionId, }); }
public static async Task <object> Run([HttpTrigger(WebHookType = "genericJson")] HttpRequestMessage req, TraceWriter log) { log.Info($"AMS v3 Function - create_empty_asset was triggered!"); string jsonContent = await req.Content.ReadAsStringAsync(); dynamic data = JsonConvert.DeserializeObject(jsonContent); if (data.assetNamePrefix == null) { return(req.CreateResponse(HttpStatusCode.BadRequest, new { error = "Please pass assetNamePrefix in the input object" })); } string assetStorageAccount = null; if (data.assetStorageAccount != null) { assetStorageAccount = data.assetStorageAccount; } Guid assetGuid = Guid.NewGuid(); string assetName = data.assetNamePrefix + "-" + assetGuid.ToString(); MediaServicesConfigWrapper amsconfig = new MediaServicesConfigWrapper(); Asset asset = null; try { IAzureMediaServicesClient client = CreateMediaServicesClient(amsconfig); Asset assetParams = new Asset(null, assetName, null, assetGuid, DateTime.Now, DateTime.Now, null, assetName, null, assetStorageAccount, AssetStorageEncryptionFormat.None); asset = client.Assets.CreateOrUpdate(amsconfig.ResourceGroup, amsconfig.AccountName, assetName, assetParams); //asset = client.Assets.CreateOrUpdate(amsconfig.ResourceGroup, amsconfig.AccountName, assetName, new Asset()); } catch (ApiErrorException e) { log.Info($"ERROR: AMS API call failed with error code: {e.Body.Error.Code} and message: {e.Body.Error.Message}"); return(req.CreateResponse(HttpStatusCode.BadRequest, new { error = "AMS API call error: " + e.Message })); } return(req.CreateResponse(HttpStatusCode.OK, new { assetName = assetName, assetId = asset.AssetId })); }
public static async Task <object> Run([HttpTrigger(WebHookType = "genericJson")] HttpRequestMessage req, TraceWriter log) { log.Info($"AMS v3 Function - monitor_job_status was triggered!"); string jsonContent = await req.Content.ReadAsStringAsync(); dynamic data = JsonConvert.DeserializeObject(jsonContent); // Validate input objects if (data.jobName == null) { return(req.CreateResponse(HttpStatusCode.BadRequest, new { error = "Please pass jobName in the input object" })); } if (data.transformName == null) { return(req.CreateResponse(HttpStatusCode.BadRequest, new { error = "Please pass transformName in the input object" })); } string jobName = data.jobName; string transformName = data.transformName; MediaServicesConfigWrapper amsconfig = new MediaServicesConfigWrapper(); Job job = null; try { IAzureMediaServicesClient client = CreateMediaServicesClient(amsconfig); job = client.Jobs.Get(amsconfig.ResourceGroup, amsconfig.AccountName, transformName, jobName); } catch (ApiErrorException e) { log.Info($"ERROR: AMS API call failed with error code: {e.Body.Error.Code} and message: {e.Body.Error.Message}"); return(req.CreateResponse(HttpStatusCode.BadRequest, new { error = "AMS API call error: " + e.Message })); } return(req.CreateResponse(HttpStatusCode.OK, new { // job status jobStatus = job.State, obj = JsonConvert.SerializeObject(job) // job output progress })); }
public static async Task <object> Run([HttpTrigger(WebHookType = "genericJson")] HttpRequestMessage req, TraceWriter log) { log.Info($"AMS v3 Function - submit_job was triggered!"); string jsonContent = await req.Content.ReadAsStringAsync(); dynamic data = JsonConvert.DeserializeObject(jsonContent); // Validate input objects if (data.inputAssetName == null) { return(req.CreateResponse(HttpStatusCode.BadRequest, new { error = "Please pass inputAssetName in the input object" })); } if (data.transformName == null) { return(req.CreateResponse(HttpStatusCode.BadRequest, new { error = "Please pass transformName in the input object" })); } if (data.outputAssetNamePrefix == null) { return(req.CreateResponse(HttpStatusCode.BadRequest, new { error = "Please pass outputAssetNamePrefix in the input object" })); } string inputAssetName = data.inputAssetName; string transformName = data.transformName; string outputAssetNamePrefix = data.outputAssetNamePrefix; string assetStorageAccount = null; if (data.assetStorageAccount != null) { assetStorageAccount = data.assetStorageAccount; } MediaServicesConfigWrapper amsconfig = new MediaServicesConfigWrapper(); Asset inputAsset = null; string guid = Guid.NewGuid().ToString(); string jobName = "amsv3function-job-" + guid; string encoderOutputAssetName = null; string videoAnalyzerOutputAssetName = null; string outputContainer = null; try { var containerName = inputAssetName; containerName = containerName.Replace("asset", "saida"); IAzureMediaServicesClient client = CreateMediaServicesClient(amsconfig); inputAsset = client.Assets.Get(amsconfig.ResourceGroup, amsconfig.AccountName, inputAssetName); if (inputAsset == null) { return(req.CreateResponse(HttpStatusCode.BadRequest, new { error = "Asset for input not found" })); } Transform transform = client.Transforms.Get(amsconfig.ResourceGroup, amsconfig.AccountName, transformName); if (transform == null) { return(req.CreateResponse(HttpStatusCode.BadRequest, new { error = "Transform not found" })); } var jobOutputList = new List <JobOutput>(); for (int i = 0; i < transform.Outputs.Count; i++) { Guid assetGuid = Guid.NewGuid(); string outputAssetName = outputAssetNamePrefix + "-" + assetGuid.ToString(); Preset p = transform.Outputs[i].Preset; if (p is BuiltInStandardEncoderPreset || p is StandardEncoderPreset) { encoderOutputAssetName = outputAssetName; } else if (p is VideoAnalyzerPreset) { videoAnalyzerOutputAssetName = outputAssetName; } Asset assetParams = new Asset(null, outputAssetName, null, assetGuid, DateTime.Now, DateTime.Now, null, outputAssetName, containerName, assetStorageAccount, AssetStorageEncryptionFormat.None); Asset outputAsset = client.Assets.CreateOrUpdate(amsconfig.ResourceGroup, amsconfig.AccountName, outputAssetName, assetParams); jobOutputList.Add(new JobOutputAsset(outputAssetName)); if (outputContainer != null) { outputContainer += containerName + ","; } outputContainer += containerName; } // Use the name of the created input asset to create the job input. JobInput jobInput = new JobInputAsset(assetName: inputAssetName); JobOutput[] jobOutputs = jobOutputList.ToArray(); Job job = client.Jobs.Create( amsconfig.ResourceGroup, amsconfig.AccountName, transformName, jobName, new Job { Input = jobInput, Outputs = jobOutputs, } ); } catch (ApiErrorException e) { log.Error("error", e); log.Info($"ERROR: AMS API call failed with error code: {e.Body.Error.Code} and message: {e.Body.Error.Message}"); return(req.CreateResponse(HttpStatusCode.BadRequest, new { error = "AMS API call error: " + e.Message })); } catch (Exception ex) { log.Error("error", ex); } return(req.CreateResponse(HttpStatusCode.OK, new { jobName = jobName, encoderOutputAssetName = encoderOutputAssetName, videoAnalyzerOutputAssetName = videoAnalyzerOutputAssetName, outputGuid = outputContainer })); }
public static async Task <object> Run([HttpTrigger(WebHookType = "genericJson")] HttpRequestMessage req, TraceWriter log) { log.Info($"AMS v3 Function - start_blob_copy_to_asset was triggered!"); string jsonContent = await req.Content.ReadAsStringAsync(); dynamic data = JsonConvert.DeserializeObject(jsonContent); // Validate input objects if (data.assetName == null) { return(req.CreateResponse(HttpStatusCode.BadRequest, new { error = "Please pass assetName in the input object" })); } if (data.assetId == null) { return(req.CreateResponse(HttpStatusCode.BadRequest, new { error = "Please pass assetId in the input object" })); } if (data.sourceStorageAccountName == null) { return(req.CreateResponse(HttpStatusCode.BadRequest, new { error = "Please pass sourceStorageAccountName in the input object" })); } if (data.sourceStorageAccountKey == null) { return(req.CreateResponse(HttpStatusCode.BadRequest, new { error = "Please pass sourceStorageAccountKey in the input object" })); } if (data.sourceContainer == null) { return(req.CreateResponse(HttpStatusCode.BadRequest, new { error = "Please pass sourceContainer in the input object" })); } log.Info("Input - assetName : " + data.assetName); log.Info("Input - assetId : " + data.assetId); log.Info("Input - SourceStorageAccountName : " + data.sourceStorageAccountName); log.Info("Input - SourceStorageAccountKey : " + data.sourceStorageAccountKey); string assetName = data.assetName; string assetId = data.assetId; string _sourceStorageAccountName = data.sourceStorageAccountName; string _sourceStorageAccountKey = data.sourceStorageAccountKey; string sourceContainerName = data.sourceContainer; List <string> fileNames = null; if (data.fileNames != null) { fileNames = ((JArray)data.fileNames).ToObject <List <string> >(); } MediaServicesConfigWrapper amsconfig = new MediaServicesConfigWrapper(); Asset asset = null; string destinationContainer = ""; try { IAzureMediaServicesClient client = CreateMediaServicesClient(amsconfig); asset = client.Assets.Get(amsconfig.ResourceGroup, amsconfig.AccountName, assetName); if (asset == null) { return(req.CreateResponse(HttpStatusCode.BadRequest, new { error = "Asset not found" })); } // Setup blob container CloudBlobContainer sourceBlobContainer = BlobStorageHelper.GetCloudBlobContainer(_sourceStorageAccountName, _sourceStorageAccountKey, sourceContainerName); sourceBlobContainer.CreateIfNotExists(); var response = client.Assets.ListContainerSas(amsconfig.ResourceGroup, amsconfig.AccountName, assetName, permissions: AssetContainerPermission.ReadWrite, expiryTime: DateTime.UtcNow.AddHours(4).ToUniversalTime()); var sasUri = new Uri(response.AssetContainerSasUrls.First()); CloudBlobContainer destinationBlobContainer = new CloudBlobContainer(sasUri); destinationContainer = destinationBlobContainer.Name; // Copy Source Blob container into Destination Blob container that is associated with the asset. BlobStorageHelper.CopyBlobsAsync(sourceBlobContainer, destinationBlobContainer, fileNames, log); } catch (ApiErrorException e) { log.Info($"ERROR: AMS API call failed with error code: {e.Body.Error.Code} and message: {e.Body.Error.Message}"); return(req.CreateResponse(HttpStatusCode.BadRequest, new { error = "AMS API call error: " + e.Message })); } return(req.CreateResponse(HttpStatusCode.OK, new { destinationContainer = destinationContainer })); }
public static async Task <object> Run([HttpTrigger(WebHookType = "genericJson")] HttpRequestMessage req, TraceWriter log) { log.Info($"AMS v3 Function - publish_asset was triggered!"); string jsonContent = await req.Content.ReadAsStringAsync(); dynamic data = JsonConvert.DeserializeObject(jsonContent); // Validate input objects if (data.publishAssetName == null) { return(req.CreateResponse(HttpStatusCode.BadRequest, new { error = "Please pass publishAssetName in the input object" })); } string publishAssetName = data.publishAssetName; PredefinedStreamingPolicy streamingPolicy = PredefinedStreamingPolicy.ClearStreamingOnly; // default if (data.streamingPolicy != null) { string streamingPolicyName = data.streamingPolicy; if (predefinedStreamingPolicy.ContainsKey(streamingPolicyName)) { streamingPolicy = predefinedStreamingPolicy[streamingPolicyName]; } } string streamingEndpointName = "default"; // default if (data.streamingEndpointName != null) { streamingEndpointName = data.streamingEndpointName; } MediaServicesConfigWrapper amsconfig = new MediaServicesConfigWrapper(); string guid = Guid.NewGuid().ToString(); string locatorName = "locator-" + guid; PublishAssetOutput output = null; try { IAzureMediaServicesClient client = CreateMediaServicesClient(amsconfig); StreamingLocator locator = client.StreamingLocators.Create(amsconfig.ResourceGroup, amsconfig.AccountName, locatorName, new StreamingLocator() { AssetName = publishAssetName, StreamingPolicyName = streamingPolicy, }); string streamingUrlPrefx = ""; StreamingEndpoint streamingEndpoint = client.StreamingEndpoints.Get(amsconfig.ResourceGroup, amsconfig.AccountName, streamingEndpointName); if (streamingEndpoint != null) { streamingUrlPrefx = streamingEndpoint.HostName; } ListPathsResponse paths = client.StreamingLocators.ListPaths(amsconfig.ResourceGroup, amsconfig.AccountName, locatorName); output = MediaServicesHelper.ConvertToPublishAssetOutput(locatorName, streamingUrlPrefx, paths); } catch (ApiErrorException e) { log.Info($"ERROR: AMS API call failed with error code: {e.Body.Error.Code} and message: {e.Body.Error.Message}"); return(req.CreateResponse(HttpStatusCode.BadRequest, new { error = "AMS API call error: " + e.Message })); } return(req.CreateResponse(HttpStatusCode.OK, output)); }
public static async Task <object> Run([HttpTrigger(WebHookType = "genericJson")] HttpRequestMessage req, TraceWriter log) { log.Info($"AMS v3 Function - create_empty_asset was triggered!"); string jsonContent = await req.Content.ReadAsStringAsync(); dynamic data = JsonConvert.DeserializeObject(jsonContent); if (data.assetNamePrefix == null) { return(req.CreateResponse(HttpStatusCode.BadRequest, new { error = "Please pass assetNamePrefix in the input object" })); } string assetStorageAccount = null; if (data.assetStorageAccount != null) { assetStorageAccount = data.assetStorageAccount; } Guid assetGuid = Guid.NewGuid(); string assetName = data.assetNamePrefix + "-" + assetGuid.ToString(); string fileNameTemp = ""; MediaServicesConfigWrapper amsconfig = new MediaServicesConfigWrapper(); Asset asset = null; try { fileNameTemp = ((string)data.assetNamePrefix); if (fileNameTemp.Length > 20) { fileNameTemp = fileNameTemp.Substring(0, 20); } fileNameTemp = Regex.Replace(fileNameTemp, "[^a-zA-Z0-9_.]+", "", RegexOptions.Compiled); fileNameTemp = fileNameTemp.Replace(" ", string.Empty).Replace(".", "").Replace("-", "").Replace("_", ""); fileNameTemp = $"asset-{fileNameTemp}-{assetGuid.ToString()}"; if (fileNameTemp.Length > 63) { fileNameTemp = fileNameTemp.Substring(0, 63); } fileNameTemp = fileNameTemp.ToLower(); assetName = fileNameTemp; IAzureMediaServicesClient client = CreateMediaServicesClient(amsconfig); Asset assetParams = new Asset(null, assetName, null, assetGuid, DateTime.Now, DateTime.Now, null, assetName, null, assetStorageAccount, AssetStorageEncryptionFormat.None); assetParams.Container = fileNameTemp; asset = client.Assets.CreateOrUpdate(amsconfig.ResourceGroup, amsconfig.AccountName, assetName, assetParams); //asset = client.Assets.CreateOrUpdate(amsconfig.ResourceGroup, amsconfig.AccountName, assetName, new Asset()); } catch (ApiErrorException e) { log.Error("Error when trying to create empty asset", e); log.Info($"ERROR: AMS API call failed with error code: {e.Body.Error.Code} and message: {e.Body.Error.Message}"); return(req.CreateResponse(HttpStatusCode.BadRequest, new { error = "AMS API call error: " + e.Message })); } catch (Exception ex) { log.Error("Error when trying to create empty asset", ex); } return(req.CreateResponse(HttpStatusCode.OK, new { assetName = assetName, assetId = asset.AssetId })); }
public static async Task <object> Run([HttpTrigger(WebHookType = "genericJson")] HttpRequestMessage req, TraceWriter log) { log.Info($"AMS v3 Function - create_transform was triggered!"); string jsonContent = await req.Content.ReadAsStringAsync(); dynamic data = JsonConvert.DeserializeObject(jsonContent); // Validate input objects if (data.transformName == null) { return(req.CreateResponse(HttpStatusCode.BadRequest, new { error = "Please pass transformName in the input object" })); } if (data.builtInStandardEncoderPreset == null && data.videoAnalyzerPreset == null) { return(req.CreateResponse(HttpStatusCode.BadRequest, new { error = "Please pass preset in the input object" })); } string transformName = data.transformName; MediaServicesConfigWrapper amsconfig = new MediaServicesConfigWrapper(); string transformId = null; try { IAzureMediaServicesClient client = CreateMediaServicesClient(amsconfig); // Does a Transform already exist with the desired name? Assume that an existing Transform with the desired name // also uses the same recipe or Preset for processing content. Transform transform = client.Transforms.Get(amsconfig.ResourceGroup, amsconfig.AccountName, transformName); if (transform == null) { // Create a new Transform Outputs array - this defines the set of outputs for the Transform TransformOutput[] outputs = new TransformOutput[] { new TransformOutput( new StandardEncoderPreset( codecs: new Codec[] { // Add an AAC Audio layer for the audio encoding new AacAudio( channels: 1, samplingRate: 48000, bitrate: 64000, profile: AacAudioProfile.AacLc ), // Next, add a H264Video for the video encoding new H264Video( // Set the GOP interval to 2 seconds for both H264Layers keyFrameInterval: TimeSpan.FromSeconds(2), stretchMode: StretchMode.None, // Add H264Layers, one at HD and the other at SD. Assign a label that you can use for the output filename layers: new H264Layer[] { new H264Layer( bitrate: 1000000, maxBitrate: 1000000, label: "HD", bufferWindow: TimeSpan.FromSeconds(5), width: "1080", height: "720", referenceFrames: 3, entropyMode: "Cabac", adaptiveBFrame: true, frameRate: "0/1" ), new H264Layer( bitrate: 750000, maxBitrate: 750000, label: "SD", bufferWindow: TimeSpan.FromSeconds(5), width: "720", height: "480", referenceFrames: 3, entropyMode: "Cabac", adaptiveBFrame: true, frameRate: "0/1" ), new H264Layer( bitrate: 500000, maxBitrate: 500000, label: "HD", bufferWindow: TimeSpan.FromSeconds(5), width: "540", height: "360", referenceFrames: 3, entropyMode: "Cabac", adaptiveBFrame: true, frameRate: "0/1" ), new H264Layer( bitrate: 200000, maxBitrate: 200000, label: "HD", bufferWindow: TimeSpan.FromSeconds(5), width: "360", height: "240", referenceFrames: 3, entropyMode: "Cabac", adaptiveBFrame: true, frameRate: "0/1" ) } ), }, // Specify the format for the output files - one for video+audio, and another for the thumbnails formats: new Format[] { // Mux the H.264 video and AAC audio into MP4 files, using basename, label, bitrate and extension macros // Note that since you have multiple H264Layers defined above, you have to use a macro that produces unique names per H264Layer // Either {Label} or {Bitrate} should suffice new Mp4Format( filenamePattern: "Video-{Basename}-{Label}-{Bitrate}{Extension}" ) //,new PngFormat( // filenamePattern:"Thumbnail-{Basename}-{Index}{Extension}" //) } ), onError: OnErrorType.StopProcessingJob, relativePriority: Priority.Normal ) }; string description = "A simple custom encoding transform with 2 MP4 bitrates"; // Create the custom Transform with the outputs defined above transform = client.Transforms.CreateOrUpdate(amsconfig.ResourceGroup, amsconfig.AccountName, transformName, outputs, description); transformId = transform.Id; } } catch (ApiErrorException e) { log.Info($"ERROR: AMS API call failed with error code: {e.Body.Error.Code} and message: {e.Body.Error.Message}"); return(req.CreateResponse(HttpStatusCode.BadRequest, new { error = "AMS API call error: " + e.Message })); } return(req.CreateResponse(HttpStatusCode.OK, new { transformId = transformId })); }
public static async Task <object> Run([HttpTrigger(WebHookType = "genericJson")] HttpRequestMessage req, TraceWriter log) { log.Info($"AMS v3 Function - monitor_blob_copy_container_status was triggered!"); string jsonContent = await req.Content.ReadAsStringAsync(); dynamic data = JsonConvert.DeserializeObject(jsonContent); // Validate input objects if (data.destinationContainer == null) { return(req.CreateResponse(HttpStatusCode.BadRequest, new { error = "Please pass destinationContainer in the input object" })); } string destinationContainerName = data.destinationContainer; List <string> fileNames = null; if (data.fileNames != null) { fileNames = ((JArray)data.fileNames).ToObject <List <string> >(); } MediaServicesConfigWrapper amsconfig = new MediaServicesConfigWrapper(); bool copyStatus = true; //CopyStatus copyStatus = CopyStatus.Success; try { CloudBlobContainer destinationBlobContainer = BlobStorageHelper.GetCloudBlobContainer(_storageAccountName, _storageAccountKey, destinationContainerName); string blobPrefix = null; bool useFlatBlobListing = true; var destBlobList = destinationBlobContainer.ListBlobs(blobPrefix, useFlatBlobListing, BlobListingDetails.Copy); foreach (var dest in destBlobList) { var destBlob = dest as CloudBlob; if (destBlob.CopyState.Status == CopyStatus.Aborted || destBlob.CopyState.Status == CopyStatus.Failed) { // Log the copy status description for diagnostics and restart copy destBlob.StartCopyAsync(destBlob.CopyState.Source); //copyStatus = CopyStatus.Pending; copyStatus = false; } else if (destBlob.CopyState.Status == CopyStatus.Pending) { // We need to continue waiting for this pending copy // However, let us log copy state for diagnostics //copyStatus = CopyStatus.Pending; copyStatus = false; } // else we completed this pending copy } } catch (Exception e) { log.Info($"ERROR: Exception {e}"); return(req.CreateResponse(HttpStatusCode.BadRequest)); } return(req.CreateResponse(HttpStatusCode.OK, new { CopyStatus = copyStatus })); }
public static async Task <object> Run([HttpTrigger(WebHookType = "genericJson")] HttpRequestMessage req, TraceWriter log) { log.Info($"AMS v3 Function - create_transform was triggered!"); string jsonContent = await req.Content.ReadAsStringAsync(); dynamic data = JsonConvert.DeserializeObject(jsonContent); // Validate input objects if (data.transformName == null) { return(req.CreateResponse(HttpStatusCode.BadRequest, new { error = "Please pass transformName in the input object" })); } if (data.builtInStandardEncoderPreset == null && data.videoAnalyzerPreset == null) { return(req.CreateResponse(HttpStatusCode.BadRequest, new { error = "Please pass preset in the input object" })); } string transformName = data.transformName; MediaServicesConfigWrapper amsconfig = new MediaServicesConfigWrapper(); string transformId = null; try { IAzureMediaServicesClient client = CreateMediaServicesClient(amsconfig); // Does a Transform already exist with the desired name? Assume that an existing Transform with the desired name // also uses the same recipe or Preset for processing content. Transform transform = client.Transforms.Get(amsconfig.ResourceGroup, amsconfig.AccountName, transformName); if (transform == null) { // You need to specify what you want it to produce as an output var transformOutputList = new List <TransformOutput>(); // BuiltInStandardEncoderPreset if (data.builtInStandardEncoderPreset != null) { EncoderNamedPreset preset = EncoderNamedPreset.AdaptiveStreaming; if (data.builtInStandardEncoderPreset.presetName != null) { string presetName = data.builtInStandardEncoderPreset.presetName; if (encoderPreset.ContainsKey(presetName)) { preset = encoderPreset[presetName]; } } TransformOutput encoderTransform = new TransformOutput { // The preset for the Transform is set to one of Media Services built-in sample presets. // You can customize the encoding settings by changing this to use "StandardEncoderPreset" class. Preset = new BuiltInStandardEncoderPreset() { // This sample uses the built-in encoding preset for Adaptive Bitrate Streaming. PresetName = preset } }; transformOutputList.Add(encoderTransform); } // VideoAnalyzerPreset if (data.builtInStandardEncoderPreset != null) { bool audioInsightsOnly = false; string audioLanguage = "en-US"; if (data.videoAnalyzerPreset.audioInsightsOnly != null) { audioInsightsOnly = data.videoAnalyzerPreset.audioInsightsOnly; } if (data.videoAnalyzerPreset.audioLanguage != null) { audioLanguage = data.videoAnalyzerPreset.audioLanguage; } TransformOutput encoderTransform = new TransformOutput { // The preset for the Transform is set to one of Media Services built-in sample presets. // You can customize the encoding settings by changing this to use "StandardEncoderPreset" class. Preset = new VideoAnalyzerPreset(audioLanguage, audioInsightsOnly) }; transformOutputList.Add(encoderTransform); } // You need to specify what you want it to produce as an output TransformOutput[] output = transformOutputList.ToArray(); // Create the Transform with the output defined above transform = client.Transforms.CreateOrUpdate(amsconfig.ResourceGroup, amsconfig.AccountName, transformName, output); transformId = transform.Id; } } catch (ApiErrorException e) { log.Info($"ERROR: AMS API call failed with error code: {e.Body.Error.Code} and message: {e.Body.Error.Message}"); return(req.CreateResponse(HttpStatusCode.BadRequest, new { error = "AMS API call error: " + e.Message })); } return(req.CreateResponse(HttpStatusCode.OK, new { transformId = transformId })); }