Learn how to trim a video segment from a single source asset using the RMS API. This guide provides API reference documentation, workflow steps, and troubleshooting guidance for video trimming.
In this article:
Before you begin:
- Authenticate using the RMS API Authentication.
- Upload a media file to use as the trim source (use RMS Console or your SDK).
Trimming concept
Video trimming extracts a single continuous segment from one source asset by specifying a start and end time. Stitching, by contrast, joins segments from one or more sources into a new timeline.
Common use cases:
- Remove unwanted footage from the beginning or end of a recording.
- Extract a highlight clip from a longer video.
Trimming runs as part of job processing, based on the preset.
API workflow
Use the following steps to build a trimming job:
1. Define the trim range
- Reference the source asset in the input parameters.
-
Set timing parameters:
- Set start time - when to begin the trimmed output.
- Set end time - when to end the trimmed output. Example: A source video has a total duration of 60 seconds. Setting a start time of
PT10Sand an end time ofPT45Sproduces a trimmed output 35 seconds long.
2. Create and specify the output asset
- Create the asset for the output result. Use the Asset - Create Or Update API call.
- Specify the output asset name where your trimmed video will be saved.
3. Submit the trimming job
The system automatically:
- Trims the source between the specified start and end time.
- Processes the trimmed segment using your selected transform, applying its encoding settings.
- Saves the final trimmed video to the specified asset.
The output inherits encoding settings from your selected transform, including the media format.
Construct a trimming request
Use this reference when building your API calls to trim a video.
PUT https://{{api-endpoint}}/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Media/mediaServices/{accountName}/transforms/{transformName}/jobs/{jobName}?api-version={{api-version}}Request URL structure:
-
api-endpoint: Placeholder for your RMS API endpoint. -
subscriptionId: This is your Azure subscription ID, a unique identifier for your Azure subscription. -
resourceGroup: The name of the resource group where your Media Services account is located. -
accountName: This is the name of your Media Services account. -
transformName: Select a transform - the predefined processing settings (resolution, bitrate, etc.). -
jobName: The job name. -
api-version={{api-version}}: This specifies the version of the AMS API you used. Any valid version number will work for your requests. Example:api-version=2018-07-01.
Request body:
{
"properties": {
"input": {
"@odata.type": "#Microsoft.Media.JobInputAsset",
"AssetName": "your-asset-name",
"start": {
"@odata.type": "#Microsoft.Media.AbsoluteClipTime",
"Time": "PT10S"
},
"end": {
"@odata.type": "#Microsoft.Media.AbsoluteClipTime",
"Time": "PT45S"
}
},
"outputs": [
{
"@odata.type": "#Microsoft.Media.JobOutputAsset",
"assetName": "trim1-name"
}
],
"priority": "Normal"
}
}Trimming uses a single JobInputAsset as the input property, since it operates on one source and does not need the JobInputSequence wrapper that stitching uses to order multiple inputs.
Parameters
Request body parameters used in the trimming request:
| Name | Required | Type | Description |
|---|---|---|---|
@odata.type: #Microsoft.Media.JobInputAsset |
True (one of JobInputAsset or JobInputHttp must be provided) |
string | Represents an Asset for input into a Job. Specify the asset name in the AssetName parameter. |
@odata.type: #Microsoft.Media.JobInputHttp |
string | Represents the HTTPS job input. Specify the URL in the baseUri parameter. |
|
| Time format: | |||
@odata.type: #Microsoft.Media.AbsoluteClipTime |
string |
Use AbsoluteClipTime with ISO 8601 duration format for the
UtcClipTime format is not supported. Use ISO 8601 format instead. |
|
| Other parameters: | |||
@odata.type: #Microsoft.Media.JobOutputAsset |
True | string | Represents an Asset used as a job output. This is an obligatory parameter to set the assetName for the output. |
Priority |
string | The priority with which the job should be processed. Higher-priority jobs are processed before lower-priority jobs. If not set, the default is normal. | |
Responses
| Name | Type | Description |
|---|---|---|
| 201 Created | Job | Created |
| Other Status Codes | ErrorResponse | Detailed error information. |
Sample response
Status code: 201
Response body:
{
"properties": {
"created": "2025-06-18T15:38:21.2990342Z",
"state": "Queued",
"input": {
"assetName": "your-asset-name",
"start": {
"time": "PT10S",
"@odata.type": "#Microsoft.Media.AbsoluteClipTime"
},
"end": {
"time": "PT45S",
"@odata.type": "#Microsoft.Media.AbsoluteClipTime"
},
"inputDefinitions": [],
"@odata.type": "#Microsoft.Media.JobInputAsset"
},
"lastModified": "2025-06-18T15:38:21.2990342Z",
"outputs": [
{
"assetName": "trim1-name",
"@odata.type": "#Microsoft.Media.JobOutputAsset",
"state": "Queued",
"progress": 0,
"label": "BuiltInStandardEncoderPreset_0"
}
],
"priority": "Normal"
},
"systemData": {
"createdBy": "system",
"createdByType": "Application",
"createdAt": "2025-06-18T15:38:21.2990342Z",
"lastModifiedBy": "system",
"lastModifiedByType": "Application",
"lastModifiedAt": "2025-06-18T15:38:21.2990342Z"
},
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mrg-yourresourceGroupName/providers/Microsoft.Media/mediaServices/default/transforms/StandardEncoder-AdaptiveStreaming/jobs/your-job-name",
"name": "your-job-name",
"type": "Microsoft.Media/mediaservices/transforms/jobs"
}
Considerations
General
- Without start and end time values, the job processes the entire source video and does not trim it.
- Trimming accepts a single input asset. To combine segments from multiple sources, or multiple segments from the same source, use stitching instead.
- RMS trims video only; audio-only files are not supported for trimming.
Preset and processing behavior
- Trimming works with any transform created using the
BuiltInStandardEncoderPresetpresets, or theStandardEncoderPresetcustom presets. - The preset determines whether trimming copies or re-encodes the segment. Copying skips re-encoding, so the trim finishes in seconds, no matter how long the segment is. Re-encoding takes longer - the longer the segment, the longer the job takes.
Recorded live streams
- For recorded ABR live streams, the trimmed output's quality renditions may not all start at the exact same timestamp - a carryover from the source recording, not a trimming error.
Troubleshooting
Encountering issues with video trimming jobs? Here are common problems and their solutions to restore your content processing:
- Verify that the end time does not exceed the source video duration. The job fails with a validation error if the end time is greater than the video duration.
-
Example: Asset has 45s in total timeline with start:
PT10S, end:PT50S(end is 5s longer than the timeline).
-
Example: Asset has 45s in total timeline with start:
- Check that the start time is less than the end time.
-
Example: Asset with start:
PT30S, end:PT10S(end is before start).
-
Example: Asset with start:
- Ensure timing values use a valid ISO 8601 format with no negative values.
To view job details, including trim boundaries, make a GET request to retrieve the job information.
Jobs with Error status include a complete error stack to help you address specific issues. If you still need assistance, contact Ravnur.