How to update a video caption file(vtt file) into a media service asset by using .net SDK RRS feed


All replies

  • Hi Hamendra,

    Have a look at the sample project. Specifically, in Program.cs you see a static method CreateInputAssetAsync that will create and upload the mp4 file an asset.

    Hope this helps, if not, please let us know.

    Thanks in advance, Ryan

    Tuesday, September 17, 2019 7:37 PM
  • Dear Ryan - As i understand CreateInputAssetAsync method is for uploading the MP4 file. Where as I am looking how to implement Captioning and update a video caption file(vtt file) into a media service asset by using .net SDK. Regards
    Wednesday, September 18, 2019 6:33 AM
  • My apologies for misunderstanding your question. I do see though that one of our engineers was able to answer question over on stackoverflow (

    Let us know if you need any further assistance.

    Thanks in advance, Ryan

    Wednesday, September 18, 2019 3:40 PM
  • Dear Ryan - I tried same and uploaded VTT file in output asset after video encode. I have and added below code as well to get the manifest URL to run in Azure Media Player. But did not see captions. Am I missing something ?

    private static async Task RunAsync(ConfigWrapper config)
                IAzureMediaServicesClient client = await CreateMediaServicesClientAsync(config);

                // Set the polling interval for long running operations to 2 seconds.
                // The default value is 30 seconds for the .NET client SDK
                client.LongRunningOperationRetryTimeout = 2;

                // Creating a unique suffix so that we don't have name collisions if you run the sample
                // multiple times without cleaning up.
                string uniqueness = Guid.NewGuid().ToString("N");
                string jobName = $"job-{uniqueness}";
                string locatorName = $"locator-{uniqueness}";
                string outputAssetName = $"output-{uniqueness}";
                string inputAssetName = $"input-{uniqueness}";

                // Ensure that you have the desired encoding Transform. This is really a one time setup operation.
                Transform transform = await GetOrCreateTransformAsync(client, config.ResourceGroup, config.AccountName, AdaptiveStreamingTransformName);

                // Create a new input Asset and upload the specified local video file into it.
                await CreateInputAssetAsync(client, config.ResourceGroup, config.AccountName, inputAssetName, InputMP4FileName);

                // Use the name of the created input asset to create the job input.
                JobInput jobInput = new JobInputAsset(assetName: inputAssetName);

                // Output from the encoding Job must be written to an Asset, so let's create one
                Asset outputAsset = await CreateOutputAssetAsync(client, config.ResourceGroup, config.AccountName, outputAssetName);

                Job job = await SubmitJobAsync(client, config.ResourceGroup, config.AccountName, AdaptiveStreamingTransformName, jobName, inputAssetName, outputAsset.Name);
                // In this demo code, we will poll for Job status
                // Polling is not a recommended best practice for production applications because of the latency it introduces.
                // Overuse of this API may trigger throttling. Developers should instead use Event Grid.
                job = await WaitForJobToFinishAsync(client, config.ResourceGroup, config.AccountName, AdaptiveStreamingTransformName, jobName);

                if (job.State == JobState.Finished)
                    Console.WriteLine("Job finished.");
                    //if (!Directory.Exists(OutputFolderName))
                    //    Directory.CreateDirectory(OutputFolderName);

                    //await DownloadOutputAssetAsync(client, config.ResourceGroup, config.AccountName, outputAsset.Name, OutputFolderName);

                    var response = await client.Assets.ListContainerSasAsync(
                    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(InputMP4FileName1));

                    // Use Strorage API to upload the file into the container in storage.
                    await blob.UploadFromFileAsync(InputMP4FileName1);

                    StreamingLocator locator = await CreateStreamingLocatorAsync(client, config.ResourceGroup, config.AccountName, outputAsset.Name, locatorName);

                    IList<string> urls = await GetStreamingUrlsAsync(client, config.ResourceGroup, config.AccountName, locator.Name);
                    foreach (var url in urls)

                Console.WriteLine("Done. Copy and paste the Streaming URL into the Azure Media Player at ''.");

    Wednesday, September 18, 2019 6:49 PM
  • Thursday, September 19, 2019 5:52 PM
  • Thanks Ryan. It works for me. Regards
    Friday, October 18, 2019 5:01 AM