编码Job时的Azure媒体服务为.wmv文件提供JobState.Error

时间:2012-09-08 10:06:41

标签: azure azure-storage azure-diagnostics

对于Azure媒体服务编码任务,状态显示处理....多次,然后进入错误状态。没有显示错误消息。 我正在关注这个https://www.windowsazure.com/en-us/develop/net/how-to-guides/media-services/#encode-asset 输入文件大小小于4Mb,cloudblobclient.ParallelOperationThreadCount = 2

   IJob job = _context.Jobs.Create("My encoding job");
                    IMediaProcessor processor = GetMediaProcessor(_context,"Windows Azure Media Encoder");
                    ITask task = job.Tasks.AddNew("My encoding task",processor, "H.264 256k DSL CBR",TaskCreationOptions.ProtectedConfiguration);

                    task.InputMediaAssets.Add(assetToBeProcessed); //where assetToBeProcessed is the IAsset Ref. 
                    task.OutputMediaAssets.AddNew("Outputasset",true, AssetCreationOptions.StorageEncrypted);
                    job.Submit();
                    CheckJobProgress(_context,job.Id);

      private static void CheckJobProgress(CloudMediaContext _context,string jobId)
            {
                bool jobCompleted = false;
                const int JobProgressInterval = 20000;
     while (!jobCompleted)
                {
                    IJob theJob = GetJob(_context,jobId); //brings the desired jobid
     switch (theJob.State)
                    {
                        case JobState.Finished: jobCompleted = true;break;
                        case JobState.Queued:
                        case JobState.Scheduled:
                        case JobState.Processing:
                                          break;
                        case JobState.Error:
                            break;
                        default:
                            break;
                    }
                    Thread.Sleep(JobProgressInterval);
                }

            }

1 个答案:

答案 0 :(得分:3)

您可以通过使用以下代码找到ID作业,然后打印其中所有任务的信息,以获取有关作业失败原因的更多信息。

var context = CloudMediaContext(acc, key);
var job = context.Jobs.Where(j => j.Id == id).Single();

Console.WriteLine("  Job ID: " + job.Id);
Console.WriteLine("  Name: " + job.Name);
Console.WriteLine("  State: " + job.State);

      foreach (var task in job.Tasks)
      {
             Console.WriteLine("  Task Id: " + task.Id);
             Console.WriteLine("  Name: " + task.Name);
             Console.WriteLine("  Progress: " + task.Progress);
             Console.WriteLine("  Configuration: " + task.Configuration);
             Console.WriteLine("  Running time: " + task.RunningDuration);
        if (task.ErrorDetails != null)
        {
            foreach (var errordetail in task.ErrorDetails)
            {

                Console.WriteLine("  Error Message:" + errordetail.Message);
                Console.WriteLine("  Error Code:" + errordetail.Code);
            }
        }
       }