2

对于 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);
                }

            }
4

1 回答 1

4

您可以使用以下代码获取有关您的作业失败原因的更多信息,您可以在其中按 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);
            }
        }
       }
于 2012-10-30T13:38:20.320 回答