问题
How to complete captioning in azure media service 3by using .net SDK
I am using Azure Media Services v3 tutorials (https://github.com/Azure-Samples/media-services-v3-dotnet-tutorials) but missing How to update a video caption file(vtt file) into a media service asset by using .net SDK. Can some body help me on same.
回答1:
You would simply treat the caption file the same way as you would a video that you upload. The only difference is that the caption file would be put into an asset that already has video. In other words, you'd upload your video, encode it, and in the output asset you'd upload the VTT file.
From a code perspective you would use:
// 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);
Where assetName is the name of your output asset.
回答2:
How were you planning to deliver captions for playback? For the example in the Azure Media Player, the VTT file is added as a separate URL (from the HLS or DASH streaming URL). If this works, then you can simply edit the streaming URL and add the file name of the VTT file (as shown in one of the examples in the player page).
If, however, you need playback of captions via other HLS or DASH players, then there are some additional steps needed to expose the captions track along with video and audio. We will update our documentation pages when certain service updates have been deployed.
来源:https://stackoverflow.com/questions/57986861/how-to-implement-captioning-in-azure-media-services-v3