SALES: 1-800-867-1380
1 out of 1 rated this helpful - Rate this topic

Dynamic Packaging

Updated: September 27, 2013

Windows Azure Media Services can be used to deliver many media source file formats, media streaming formats, and content protection formats to a variety of client technologies (for example, iOS, XBOX, Silverlight, Windows 8). These clients understand different protocols, for example iOS requires an HTTP Live Streaming (HLS) V4 format and Silverlight and Xbox require Smooth Streaming. If you have a set of multi-bitrate MP4 (ISO Base Media 14496-12) files or Smooth Streaming files that you want to serve to clients that understand HLS or Smooth Streaming, you should take advantage of Media Services dynamic packaging.

With dynamic packaging all you need is to create an asset that contains a set of multi-bitrate MP4 files or multi-bitrate Smooth Streaming source files. Then, based on the specified format in the manifest or fragment request, the On-Demand Streaming server will ensure that you receive the stream in the protocol you have chosen. As a result, you only need to store and pay for the files in single storage format and Media Services service will build and serve the appropriate response based on requests from a client.

TraditionalEncodeandPackage

DynamicPackaging
noteNote
Currently, you cannot use Dynamic Packaging to deliver Smooth Streaming and HLS encrypted with PlayReady or Advanced Encryption Standard (AES). You can use Dynamic Packaging to deliver MPEG DASH encrypted with PlayReady.

ImportantImportant
To take advantage of dynamic packaging, you must first get at least one On-demand Streaming reserved units. For more information, see How to Scale a Media Service.

For an overview of Dynamic Packaging, see Introduction to dynamic packaging

This topic walks you through the steps of

You can download the code example from here: Dynamically Packaging Assets Sample

Set up your project

Preparing assets for dynamic streaming

To prepare your asset for dynamic streaming you have the two options described in this section.

noteNote
Not all MP4 file-formats are supported by dynamic packaging, for more information, see Unsupported formats for dynamic packaging.

Upload a master file and produce H.264 MP4 adaptive bitrate sets using the Azure Media Encoder

With this option, perform the following steps:

  1. Upload a single file.

  2. Run an encoding job to produce H.264 MP4 adaptive bitrate set. The following CreateEncodingJob method takes the asset object that was created by CreateAssetAndUploadSingleFile as a parameter. For information about other encoding preset strings, see Media Services Encoder System Presets.

    The CreateEncodingJob method makes calls to some helper methods that are defined in the Process Assets topic.

    static IJob CreateEncodingJob(IAsset asset)
    {
        // Declare a new job.
        IJob job = _context.Jobs.Create("My encoding job");
    
        // Get a media processor reference
        IMediaProcessor processor = GetLatestMediaProcessorByName("Azure Media Encoder");
    
        // Create a task with the encoding details, using a string preset.
        ITask task = job.Tasks.AddNew("My encoding task",
            processor,
            "H264 Adaptive Bitrate MP4 Set 720p",
            TaskOptions.None);
    
        // Specify the input asset to be encoded.
        task.InputAssets.Add(asset);
    
        // Add an output asset to contain the results of the job. 
        // This output is specified as AssetCreationOptions.None, which 
        // means the output asset is in the clear (unencrypted). 
        task.OutputAssets.AddNew("Output asset",
            AssetCreationOptions.None);
    
        // Use the following event handler to check job progress.  
        job.StateChanged += new
                EventHandler<JobStateChangedEventArgs>(StateChanged);
    
        // Launch the job.
        job.Submit();
    
        // Optionally log job details. This displays basic job details
        // to the console and saves them to a JobDetails-{JobId}.txt file 
        // in your output folder.
        LogJobDetails(job.Id);
    
        // Check job execution and wait for job to finish. 
        Task progressJobTask = job.GetExecutionProgressTask(CancellationToken.None);
        progressJobTask.Wait();
    
        // Get an updated job reference.
        job = GetJob(job.Id);
    
        return job;
    }
    
    
    The asset that contains the source files also needs to contain a server manifest (.ism) file that describes the relationships between media tracks, bitrates and files on disk. When you use the Azure Media Encoder, the manifest file is produced for you.

Upload existing adaptive bitrate sets and validate them using the Media Packager

With this option, you would typically perform the following steps:

  1. Upload multiple files from a local directory.

    If you plan to validate your files with Azure Media Packager (described in the next step), you must create your own manifest (.ism) file and upload it together with the source files into the Media Services account. Below is a sample of the .ism file produced by the Azure Media Encoder.

    WarningWarning
    Make sure the text in the .ism file is encoded with UTF-8.

    <?xml version="1.0" encoding="utf-8" standalone="yes"?>
    <smil xmlns="http://www.w3.org/2001/SMIL20/Language">
      <head>
    <!-- Tells the server that these input files are MP4s – specific to Dynamic Packaging -->
        <meta name="formats" content="mp4" /> 
      </head>
      <body>
        <switch>
          <video src="BigBuckBunny_1000.mp4" />
          <video src="BigBuckBunny_1500.mp4" />
          <video src="BigBuckBunny_2250.mp4" />
          <video src="BigBuckBunny_3400.mp4" />
          <video src="BigBuckBunny_400.mp4" />
          <video src="BigBuckBunny_650.mp4" />
          <audio src="BigBuckBunny_400.mp4" />
        </switch>
      </body>
    </smil>
    
    
  2. Run the Media Packager with the “MP4 validation task” to validate the asset uploaded to Media Services.

    You must pass a configuration xml string when creating a validation task. In this example the MediaPackager_ValidateTask.xml file is used, this file is defined in the Task Preset for Azure Media Packager topic.

    The ValidateMP4Asset method makes calls to some helper methods that are defined in the Process Assets topic.

    private static IJob ValidateMP4Asset(IAsset asset, string configFilePath)
    {
        SetISMFileAsPrimary(asset);
    
        // Declare a new job to contain the tasks.
        IJob job = _context.Jobs.Create("MP4 validation job.");
    
        // Set up the first task. 
    
        // Read the task configuration data into a string. 
        string configMp4Validation = File.ReadAllText(Path.GetFullPath(configFilePath + @"\MediaPackager_ValidateTask.xml"));
    
        // Get a media processor reference, and pass to it the name of the 
        // processor to use for the specific task.
        IMediaProcessor processor = GetLatestMediaProcessorByName("Azure Media Packager");
    
        // Create a task with the conversion details, using the configuration data. 
        ITask task = job.Tasks.AddNew("Mp4 Validation Task",
            processor,
            configMp4Validation,
            TaskOptions.None);
    
        // specify the input asset to be validated.
        task.InputAssets.Add(asset);
    
        // Add an output asset to contain the results of the job. 
        // This output is specified as AssetCreationOptions.None, which 
        // means the output asset is in the clear (unencrypted). 
        task.OutputAssets.AddNew("Output asset",
            AssetCreationOptions.None);
    
        // Use the following event handler to check job progress. 
        job.StateChanged += new  EventHandler<JobStateChangedEventArgs>(StateChanged);
    
        // Launch the job.
        job.Submit();
    
        // Optionally log job details
        LogJobDetails(job.Id);
    
        // Check job execution and wait for job to finish. 
        Task progressJobTask = job.GetExecutionProgressTask(CancellationToken.None);
        progressJobTask.Wait();
    
        // Get an updated job reference.
        job = GetJob(job.Id);
    
        return job;
    }
    
    static void SetISMFileAsPrimary(IAsset asset)
    {
        var ismAssetFiles = asset.AssetFiles.ToList().
            Where(f => f.Name.EndsWith(".ism", StringComparison.OrdinalIgnoreCase)).ToArray();
    
        if (ismAssetFiles.Count() != 1)
            throw new ArgumentException("The asset should have only one, .ism file");
    
        ismAssetFiles.First().IsPrimary = true;
        ismAssetFiles.First().Update();
    }
    
WarningWarning
If the On-Demand Streaming server is not able to parse your source files at runtime, you will receive HTTP 1.1 error “415 Unsupported Media Type”. Repeatedly causing the server to fail to parse your source files affects performance of the On-Demand Streaming server and may reduce the bandwidth available to serving other requests. Azure Media Services offers a Service Level Agreement (SLA) on its On-Demand Streaming services; however, this SLA cannot be honored if the server is misused in the fashion described above. Use the Azure Media Encoder to produce or the Azure Media Packager to validate your content in order to avoid runtime issues.

Streaming content

Once you have the adaptive bitrate sets on the Azure Media On-demand Streaming server, you can request a locator and compose the streaming URLs for Smooth and HLS.

ImportantImportant
Make sure to get at least one On-demand Streaming reserved units. For more information, see How to Scale a Media Service.

To stream the content from a client, you must request an origin locator and then append an appropriate format to the origin locator path. When a client requires Smooth Streaming format, append file.ism/Manifest to the locator path. When a client requires HLS, append file.ism/Manifest(format=m3u8-aapl)to the locator path. For example:

http://server.cloudapp.net/locator_guid/file.ism/Manifest
http://server.cloudapp.net/locator_guid/file.ism/Manifest(format=m3u8-aapl)

For more information about streaming the content see: How to create a locator and compose URLs.

Unsupported formats for dynamic packaging

The following source file formats are not supported by dynamic packaging.

  • Source files containing the following codecs:

    • Dolby digital plus mp4 files.

    • Dolby digital plus smooth files.

    noteNote
    These codecs are supported in the Azure Media Packager.

  • Protected content:

    • Storage Encrypted

    • PlayReady Protected Smooth Streaming

    • AES-128 CBC Protected HLS

    noteNote
    These codecs are supported in the Azure Media Encryptor and Azure Media Packager.

  • HLS sources:

    • PlayReady Protected HLS

    • IIS MS HLS archives

    • IIS MS HLS presentations from Transform Manager or the Media Services Packager

    • Segmented HLS

See Also


Build Date:

2014-04-10
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.