Azure媒体视频缩略图创建错误

时间:2014-12-28 22:03:48

标签: azure azure-media-services

在编码视频后创建缩略图时出现错误。我的脚本中没有任何错误,但是当我尝试在asp:image中加载url时,我收到以下错误

This XML file does not appear to have any style information associated with it. The document tree is shown below.
<Error>
ResourceNotFound
<Message>
The specified resource does not exist. RequestId:2224a828-0001-0011-4b57-900926000000 Time:2014-12-28T21:38:07.2803364Z
</Message>
</Error>

//Thumbnail Creation
IJob job1 = context.Jobs.Create("Thumbnail job");
IMediaProcessor processor1 = (from p in context.MediaProcessors where p.Name == "Windows Azure Media Encoder" select p).ToList().OrderBy(wame => new Version(wame.Version)).LastOrDefault();
ITask thumbnailTask = job1.Tasks.AddNew("Thumbnail Task", processor, "Thumbnails", TaskOptions.ProtectedConfiguration);
thumbnailTask.InputAssets.Add(inputAsset);
thumbnailTask.OutputAssets.AddNew(string.Format("{0} Thumbnails", CreateAsset), AssetCreationOptions.None);
job1.Submit();
job1.GetExecutionProgressTask(CancellationToken.None).Wait();
IAsset thumbnailAsset = job1.OutputMediaAssets[0];
var jpgAssetFile = thumbnailAsset.AssetFiles.ToList().Where(f => f.Name.EndsWith(".jpg", StringComparison.OrdinalIgnoreCase)).First();
IAccessPolicy thumbpolicy = context.AccessPolicies.Create("Streaming policy", TimeSpan.FromDays(365), AccessPermissions.Read);
ILocator thumboriginLocator = context.Locators.CreateLocator(LocatorType.OnDemandOrigin, thumbnailAsset, thumbpolicy, DateTime.UtcNow.AddMinutes(-5));

This XML file does not appear to have any style information associated with it. The document tree is shown below. <Error> ResourceNotFound <Message> The specified resource does not exist. RequestId:2224a828-0001-0011-4b57-900926000000 Time:2014-12-28T21:38:07.2803364Z </Message> </Error> //Thumbnail Creation IJob job1 = context.Jobs.Create("Thumbnail job"); IMediaProcessor processor1 = (from p in context.MediaProcessors where p.Name == "Windows Azure Media Encoder" select p).ToList().OrderBy(wame => new Version(wame.Version)).LastOrDefault(); ITask thumbnailTask = job1.Tasks.AddNew("Thumbnail Task", processor, "Thumbnails", TaskOptions.ProtectedConfiguration); thumbnailTask.InputAssets.Add(inputAsset); thumbnailTask.OutputAssets.AddNew(string.Format("{0} Thumbnails", CreateAsset), AssetCreationOptions.None); job1.Submit(); job1.GetExecutionProgressTask(CancellationToken.None).Wait(); IAsset thumbnailAsset = job1.OutputMediaAssets[0]; var jpgAssetFile = thumbnailAsset.AssetFiles.ToList().Where(f => f.Name.EndsWith(".jpg", StringComparison.OrdinalIgnoreCase)).First(); IAccessPolicy thumbpolicy = context.AccessPolicies.Create("Streaming policy", TimeSpan.FromDays(365), AccessPermissions.Read); ILocator thumboriginLocator = context.Locators.CreateLocator(LocatorType.OnDemandOrigin, thumbnailAsset, thumbpolicy, DateTime.UtcNow.AddMinutes(-5));

EDIT

IJob thumbjob = context.Jobs.Create("My Thumbnail job"); IMediaProcessor processor = (from p in context.MediaProcessors where p.Name == "Windows Azure Media Encoder" select p).ToList().OrderBy(wame => new Version(wame.Version)).LastOrDefault(); ITask task = thumbjob.Tasks.AddNew("My thumbnail task", processor, "Thumbnails", TaskOptions.ProtectedConfiguration); task.InputAssets.Add(inputAsset); task.OutputAssets.AddNew("Output asset", AssetCreationOptions.None); thumbjob.Submit();

        IAsset thumbnailAsset = context.Assets.Create(trainingfolder + "_" + Path.GetFileNameWithoutExtension(fileName) + "_thumb", AssetCreationOptions.None);
        IAccessPolicy accessPolicy = context.AccessPolicies.Create("Thumb Policy", TimeSpan.FromDays(30), AccessPermissions.Read | AccessPermissions.Write);
        ILocator locator = context.Locators.CreateLocator(LocatorType.Sas, thumbnailAsset, accessPolicy);

1 个答案:

答案 0 :(得分:0)

您是否阅读过the documentation

  

创建定位器后可能会有30-40秒的延迟   它可以使用。此问题适用于SAS URL和   OnDemandOrigin定位器。

使用Azure Media Services时,事情不是即时的。难怪您无法使用您提供的代码查看缩略图。我从未见过立即可用的定位器。我真的鼓励您查看this sample MVC web application中用于显示媒体服务基本概念的代码。有is a part in the code that also checks for existing locators / Access policies before creating new ones。您确实需要更好地管理资产。并考虑到these delays between creation and availability

相关问题