我正在使用Windows Azure媒体服务.NET SDK 3来利用流服务。我想检索视频的时长。如何使用Windows Azure Media Services .NET SDK 3检索视频的持续时间?
最佳答案
Azure创建一些可以在持续时间内查询的元数据文件(xml)。使用媒体服务扩展名可以访问这些文件
https://github.com/Azure/azure-sdk-for-media-services-extensions
在获取资产元数据下:
// 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;
关于c# - 如何从Azure媒体服务获取视频的持续时间?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/29296205/