Overview
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, and Japanese.
The Azure Media Indexer 2 Preview MP is currently in Preview.
This topic shows how to create indexing jobs with Azure Media Indexer 2 Preview.
Note
The following considerations apply:
Indexer 2 is not supported in Azure China 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).
This topic gives details about Azure Media Indexer 2 Preview and shows how to use it with Media Services SDK for .NET
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.
{
"version":"1.0",
"Features":
[
{
"Options": {
"Formats":["WebVtt","ttml"],
"Language":"enUs",
"Type":"RecoOptions"
},
"Type":"SpReco"
}]
}
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]
- Mexican Spanish [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:
- Create an asset and upload a media file into the asset.
Create a job with an indexing task based on a configuration file that contains the following json preset.
{ "version":"1.0", "Features": [ { "Options": { "Formats":["WebVtt","ttml"], "Language":"enUs", "Type":"RecoOptions" }, "Type":"SpReco" }] }- 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.
Example
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 =
ConfigurationManager.AppSettings["AADTenantDomain"];
private static readonly string _RESTAPIEndpoint =
ConfigurationManager.AppSettings["MediaServiceRESTAPIEndpoint"];
// Field for service context.
private static CloudMediaContext _context = null;
static void Main(string[] args)
{
var tokenCredentials = new AzureAdTokenCredentials(_AADTenantDomain, AzureEnvironments.AzureCloudEnvironment);
var tokenProvider = new AzureAdTokenProvider(tokenCredentials);
_context = new CloudMediaContext(new Uri(_RESTAPIEndpoint), tokenProvider);
// Run indexing job.
var asset = RunIndexingJob(@"C:\supportFiles\Indexer\BigBuckBunny.mp4",
@"C:\supportFiles\Indexer\config.json");
// 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",
AssetCreationOptions.None);
// 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",
processor,
configuration,
TaskOptions.None);
// Specify the input asset to be indexed.
task.InputAssets.Add(asset);
// 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.
job.Submit();
// Check job execution and wait for job to finish.
Task progressJobTask = job.GetExecutionProgressTask(CancellationToken.None);
progressJobTask.Wait();
// 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}",
error.Code,
error.Message));
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));
assetFile.Upload(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)
.ToList()
.OrderBy(p => new Version(p.Version))
.LastOrDefault();
if (processor == null)
throw new ArgumentException(string.Format("Unknown media processor",
mediaProcessorName));
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();
Console.WriteLine("Job is finished.");
Console.WriteLine();
break;
case JobState.Canceling:
case JobState.Queued:
case JobState.Scheduled:
case JobState.Processing:
Console.WriteLine("Please wait...\n");
break;
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);
break;
default:
break;
}
}
}
}
Media Services learning paths
Read about the Azure Media Services learning paths:
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 Player
- Client SDK libraries
- Encoding and processing
- Live streaming
- Media Analytics
- Azure portal
- REST API and platform
- Video on-demand streaming

