Media Services v3 samples

media services logo v3


Looking for Media Services v2 documentation?

This article contains a list of all the samples available for Media Services organized by method and SDK. Samples include .NET, Node.js (TypeScript), Python and Java as well as REST with Postman.

Samples by SDK

You'll find description and links to the samples you may be looking for in each of the tabs.

Sample Description
Account/CreateAccount The sample shows how to create a Media Services account and set the primary storage account, in addition to advanced configuration settings including Key Delivery IP allowlist, Managed Identity, storage auth, and bring your own encryption key.
VideoEncoding/Encoding_PredefinedPreset The sample shows how to submit a job using a built-in preset and an HTTP URL input, publish output asset for streaming, and download results for verification.
VideoEncoding/Encoding_H264_ContentAware Demonstrates the most basic use of H.264 content-aware encoding without any constraints
VideoEncoding/Encoding_H264_ContentAware_Constrained Demonstrates how to use the PresetConfigurations class to constrain the output behavior of the preset
VideoEncoding/Encoding_H264 The sample shows how to submit a job using a custom H.264 encoding preset and an HTTP URL input, publish output asset for streaming, and download results for verification.
VideoEncoding/Encoding_HEVC_ContentAware Shows basic usage of the HEVC codec with content-aware encoding and no constraints. The PresetConfigurations class is also supported for HEVC and can be added to this sample
VideoEncoding/Encoding_HEVC The sample shows how to submit a job using a custom HEVC encoding preset and an HTTP URL input, publish output asset for streaming, and download results for verification.
VideoEncoding/Encoding_StitchTwoAssets The sample shows how to submit a job using the JobInputSequence to stitch together 2 or more assets that may be clipped by start or end time. The resulting encoded file is a single video with all assets stitched together. The sample will also publish output asset for streaming and download results for verification.
VideoEncoding/Encoding_SpriteThumbnail The sample shows how to submit a job using a custom preset with a thumbnail sprite and an HTTP URL input, publish output asset for streaming, and download results for verification.
Live/LiveEventWithDVR This sample first shows how to create a LiveEvent with a full archive up to 25 hours and a filter on the asset with 5 minutes DVR window, then it shows how to use the filter to create a locator for streaming.
VideoAnalytics/VideoAnalyzer This sample illustrates how to create a video analyzer transform, upload a video file to an input asset, submit a job with the transform and download the results for verification.
AudioAnalytics/AudioAnalyzer This sample illustrates how to create an audio analyzer transform, upload a media file to an input asset, submit a job with the transform and download the results for verification.
ContentProtection/BasicAESClearKey This sample demonstrates how to create a transform with built-in AdaptiveStreaming preset, submit a job, create a ContentKeyPolicy using a secret key, associate the ContentKeyPolicy with StreamingLocator, get a token and print a url for playback in Azure Media Player. When a stream is requested by a player, Media Services uses the specified key to dynamically encrypt your content with AES-128 and Azure Media Player uses the token to decrypt.
ContentProtection/BasicWidevine This sample demonstrates how to create a transform with built-in AdaptiveStreaming preset, submit a job, create a ContentKeyPolicy with Widevine configuration using a secret key, associate the ContentKeyPolicy with StreamingLocator, get a token and print a url for playback in a Widevine Player. When a user requests Widevine-protected content, the player application requests a license from the Media Services license service. If the player application is authorized, the Media Services license service issues a license to the player. A Widevine license contains the decryption key that can be used by the client player to decrypt and stream the content.
ContentProtection/BasicPlayReady This sample demonstrates how to create a transform with built-in AdaptiveStreaming preset, submit a job, create a ContentKeyPolicy with PlayReady configuration using a secret key, associate the ContentKeyPolicy with StreamingLocator, get a token and print a url for playback in an Azure Media Player. When a user requests PlayReady-protected content, the player application requests a license from the Media Services license service. If the player application is authorized, the Media Services license service issues a license to the player. A PlayReady license contains the decryption key that can be used by the client player to decrypt and stream the content.
ContentProtection/OfflinePlayReadyAndWidevine This sample demonstrates how to dynamically encrypt your content with PlayReady and Widevine DRM and play the content without requesting a license from license service. It shows how to create a transform with built-in AdaptiveStreaming preset, submit a job, create a ContentKeyPolicy with open restriction and PlayReady/Widevine persistent configuration, associate the ContentKeyPolicy with a StreamingLocator and print a url for playback.
Streaming/AssetFilters This sample demonstrates how to create a transform with built-in AdaptiveStreaming preset, submit a job, create an asset-filter and an account-filter, associate the filters to streaming locators and print urls for playback.
Streaming/StreamHLSAndDASH This sample demonstrates how to create a transform with built-in AdaptiveStreaming preset, submit a job, publish output asset for HLS and DASH streaming.
HighAvailabilityEncodingStreaming This sample provides guidance and best practices for a production system using on-demand encoding or analytics. Readers should start with the companion article High Availability with Media Services and VOD. There is a separate solution file provided for the HighAvailabilityEncodingStreaming sample.
Azure Functions for Media Services This project contains examples of Azure Functions that connect to Azure Media Services v3 for video processing. You can use Visual Studio 2019 or Visual Studio Code to develop and run the functions. An Azure Resource Manager (ARM) template and a GitHub Actions workflow are provided for the deployment of the Function resources and to enable continuous deployment.

REST Postman collection

The REST Postman samples include a Postman environment and collection for you to import into the Postman client. The Postman collection samples are recommended for getting familiar with the API structure and how it works with Azure Resource Management (ARM), as well as the structure of calls from the client SDKs.

Warning

It is not advised to attempt to wrap the REST API for Media Services directly into your own library code, as doing so properly for production purposes would require you to implement the full Azure Resource Management retry logic and understand how to manage long running operations in Azure Resource Management APIs. This is handled by the client SDKs for various language - .NET, Java, TypeScript, Python, Ruby, etc. - for you automatically and reduces the chances of you having issues with rety logic or failed API calls. The client SDKs all handle this for you already. The Postman collection is provided more as a teaching tool, and to show you what the client SDKs are actually doing on the wire during your development with the various client SDKs.