Reduce your streaming bandwidth using Azure Media Services filters
Published Mar 29 2020 10:08 AM 3,118 Views
Microsoft

In times of high bandwidth utilization, you may wish to temporarily restrict the bitrates that are available in a streaming manifest to provide your customers a better streaming experience. Typically when encoding video with Azure Media Services, multiple streams with different bitrates are created. This allows clients with different connection speeds to select the most appropriate bandwidth for playback. Under normal circumstances this provides the best streaming experience for most clients. However, to reduce the bitrates offered you can use filters to temporarily limit the bandwidth that clients select for streaming.

 

Filters

There are several different features that filters provide when you need to restrict delivery during streaming. These include the ability to change the start and end times of a video, deliver only specific language tracks, etc. Also, filters can be applied to individual assets or globally. A global filter applies to the entire account. The feature that can be used to reduce bandwidth is the bitrate option. You can use the Azure CLI along with JSON to create a filter. The allowed bitrates can be set using a simple range. Note that you will need to make sure that the video assets you are applying this filter to have bitrate streams within the range you are specifying in this JSON.

There are several methods of creating a filter for Media Services including the Azure CLI, the .Net SDK, and PowerShell. One of the easiest is to use the ‘Try It’ option from within the Media Services REST documentation at https://docs.microsoft.com/rest/api/media/accountfilters/createorupdate. Navigate to this page, and beside the example PUT URL for creating a filter, click on Try It.

tryit.png

You will need to sign in to your Azure subscription if you’ve not already done so. Specify values for the subscriptionId, resourceGroupName, and accountName parameters for your Media Services account.  Next define the name of your filter by specifying a value for the filterName parameter. The default value for the api-version parameter can be left as is and you do not need to add any additional parameters or headers. Finally, paste the JSON below into the Body section of the form. This JSON will restrict the bitrate to 3 Mbps via the line: "value": "0-3000000". If you need to increase or decrease the maximum bitrate, you can adjust this value.

 

 

 

{
  "properties": {
    "presentationTimeRange": {
      "startTimestamp": null,
      "endTimestamp": null,
      "presentationWindowDuration": null,
      "liveBackoffDuration": null,
      "timescale": 10000000,
      "forceEndTimestamp": null
    },
    "firstQuality": null,
    "tracks": [
      {
        "trackSelections": [
          {
            "property": "Type",
            "operation": "Equal",
            "value": "Video"
          },
          {
            "property": "Bitrate",
            "operation": "Equal",
            "value": "0-3000000"
          }
        ]
      }
    ]
  }
}

 

 

 

 

Click the Run button to execute this script.

David_Bristol_1-1585501119825.png

The response code should be “Response Code: 201” and include the header and body of the response.

 

Streaming with filters

The next step is to add the filter parameter to your streaming URLs. Because Media Services dynamically packages the streaming content, the streaming manifests are built based on client request parameters. As discussed in https://docs.microsoft.com/azure/media-services/previous/media-services-dynamic-manifest-overview, the name of the filter is added to the manifest URL so that the Media Services streaming endpoint filters the manifests.

For a Smooth Streaming URL, you can add filter=filtername to the manifest URL like:

http://testendpoint-testaccount.streaming.mediaservices.windows.net/fecebb23-46f6-490d-8b70-203e86b0df58/BigBuckBunny.ism/Manifest(filter=MyFilter)

Or, if you are using multiple parameters, such as explicitly using the MPEG-DASH protocol, the URL would be:

http://testendpoint-testaccount.streaming.mediaservices.windows.net/fecebb23-46f6-490d-8b70-203e86b0...)

Since the filter is globally available for the entire Media Services account, any manifest URL request can use this same filter parameter.

 

Higher capacity

In addition to reducing the bandwidths available to clients, you can increase the resources that are available for streaming. There are two types of Media Services streaming endpoints. Premium streaming endpoints are suitable for advanced workloads and providing dedicated and scalable bandwidth capacity. The steps to scale premium endpoints are in https://docs.microsoft.com/azure/media-services/previous/media-services-portal-scale-streaming-endpo.... If you are using a standard streaming endpoint, it is a good idea to switch to a premium streaming endpoint prior to a large event so that you can scale without interruption.

During high demand events, you can monitor the streaming endpoint with diagnostic logging to best know, if you need to scale the premium streaming endpoint streaming units up or down based on the current load. Keep in mind that it can take a few minutes for additional streaming units to come online.

Co-Authors
Version history
Last update:
‎May 16 2022 12:17 PM
Updated by: