Indexing Media Files with Azure Media Indexer 2 Preview


The Azure Media Indexer 2 media processor will be retired on January 1 of 2020. Azure Media Services Video Indexer replaces this legacy media processor. For more information, see Migrate from Azure Media Indexer and Azure Media Indexer 2 to Azure Media Services Video Indexer.

The Azure Media Indexer 2 Preview media processor (MP) enables you to make media files and content searchable, as well as generate closed captioning tracks. Compared to the previous version of Azure Media Indexer, Azure Media Indexer 2 Preview performs faster indexing and offers broader language support. Supported languages include English, Spanish, French, German, Italian, Chinese (Mandarin, Simplified), Portuguese, Arabic, Russian, and Japanese.

The Azure Media Indexer 2 Preview MP is currently in Preview.

This article shows how to create indexing jobs with Azure Media Indexer 2 Preview.


The following considerations apply:

  • Indexer 2 is not supported in Azure China 21Vianet and Azure Government.
  • When indexing content, make sure to use media files that have very clear speech (without background music, noise, effects, or microphone hiss). Some examples of appropriate content are: recorded meetings, lectures, or presentations. The following content might not be suitable for indexing: movies, TV shows, anything with mixed audio and sound effects, poorly recorded content with background noise (hiss).

Input and output files

Input files

Audio or video files

Output files

An indexing job can generate closed caption files in the following formats:

  • SAMI
  • TTML
  • WebVTT

Closed Caption (CC) files in these formats can be used to make audio and video files accessible to people with hearing disability.

Task configuration (preset)

When creating an indexing task with Azure Media Indexer 2 Preview, you must specify a configuration preset.

The following JSON sets available parameters.

           "Options": {

Supported languages

Azure Media Indexer 2 Preview supports speech-to-text for the following languages (when specifying the language name in the task configuration, use 4-character code in brackets as shown below):

  • English [EnUs]
  • Spanish [EsEs]
  • Chinese (Mandarin, Simplified) [ZhCn]
  • French [FrFr]
  • German [DeDe]
  • Italian [ItIt]
  • Portuguese [PtBr]
  • Arabic (Egyptian) [ArEg]
  • Japanese [JaJp]
  • Russian [RuRu]
  • British English [EnGb]
  • Spanish (Mexico) [EsMx] 

Supported file types

For information about supported files types, see the supported codecs/formats section.

.NET sample code

The following program shows how to:

  1. Create an asset and upload a media file into the asset.

  2. Create a job with an indexing task based on a configuration file that contains the following json preset:

                "Options": {
  3. Download the output files.

Create and configure a Visual Studio project

Set up your development environment and populate the app.config file with connection information, as described in Media Services development with .NET.


using System;
using System.Configuration;
using System.IO;
using System.Linq;
using Microsoft.WindowsAzure.MediaServices.Client;
using System.Threading;
using System.Threading.Tasks;

namespace IndexContent
    class Program
        // Read values from the App.config file.
        private static readonly string _AADTenantDomain =
        private static readonly string _RESTAPIEndpoint =
        private static readonly string _AMSClientId =
        private static readonly string _AMSClientSecret =

        // Field for service context.
        private static CloudMediaContext _context = null;

        static void Main(string[] args)
            AzureAdTokenCredentials tokenCredentials =
                new AzureAdTokenCredentials(_AADTenantDomain,
                    new AzureAdClientSymmetricKey(_AMSClientId, _AMSClientSecret),

            var tokenProvider = new AzureAdTokenProvider(tokenCredentials);

            _context = new CloudMediaContext(new Uri(_RESTAPIEndpoint), tokenProvider);

            // Run indexing job.
            var asset = RunIndexingJob(@"C:\supportFiles\Indexer\BigBuckBunny.mp4",

            // Download the job output asset.
            DownloadAsset(asset, @"C:\supportFiles\Indexer\Output");

        static IAsset RunIndexingJob(string inputMediaFilePath, string configurationFile)
            // Create an asset and upload the input media file to storage.
            IAsset asset = CreateAssetAndUploadSingleFile(inputMediaFilePath,
                "My Indexing Input Asset",

            // Declare a new job.
            IJob job = _context.Jobs.Create("My Indexing Job");

            // Get a reference to Azure Media Indexer 2 Preview.
            string MediaProcessorName = "Azure Media Indexer 2 Preview";

            var processor = GetLatestMediaProcessorByName(MediaProcessorName);

            // Read configuration from the specified file.
            string configuration = File.ReadAllText(configurationFile);

            // Create a task with the encoding details, using a string preset.
            ITask task = job.Tasks.AddNew("My Indexing Task",

            // Specify the input asset to be indexed.

            // Add an output asset to contain the results of the job.
            task.OutputAssets.AddNew("My Indexing Output Asset", AssetCreationOptions.None);

            // Use the following event handler to check job progress.  
            job.StateChanged += new EventHandler<JobStateChangedEventArgs>(StateChanged);

            // Launch the job.

            // Check job execution and wait for job to finish.
            Task progressJobTask = job.GetExecutionProgressTask(CancellationToken.None);


            // If job state is Error, the event handling
            // method for job progress should log errors.  Here we check
            // for error state and exit if needed.
            if (job.State == JobState.Error)
                ErrorDetail error = job.Tasks.First().ErrorDetails.First();
                Console.WriteLine(string.Format("Error: {0}. {1}",
                return null;

            return job.OutputMediaAssets[0];

        static IAsset CreateAssetAndUploadSingleFile(string filePath, string assetName, AssetCreationOptions options)
            IAsset asset = _context.Assets.Create(assetName, options);

            var assetFile = asset.AssetFiles.Create(Path.GetFileName(filePath));

            return asset;

        static void DownloadAsset(IAsset asset, string outputDirectory)
            foreach (IAssetFile file in asset.AssetFiles)
                file.Download(Path.Combine(outputDirectory, file.Name));

        static IMediaProcessor GetLatestMediaProcessorByName(string mediaProcessorName)
            var processor = _context.MediaProcessors
                .Where(p => p.Name == mediaProcessorName)
                .OrderBy(p => new Version(p.Version))

            if (processor == null)
                throw new ArgumentException(string.Format("Unknown media processor",

            return processor;

        static private void StateChanged(object sender, JobStateChangedEventArgs e)
            Console.WriteLine("Job state changed event:");
            Console.WriteLine("  Previous state: " + e.PreviousState);
            Console.WriteLine("  Current state: " + e.CurrentState);

            switch (e.CurrentState)
                case JobState.Finished:
                    Console.WriteLine("Job is finished.");
                case JobState.Canceling:
                case JobState.Queued:
                case JobState.Scheduled:
                case JobState.Processing:
                    Console.WriteLine("Please wait...\n");
                case JobState.Canceled:
                case JobState.Error:
                    // Cast sender as a job.
                    IJob job = (IJob)sender;
                    // Display or log error details as needed.
                    // LogJobStop(job.Id);

Media Services learning paths

Media Services v3 (latest)

Check out the latest version of Azure Media Services!

Media Services v2 (legacy)

Provide feedback

Use the User Voice forum to provide feedback and make suggestions on how to improve Azure Media Services. You also can go directly to one of the following categories:

Azure Media Services Analytics Overview

Azure Media Analytics demos