我使用 Windows Azure Media Services .NET SDK 3 来利用流媒体服务。我想检索视频的持续时间。如何使用 Windows Azure Media Services .NET SDK 3 检索视频的持续时间?
Azure 创建一些可以在持续时间内查询的元数据文件 (xml)。这些文件可以使用媒体服务扩展来访问
https://github.com/Azure/azure-sdk-for-media-services-extensions 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;
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)