如何从Azure媒体服务获取视频的持续时间? [英] How to get the duration of a video from the Azure media services?
本文介绍了如何从Azure媒体服务获取视频的持续时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用Windows Azure媒体服务.NET SDK 3来利用流服务.我想检索视频的时长.如何使用Windows Azure Media Services .NET SDK 3检索视频的持续时间?
I'm using the Windows Azure Media Services .NET SDK 3 to make use of the streaming services. I want to retrieve the duration of the video. How can I retrieve the duration of a video using the Windows Azure Media Services .NET SDK 3?
推荐答案
Azure创建了一些元数据文件(xml),可以在持续时间内对其进行查询.使用媒体服务扩展名可以访问这些文件
Azure creates some metadata files (xml) which could be queried for the duration. These files be accessed using the media-service extension
https://github.com/Azure/azure-sdk-for-media-services-extensions
在获取资产元数据"下:
Under Get Assets Meta Data:
// The asset encoded with the Windows Media Services Encoder. Get a reference to it from the context.
IAsset asset = null;
// Get a SAS locator for the asset (make sure to create one first).
ILocator sasLocator = asset.Locators.Where(l => l.Type == LocatorType.Sas).First();
// Get one of the asset files.
IAssetFile assetFile = asset.AssetFiles.ToList().Where(af => af.Name.EndsWith(".mp4", StringComparison.OrdinalIgnoreCase)).First();
// Get the metadata for the asset file.
AssetFileMetadata manifestAssetFile = assetFile.GetMetadata(sasLocator);
TimeSpan videoDuration = manifestAssetFile.Duration;
这篇关于如何从Azure媒体服务获取视频的持续时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文