【发布时间】:2019-09-20 01:35:42
【问题描述】:
如何使用.net SDK在azure media service 3中完成字幕
我正在使用 Azure 媒体服务 v3 教程 (https://github.com/Azure-Samples/media-services-v3-dotnet-tutorials),但缺少如何使用 .net SDK 将视频字幕文件(vtt 文件)更新为媒体服务资产。有人可以帮助我吗?
【问题讨论】:
如何使用.net SDK在azure media service 3中完成字幕
我正在使用 Azure 媒体服务 v3 教程 (https://github.com/Azure-Samples/media-services-v3-dotnet-tutorials),但缺少如何使用 .net SDK 将视频字幕文件(vtt 文件)更新为媒体服务资产。有人可以帮助我吗?
【问题讨论】:
您只需像对待上传的视频一样对待字幕文件。唯一的区别是字幕文件将被放入已经有视频的资产中。换句话说,您需要上传视频,对其进行编码,然后在输出资产中上传 VTT 文件。
从代码的角度来看,您会使用:
// Use Media Services API to get back a response that contains
// SAS URL for the Asset container into which to upload blobs.
// That is where you would specify read-write permissions
// and the exparation time for the SAS URL.
var response = await client.Assets.ListContainerSasAsync(
resourceGroupName,
accountName,
assetName,
permissions: AssetContainerPermission.ReadWrite,
expiryTime: DateTime.UtcNow.AddHours(4).ToUniversalTime());
var sasUri = new Uri(response.AssetContainerSasUrls.First());
// Use Storage API to get a reference to the Asset container
// that was created by calling Asset's CreateOrUpdate method.
CloudBlobContainer container = new CloudBlobContainer(sasUri);
var blob = container.GetBlockBlobReference(Path.GetFileName(fileToUpload));
// Use Strorage API to upload the file into the container in storage.
await blob.UploadFromFileAsync(fileToUpload);
其中assetName 是您的输出资产的名称。
【讨论】:
您打算如何提供用于播放的字幕?对于Azure Media Player 中的示例,VTT 文件被添加为单独的 URL(来自 HLS 或 DASH 流 URL)。如果这可行,那么您可以简单地编辑流 URL 并添加 VTT 文件的文件名(如播放器页面中的示例之一所示)。
但是,如果您需要通过其他 HLS 或 DASH 播放器播放字幕,则需要一些额外的步骤来显示字幕轨道以及视频和音频。部署某些服务更新后,我们将更新我们的文档页面。
【讨论】: