我正在使用 Windows Azure Media Services .NET SDK 3 来利用流媒体服务。我想检索视频的持续时间。如何使用 Windows Azure 媒体服务 .NET SDK 3 检索视频的持续时间?
最佳答案
Azure 创建一些可以在持续时间内查询的元数据文件 (xml)。这些文件可以使用媒体服务扩展来访问
https://github.com/Azure/azure-sdk-for-media-services-extensions
在获取 Assets 元数据下:
// 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/