You can call the SubmitSegmentationJob operation to split a video into segments and call the GetSmartHandleJob operation to retrieve the results. For billing details, see Billing of smart segmentation.
-
Note: The region specified in the OSS URL of a media asset must be the same as the region of the OpenAPI endpoint that you call.
-
Supported regions: China (Shanghai), China (Beijing), China (Hangzhou), China (Shenzhen), US (West), and Singapore.
-
To use the custom segmentation feature, you must purchase the Basic subscription service. For more information about subscription billing, see Subscription-based billing.
Usage notes
-
For information about the OpenAPI operation for smart segmentation, see SubmitSegmentationJob. For descriptions of key parameters, see JobParams parameters, InputConfig parameters, and OutputConfig parameters in this topic.
-
To query the results of a smart segmentation Job, call the GetSmartHandleJob operation. For descriptions of key parameters in the Job response, see AiResult parameters.
JobParams parameters
Configure JobParams to specify the video shot segmentation policy.
|
Parameter |
Type |
Description |
Required |
|
Mode |
String |
The segmentation mode. Valid values:
|
Yes |
|
Ranges |
List<Range> |
The time ranges for custom segmentation. This parameter is required when Mode is set to UserDefined. |
No |
Range parameters
|
Parameter |
Type |
Description |
Required |
|
In |
Float |
The start time of the segment. Unit: seconds. Example: 0. |
Yes |
|
Out |
Float |
The end time of the segment. Unit: seconds. Example: 10. |
Yes |
Parameter example
{
"Mode": "UserDefined",
"Ranges": [
{
"In": 0,
"Out": 10
},
{
"In": 20,
"Out": 30
}
]
}
InputConfig parameters
Configure InputConfig to specify the source video.
|
Parameter |
Type |
Description |
Required |
|
Type |
String |
The media type. Select one of the following types:
|
Yes |
|
Media |
String |
|
Yes |
Parameter example
{
"Type": "Media",
"Media": "c5c62d8f0*********12dce8e77dc6d"
}
OutputConfig parameters
Configure OutputConfig to specify the output location and naming rules.
|
Parameter |
Type |
Description |
Required |
Example |
|
OutputMediaTarget |
String |
The target type of the output file.
|
Yes |
oss-object |
|
Endpoint |
String |
The endpoint that complies with the S3 protocol.
The default value is the OSS endpoint of the same region. |
No |
https://oss-cn-shanghai.aliyuncs.com |
|
Bucket |
String |
The storage bucket that complies with the S3 protocol.
|
Yes |
test-output |
|
ObjectKey |
String |
The object name that complies with the S3 protocol. Supported placeholder:
|
Yes |
dir/to/testOutput_{index}.mp4 |
|
ExportAsNewMedia |
Boolean |
Whether to export the output as a new media asset. This parameter is valid only when OutputMediaTarget is set to oss-object. |
No. The default value is false. |
false |
|
Width |
Integer |
The width of the output video. Unit: px. If you do not specify this parameter, the width of the source video is used. |
No |
1280 |
|
Height |
Integer |
The height of the output video. Unit: px. If you do not specify this parameter, the height of the source video is used. |
No |
720 |
|
JSONObject |
The output video stream settings, such as Crf and Codec. |
No |
{ "Bitrate": 3000 } |
Parameter example
{
"OutputMediaTarget": "oss-object",
"Endpoint": "https://oss-cn-shanghai.aliyuncs.com",
"Bucket": "test-output",
"ObjectKey": "dir/to/testOutput_{index}.mp4",
"ExportAsNewMedia": false,
"Width": 1280,
"Height": 720,
"Video": {
"Bitrate": 3000
}
}
GetSmartHandleJob response parameters
Call the GetSmartHandleJob operation to retrieve the segmentation results. The following section describes the AiResult parameters:
AiResult parameters
{
"SegmentationResult": {
"OutputEndpoint": "http://oss-cn-shanghai.aliyuncs.com", // The endpoint that complies with the S3 protocol
"OutputBucket": "test-output", // The bucket that complies with the S3 protocol
"OutputObjectResults": [ // The results after shot segmentation
{
"ObjectKey": "testOutput_0.mp4", // The object name that complies with the S3 protocol
"MediaId": "xxx1" // The ID of the media asset generated after shot segmentation
},
{
"ObjectKey": "testOutput_0.mp4",
"MediaId": "xxx2"
}
]
}
}