All Products
Search
Document Center

ApsaraVideo Media Processing:SubmitSnapshotJob

更新時間:Sep 27, 2024

Submits a snapshot job.

Operation description

  • Only JPG images can be generated by calling this operation.
  • Asynchronous mode: This operation may return a response before snapshots are captured. Snapshot jobs are queued in the background and asynchronously processed by ApsaraVideo Media Processing (MPS). If the Interval or Num parameter is set, the snapshot job is processed in asynchronous mode. For more information about FAQ about capturing snapshots, see FAQ about taking snapshots.
  • Notifications: When you submit a snapshot job, the PipelineId parameter is required. An asynchronous message is sent only after the notification feature is enabled for the MPS queue.

QPS limit

You can call this operation up to 50 times per second per account. Requests that exceed this limit are dropped and you will experience service interruptions. We recommend that you take note of this limit when you call this operation. For more information, see QPS limit.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer.

Authorization information

The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:

  • Operation: the value that you can use in the Action element to specify the operation on a resource.
  • Access level: the access level of each operation. The levels are read, write, and list.
  • Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
    • The required resource types are displayed in bold characters.
    • If the permissions cannot be granted at the resource level, All Resources is used in the Resource type column of the operation.
  • Condition Key: the condition key that is defined by the cloud service.
  • Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
OperationAccess levelResource typeCondition keyAssociated operation
mts:SubmitSnapshotJobcreate
  • All Resources
    *
    none
none

Request parameters

ParameterTypeRequiredDescriptionExample
InputstringYes

The information about the job input. The value must be a JSON object. You must add the Object Storage Service (OSS) bucket that stores the OSS object to be used as the job input as a media bucket in the MPS console. To add an OSS bucket as a media bucket, you can log on to the MPS console, choose Workflows > Media Buckets in the left-side navigation pane, and then click Add Bucket. After the OSS bucket is added as a media bucket, you must perform URL encoding for the OSS object. Example: {"Bucket":"example-bucket","Location":"example-location","Object":"example%2Ftest.flv"}. This example indicates the "example-bucket.example-location.aliyuncs.com/example/test.flv" object.

Note The OSS bucket must reside in the same region as your MPS service.
{"Bucket":"example-bucket","Location":"example-location","Object":"example%2Ftest.flv"}
SnapshotConfigstringYes

The snapshot configurations. For more information, see the "AliyunSnapshotConfig" section of the Data types topic.

Note If you set the Interval parameter that is nested under SnapshotConfig, snapshots are captured at the specified intervals. The default value of the Interval parameter is 10, in seconds. If an input video is short but you specify large values for both the Num and Interval parameters, the actual number of snapshots captured may be smaller than the specified number. For example, if you set the Num parameter to 5 and the Interval parameter to 3 for a video of 10 seconds, the number of snapshots captured cannot reach 5.
{"OutputFile":{"Bucket":"example-001","Location":"example-location","Object":"{Count}.jpg"},"Time":"5","Num":"10","Interval":"20"}
UserDatastringNo

The custom data. The custom data can contain letters, digits, and hyphens (-) and be up to 1,024 bytes in size. The custom data cannot start with a special character.

testid-001
PipelineIdstringNo

The ID of the MPS queue to which you want to submit the snapshot job. To obtain the ID, you can log on to the MPS console and choose Global Settings > Pipelines in the left-side navigation pane.

Note Make sure that an available Message Service (MNS) topic is bound to the specified MPS queue. Otherwise, the relevant messages may fail to be sent as expected.
dd3dae411e704030b921e52698e5****

Response parameters

ParameterTypeDescriptionExample
object

The response parameters.

RequestIdstring

The ID of the request.

19B6D8C5-A5DD-467A-B435-29D393C71E2D
SnapshotJobobject

The information about the snapshot job.

CreationTimestring

The time when the job was created.

2021-05-19T03:11:48Z
SnapshotConfigobject

The snapshot configurations.

Timestring

The start time for capturing snapshots. Unit: milliseconds.

5
TileOutobject

The tiling configurations.

Paddingstring

The distance between two consecutive single images in the tiled image.

  • Default value: 0.
  • Unit: pixel.
0
Colorstring

The background color.

  • Default value: black.
  • You can set the Color parameter to a color keyword or random in the request.
Note If you want to set the background color to black, you can specify the color keyword in one of the following three formats: Black, black, and #000000.
black
CellSelStepstring

The step for selecting a single image.

3
CellHeightstring

The height of a single image. The default value is the height of the output snapshot.

100
CellWidthstring

The width of a single image. The default value is the width of the output snapshot.

100
Marginstring

The margin width of the tiled image.

  • Default value: 0.
  • Unit: pixel.
5
Columnsstring

The number of columns that the tiled image contains. Default value: 10.

10
IsKeepCellPicstring

Indicates whether the single images are retained. Valid values:

  • true: The single images are retained.
  • false: The single images are not retained.
  • Default value: true.
false
Linesstring

The number of rows that the tiled image contains. Default value: 10.

10
Intervalstring

The interval for capturing snapshots.

  • If this parameter is specified in the request, snapshots are captured at intervals. The value must be greater than 0 in the request.
  • Unit: seconds.
  • Default value: 10.
