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

azure media service transcoding using custom preset

我在 azure 网络服务中使用 webjob 来处理视频编码,默认预设没有修复 VVS(视频旋转问题)和 trim 视频选项。

当我使用自定义预设时,它将失败并且作业状态从 'scheduled' 变为 'processing' 然后变为 'Error' 而不是 'finished'。我只是想不通。它不会抛出异常也知道错误是什么

link 到我在 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); 
    }
  }
}

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

IMediaProcessor 处理器 = GetLatestMediaProcessorByName("Media Encoder Standard");