【问题标题】:How to implement Captioning in Azure Media services V3?如何在 Azure 媒体服务 V3 中实现字幕?
【发布时间】: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 文件)更新为媒体服务资产。有人可以帮助我吗?

【问题讨论】:

    标签: azure-media-services


    【解决方案1】:

    您只需像对待上传的视频一样对待字幕文件。唯一的区别是字幕文件将被放入已经有视频的资产中。换句话说,您需要上传视频,对其进行编码,然后在输出资产中上传 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 是您的输出资产的名称。

    【讨论】:

    • 亲爱的大卫 - 我尝试了同样的方法,并在视频编码后将 VTT 文件上传到输出资产中。我还添加了以下代码以获取要在 Azure 媒体播放器中运行的清单 URL。但是没有看到字幕 StreamingLocator locator = await CreateStreamingLocatorAsync(client, config.ResourceGroup, config.AccountName, outputAsset.Name, locatorName); IList urls = await GetStreamingUrlsAsync(client, config.ResourceGroup, config.AccountName, locator.Name); foreach (var url in url) { Console.WriteLine(url);}
    • 亲爱的大卫-我的完整代码已在social.msdn.microsoft.com/Forums/en-US/…分享
    • 正如 Anil 所说,如果您使用的是 Azure 媒体播放器,请确保单独添加到 VTT 的链接。请参阅the AMP sample 上的示例。
    【解决方案2】:

    您打算如何提供用于播放的字幕?对于Azure Media Player 中的示例,VTT 文件被添加为单独的 URL(来自 HLS 或 DASH 流 URL)。如果这可行,那么您可以简单地编辑流 URL 并添加 VTT 文件的文件名(如播放器页面中的示例之一所示)。

    但是,如果您需要通过其他 HLS 或 DASH 播放器播放字幕,则需要一些额外的步骤来显示字幕轨道以及视频和音频。部署某些服务更新后,我们将更新我们的文档页面。

    【讨论】:

    • 以下有什么更新吗? “部署某些服务更新后,我们将更新我们的文档页面。”
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多