20
FrameTypestring

The type of the snapshot. Default value: Normal. Valid values:

  • normal: normal frames.
  • intra: I-frames (keyframes).
Note If the FrameType parameter is set to intra in the request, only keyframes are captured. If no keyframe is found at the specified point in time, the keyframe closest to the specified point in time is captured. Keyframes are captured faster than normal frames if the same snapshot rules are applied.
intra
Widthstring

The width of the output snapshot.

8
Heightstring

The height of the output snapshot.

8
OutputFileobject

The information about the output file of the snapshot job.

RoleArnstring

The Alibaba Cloud Resource Name (ARN) of the specified RAM role. Format: acs:ram::$accountID:role/$roleName.

acs:ram::1:role/testrole
Objectstring

The OSS object that is generated as the output file of the snapshot job.

test.png
Locationstring

The OSS region in which the OSS bucket for storing the output snapshot resides.

example-location
Bucketstring

The OSS bucket that stores the output snapshot.

example
Numstring

The number of snapshots. If the Num parameter is set in the request, snapshots are captured at intervals.

10
TileOutputFileobject

The information about the output file of the tiling job.

RoleArnstring

The ARN of the specified RAM role. Format: acs:ram::$accountID:role/$roleName.

acs:ram::1:role/testrole
Objectstring

The OSS object that is generated as the output file of the tiling job.

example.png
Locationstring

The ID of the region in which the OSS bucket that stores the object is located.

example-location
Bucketstring

The OSS bucket that stores the object.

example
Statestring

The status of the snapshot job. Valid values:

  • Submitted: The job is submitted.
  • Snapshoting: The job is being processed.
  • Success: The job is successful.
  • Fail: The job fails.
Snapshoting
Messagestring

The error message returned if the job fails. This parameter is not returned if the job is successful.

The resource operated InputFile is bad
MNSMessageResultobject

The message sent by MNS to notify the user of the job result.

MessageIdstring

The ID of the message. This parameter is not returned if the job fails.

799454621135656C7F815F198A76****
ErrorMessagestring

The error message returned if the job fails. This parameter is not returned if the job is successful.

The resource operated InputFile is bad
ErrorCodestring

The error code returned if the job fails. This parameter is not returned if the job is successful.

InvalidParameter
Inputobject

The information about the job input.

RoleArnstring

The ARN of the specified RAM role. Format: acs:ram::$accountID:role/$roleName.

acs:ram::1:role/testrole
Objectstring

The OSS object that is used as the input file.

example.flv
Locationstring

The region in which the OSS bucket resides.

example-location'
Bucketstring

The OSS bucket that stores the object.

example
Countstring

The number of snapshots that are captured.

1
TileCountstring

The number of single images that are contained in the tiled image.

5
UserDatastring

The custom data.

testid-001
Codestring

The error code returned if the job fails. This parameter is not returned if the job is successful.

ResourceContentBad
PipelineIdstring

The ID of the MPS queue to which the snapshot job is submitted.

dd3dae411e704030b921e52698e5****
Idstring

The ID of the snapshot job.

f4e3b9ba9f3840c39d6e288056f0****

Examples

Sample success responses

JSONformat

{
  "RequestId": "19B6D8C5-A5DD-467A-B435-29D393C71E2D",
  "SnapshotJob": {
    "CreationTime": "2021-05-19T03:11:48Z",
    "SnapshotConfig": {
      "Time": "5",
      "TileOut": {
        "Padding": "0",
        "Color": "black",
        "CellSelStep": "3",
        "CellHeight": "100",
        "CellWidth": "100",
        "Margin": "5",
        "Columns": "10",
        "IsKeepCellPic": "false",
        "Lines": "10"
      },
      "Interval": "20",
      "FrameType": "intra",
      "Width": "8",
      "Height": "8",
      "OutputFile": {
        "RoleArn": "acs:ram::1:role/testrole",
        "Object": "test.png",
        "Location": "example-location",
        "Bucket": "example"
      },
      "Num": "10",
      "TileOutputFile": {
        "RoleArn": "acs:ram::1:role/testrole",
        "Object": "example.png",
        "Location": "example-location",
        "Bucket": "example"
      }
    },
    "State": "Snapshoting",
    "Message": "The resource operated InputFile is bad",
    "MNSMessageResult": {
      "MessageId": "799454621135656C7F815F198A76****",
      "ErrorMessage": "The resource operated InputFile is bad",
      "ErrorCode": "InvalidParameter"
    },
    "Input": {
      "RoleArn": "acs:ram::1:role/testrole",
      "Object": "example.flv",
      "Location": "example-location'",
      "Bucket": "example"
    },
    "Count": "1",
    "TileCount": "5",
    "UserData": "testid-001",
    "Code": "ResourceContentBad",
    "PipelineId": "dd3dae411e704030b921e52698e5****",
    "Id": "f4e3b9ba9f3840c39d6e288056f0****"
  }
}

Error codes

For a list of error codes, visit the Service error codes.

Change history

Change timeSummary of changesOperation
2024-04-24The response structure of the API has changedView Change Details
2024-04-10The internal configuration of the API is changed, but the call is not affectedView Change Details