Search code examples
azure-webjobsvideo-encodingazure-media-services

azure media service transcoding using custom preset


I am using webjob in azure web service to process the encoding of the video and default preset doesn't fix the VVS (video rotating issue) and trim video option.

When I use the custom preset then it will fail and job state changes from 'scheduled' to 'processing' then to 'Error' instead of 'finished'. I just can't figure it out. It doesn't throw exception to know what the error is either

link to my preset in xml.

https://drive.google.com/file/d/0BwaYuYfb7VCoSV9Ed0lOeUN5NDg/view

//MediaService.cs
var localPath = Environment.GetEnvironmentVariable("WEBJOBS_PATH");
var filePath = Path.Combine(localPath, "CustomPreset.xml");
string configuration = File.ReadAllText(filePath); 

var multibitrateTask = job.Tasks.AddNew("Custom Encoding Task", azureMediaEncoder, configuration, TaskOptions.None);
multibitrateTask.InputAssets.Add(mediaServiceAsset);
multibitrateTask.OutputAssets.AddNew($"Multibirate ouput for {mediaServiceAsset.Name}", AssetCreationOptions.None);

job = await job.SubmitAsync(); 

//function.cs
if (jobMessage.EventType == "JobStateChange")
{
 //try get old and new state
 if (jobMessage.Properties.Any(p => p.Key == "OldState") && jobMessage.Properties.Any(p => p.Key == "NewState"))
  {
    string oldJobState = jobMessage.Properties.First(p => p.Key == "OldState").Value.ToString();
    string newJobState = jobMessage.Properties.First(p => p.Key == "NewState").Value.ToString();

await log.WriteLineAsync(string.Format("job state has changed from {0} to {1}", oldJobState, newJobState));

string newState = jobMessage.Properties["NewState"].ToString();
     if (newState == "Finished") //<--fails here
     {
       string jobId = jobMessage.Properties["JobId"].ToString();
      var mediaServiceWrapper = new MediaServiceWrapper(_mediaServiceName, _mediaServiceKey, _azureStorageAccount);
      var result = await mediaServiceWrapper.PrepareAssetsForAdaptiveStreamingAsync(jobId); 
    }
  }
}

Solution

  • so I was using Azure Media Encoder (AME) and now I changed to Media Encoder Standard (MES)

    IMediaProcessor processor = GetLatestMediaProcessorByName("Media Encoder Standard");