Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
You may want your viewers to play only a section of a video. There are a couple ways to accomplish this:
- Use an asset filter.
- Submit subclipping jobs with the standard encoder on an output asset using an SDK.
Prerequisites
For using an asset filter:
- Read the Filters article to understand what filters are.
- Read Filter your manifests using Dynamic Packager to understand:
For setting up the output asset:
- Create an output asset. You can either:
- Create a live event and a live event output using the OBS quickstart or your preferred method, or
- Upload a media file with a of 5 seconds of video to be omitted at the beginning of the video at the beginning and end of the video and run it through an encoding job. Use the output asset created from the job for this exercise.
- If using a live event, run your live event for 2 minutes (or so), then stop it. You will be working with the live event output asset.
- Read the rest of this article.
Asset filter example
You can use the portal to create an asset filter to limit the content presented to your viewers. For this example, you are going to use one filter to filter out segments of time at the beginning and end of the video.
So, say the media’s entire length is 2 minutes or 120 seconds. The beginning shows some pre-production testing that is 5 seconds long and a “Thanks for watching” animation that is 5 seconds long at the end.
Since you want to exclude the beginning and the end of the video, the values in between the beginning and end values are what you will use for the start timestamp (6) and end timestamp (114).
Create an asset filter in the portal
- Sign into the portal.
- Navigate to the Media Services account you are working with.
- Select Assets.
- Select the output asset for your live event.
- Select Add an asset filter. The asset filter screen will appear.
- In the Asset filter name field, enter a name for your asset filter. Use something like 5offbegend to remind yourself of what the filter is delivering to viewers.
- In the Timescale field, change the value to 1.
- In the Start timestamp field, enter the start timestamp of 0.
- In the End timestamp field, enter 114.
- Select Save. The filter will appear in the Asset filters list.
Create a streaming locator
Your player client will use the filter in the query string of the request for the asset. To create that URL, create a streaming locator.
- One the same screen, select + New streaming locator. The streaming locator screen will appear.
- In the Name field, change the streaming locator name to 5offbegend-loc or something that tells you which filter was used for the streaming locator.
- From the Filters dropdown list, select the filter you just created.
- Select Add. The filter will be used when the streaming locator is requested by the player client.
Test the filter
- Copy or GET the streaming locator URL that is appropriate for your player.
- Use your player client or the Azure Media Player to test the streaming locator. The video should play only the content from 6 seconds to 115 seconds.
SDK example
Fork or download the Encoding a Live Archive to MP4 sample for Node.JS or Python.
Review the parts of the code that create a subclipping job:
- To create a subclipping job, first select the top bitrate video from either an encoding output asset or from a live event output archive asset (also called an archive) by selecting the track by attribute.
// Use this to select the top bitrate from the live archive asset
// The filter property allows you to select tht "Top" bitrate which would be the highest bitrate provided by the live encoder.
let videoTrackSelection: SelectVideoTrackByAttribute = {
odataType:"#Microsoft.Media.SelectVideoTrackByAttribute",
attribute: KnownTrackAttribute.Bitrate,
filter: KnownAttributeFilter.Top // use this to select the top bitrate in this ABR asset for the job
}
- Add the timestamp beginning and ending ranges to the track selection.
// Create a job input asset that points to the live event archive to be packaged to MP4 format.
// This is where we set up the track selection and optionally set a clip trimming on the live event to clip off start and end positions.
let input = factory.createJobInputAsset({
assetName: inputArchiveName,
start: {
odataType:"#Microsoft.Media.AbsoluteClipTime",
time: "PT30S" // Trim the first 30 seconds off the live archive.
},
end : {
odataType:"#Microsoft.Media.AbsoluteClipTime",
time: "PT5M30S" // Clip off the end after 5 minutes and 30 seconds.
},
inputDefinitions: [
factory.createFromAllInputFile({
includedTracks: [
videoTrackSelection // Pass in the SelectVideoTrackByAttribute object created above to select only the top video.
]
})
]
})
- Once the job is complete, create a streaming locator for the output asset, get the URL appropriate for your player client and test it.
Get help and support
You can contact Media Services with questions or follow our updates by one of the following methods:
- Q & A
- Stack Overflow. Tag questions with
azure-media-services
. - @MSFTAzureMedia or use @AzureSupport to request support.
- Open a support ticket through the Azure portal.