使用自定义预设的azure媒体服务转码

时间:2016-10-31 02:47:48

标签: azure-webjobs video-encoding azure-media-services

我在azure web服务中使用webjob来处理视频的编码,默认预设不会修复VVS(视频旋转问题)和修剪视频选项。

当我使用自定义预设时,它将失败并且工作状态会从“已安排”'处理'然后到'错误'而不是'完成'。我无法弄明白。它不会抛出异常来知道错误是什么

链接到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); 
    }
  }
}

1 个答案:

答案 0 :(得分:0)

所以我使用Azure Media Encoder(AME),现在我改为Media Encoder Standard(MES)

IMediaProcessor processor = GetLatestMediaProcessorByName(&#34; Media Encoder Standard&#34;);