首页 > 解决方案 > 如何在 Azure 媒体服务 V3 中实现字幕?

问题描述

如何使用.net SDK在azure media service 3中完成字幕

我正在使用 Azure 媒体服务 v3 教程(https://github.com/Azure-Samples/media-services-v3-dotnet-tutorials),但缺少如何将视频字幕文件(vtt 文件)更新为媒体服务资产使用.net SDK。一些身体可以帮助我吗?

标签: azure-media-services

解决方案


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


推荐阅读