POST
/
video
/
clip
Clip Video
curl --request POST \
  --url https://mavi-backend.memories.ai/serve/api/v2/video/clip \
  --header 'Authorization: <api-key>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "asset_id": "re_657739295220518912"
}
'
{
  "code": "0000",
  "msg": "success",
  "data": {
    "task_id": "f432bc84bfd141d1b05c1d24af0abe6a"
  },
  "failed": false,
  "success": true
}
This endpoint creates a trimmed clip from a video by specifying start and end timestamps.

Code Examples

const response = await fetch('/video/clip', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'sk-8483027fe3abfe535f6ae01a9979b4f7'
  },
  body: JSON.stringify({
    asset_id: 're_657739295220518912'
  })
});

const data = await response.json();
console.log(data);

Request Body

FieldTypeRequiredDescription
asset_idstringYesThe video asset ID to create a clip from

Response

Returns task information for the video clip creation operation.
{
  "code": "0000",
  "msg": "success",
  "data": {
    "task_id": "f432bc84bfd141d1b05c1d24af0abe6a"
  },
  "failed": false,
  "success": true
}

Response Parameters

ParameterTypeDescription
codestringResponse code indicating the result status
msgstringResponse message describing the operation result
dataobjectResponse data object containing task information
data.task_idstringUnique identifier of the video clip creation task
successbooleanIndicates whether the operation was successful
failedbooleanIndicates whether the operation failed

Callback Response Parameters

When the video clipping is complete, a callback will be sent to your configured webhook URL.
ParameterTypeDescription
codestringResponse code (“0000” indicates success)
messagestringStatus message (e.g., “SUCCESS”)
dataobjectResponse data object containing scene segmentation results
data.dataobjectInner data object containing the clipping information
data.data.dataarrayArray of scene segments with frame ranges
data.data.data[].startintegerStarting frame number of the scene segment
data.data.data[].endintegerEnding frame number of the scene segment
data.data.exec_timenumberExecution time for the clipping operation in seconds
data.msgstringDetailed message about the clipping result
data.successbooleanIndicates whether the clipping was successful
task_idstringThe task ID associated with this clipping request

Understanding the Callback Response

The callback response contains an array of scene segments identified in the video, each with start and end frame numbers. Response Structure:
callback_response
├── code: "0000"
├── message: "SUCCESS"
├── data
│   ├── data
│   │   ├── data: [array of scene segments]
│   │   │   └── [
│   │   │       {
│   │   │         start: 0,
│   │   │         end: 46
│   │   │       },
│   │   │       {
│   │   │         start: 47,
│   │   │         end: 143
│   │   │       },
│   │   │       ...
│   │   │     ]
│   │   └── exec_time: 7.277834177017212
│   ├── msg: "Frame extraction completed successfully"
│   └── success: true
└── task_id: "a33f84793d0849f78825dc83c3b42671"
How to access the data:
  • Scene segments: callback_response.data.data.data
  • Number of scenes detected: callback_response.data.data.data.length
  • First scene start frame: callback_response.data.data.data[0].start
  • First scene end frame: callback_response.data.data.data[0].end
  • Execution time: callback_response.data.data.exec_time
  • Success status: callback_response.data.success
  • Task ID: callback_response.task_id
Frame Range Format: Each segment represents a continuous scene in the video:
  • start: The frame number where the scene begins (inclusive)
  • end: The frame number where the scene ends (inclusive)
  • Frame numbers are 0-indexed
  • Scenes are automatically detected based on visual content changes

Notes

  • Video clipping is processed asynchronously
  • Returns a task_id that can be used to track the clip creation progress
  • Use the task_id to query the status and results of clip creation
  • Original video remains unchanged

Authorizations

Authorization
string
header
required

Body

application/json
asset_id
string
required

The video asset ID to create a clip from

Example:

"re_657739295220518912"

Response

200 - application/json

Video clip creation initiated successfully

code
string

Response code indicating the result status

Example:

"0000"

msg
string

Response message describing the operation result

Example:

"success"

data
object

Response data object containing task information

success
boolean

Indicates whether the operation was successful

Example:

true

failed
boolean

Indicates whether the operation failed

Example:

false