Announcing Content Moderator on Azure Media Analytics

April 21, 2016 jason Uncategorized 0 Comments

Note: The following blog post describes a component of Azure Media Analytics. In order to learn more, please read the introductory blog post on Azure Media Analytics.

With the exponential growth of user generated content, it is even more important for businesses to monitor the content that is distributed to their users. In the past, businesses needed to employ human moderators to look at each piece of content, or worse yet, relied on their customers to alert them of content that violated their policies. Both of these methods have their costs. The former has a monetary cost that grows linearly as more content is added. The latter can devalue the organization’s brand and erode customer confidence.

To solve this problem, we created the Content Moderator service. Content Moderator enables customers to apply their unique set of contextual rules and policies and automatically detect questionable content in images and text.

Last week we announced our expansion into video moderation with a private preview of our new capability, the Content Moderator Media Processor! The Adult Classifier is the initial feature of this media processor, and additional features, including updates to this first classifier, will be coming soon. With this new capability, video monitoring can be automated, enabling the proactive detection of adult content in your video files. This can significantly lower the cost of your moderation efforts. Furthermore, gaining this type of early insight can enable businesses to make better decisions and create safer experiences for their customers.

Sign up to get access to the private preview of the Content Moderator Media Processor.

Getting started

Once you are granted access to the private preview, you can easily integrate the Content Moderator technology into your web or app offering using our REST API/SDKs, or with Azure Media Services Explorer.

The following is a sample C# program set that will get you started with your first Content Moderator job. This code requires both the Azure Media Services C# SDK and SDK Extensions packages (available on NuGet).

Sample program

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

namespace ContentModeratorAmsSample
    class Program
        // declare constants and globals
        private static CloudMediaContext _context = null;
        private static readonly string _accountName = { ACCOUNT_NAME };
        private static readonly string _accountKey = { ACCOUNT_KEY };
        private const string _mpName = "Azure Media Content Moderator";
        private static readonly string _inputFile = { INPUT_FILE_PATH };
        private static readonly string _outputFolder = { OUTPUT_FOLDER_PATH };
        //True if videos on the server should be scaled down false if not. 
        //Scaling the video down has better performance but could have some impact on the scoring
        private const bool _moderatorConfiguration = false;

        static void Main(string[] args)
            _context = new CloudMediaContext(_accountName, _accountKey);
            RunContentModeratorJob(_inputFile, _outputFolder, _moderatorConfiguration);

        static void RunContentModeratorJob(string inputFilePath, string output, bool scaleVideo)
            // create asset with input file
            IAsset asset = _context.Assets.CreateFromFile(inputFilePath, AssetCreationOptions.None);
            // grab instance of Azure Media Content Moderator MP
            IMediaProcessor mp = _context.MediaProcessors.GetLatestMediaProcessorByName(_mpName);

            // create Job with Content Moderator task
            IJob job = _context.Jobs.Create(String.Format("Content Moderator {0}", 
                Path.GetFileName(inputFilePath) + "_" + Guid.NewGuid()));

            ITask contentModeratorTask = job.Tasks.AddNew("Adult classifier task",
                scaleVideo ? "sdv=true" : "sdv=false",
            contentModeratorTask.OutputAssets.AddNew("Adult classifier output",


            // Create progress printing and querying tasks
            Task progressPrintTask = new Task(() =>
                IJob jobQuery = null;
                    var progressContext = _context;
                    jobQuery = progressContext.Jobs
                    .Where(j => j.Id == job.Id)
                while (jobQuery.State != JobState.Finished &&
                jobQuery.State != JobState.Error &&
                jobQuery.State != JobState.Canceled);

            Task progressJobTask = job.GetExecutionProgressTask(

            // 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}",

            DownloadAsset(job.OutputMediaAssets.First(), output);

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

        // event handler for Job State
        static 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 finished.");
                case JobState.Canceling:
                case JobState.Queued:
                case JobState.Scheduled:
                case JobState.Processing:
                    Console.WriteLine("Please wait...n");
                case JobState.Canceled:
                    Console.WriteLine("Job is canceled.n");
                case JobState.Error:
                    Console.WriteLine("Job failed.n");

Output XML

InputFileName: The name of the file, as saved on the input asset in Azure Media Services.

FileSize: The size of the input file in bytes.

AdultClassifierValue: Classifier score. The score is in a range of [0-1.0] where 0 is least likely to be adult and 1.0 is most likely.

TimeTakenMs: Time taken to execute the classification on the server.

Resized: Flag indicating whether or not the resize operation was performed.


Keep up with the Azure Media Services blog posts for more updates on the Content Moderator Media Processor and the Media Analytics initiative!

If you have questions about any of the Media Analytics products, send an email to

Source: Microsoft Azure News

Could not resolve host: