Object Tracking
Draw a box around one target on a single frame of a video (or of a time-ordered image sequence). The system tracks that one target forward and backward from that frame and returns a per-frame track: box, smoothed box, confidence, visibility and source, plus optional per-frame masks. Use it for tracked stickers, tracked mosaics, tracked crops, and anything else where a selection has to follow an object through the shot.
- Only the boxed target is tracked. The box is not treated as a category example, so other objects of the same kind are never returned (box the front wheel and the rear wheel will not appear in the result).
- Up to 16 targets per task, each tracked independently.
- One analysis range is at most 1 minute. For longer videos, use
time_rangeto pick the part you need. - To find every face in a video automatically and cluster them by identity, use Multi-Face Tracking & Identity Clustering.
Create Task
Basic Information
| Item | Value |
|---|---|
| Request Method | POST |
| Request Path | /task/video_object_track |
| Content-Type | application/json |
| Authentication | Raw API key in the Authorization header |
Request Body
Provide exactly one of file_id and frame_file_ids: the first is a video, the second a time-ordered list of images.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
file_id | string | One of two | - | Uploaded video file ID |
frame_file_ids | array | One of two | - | Frame sequence: uploaded image file IDs in time order, 2-1500 images, all of the same width and height |
frame_interval_ms | integer | No | 1000 | Time between two consecutive frames (ms), range 40-10000; frame sequences only. Image count × interval must not exceed 60000 |
rois | array | Yes | - | Targets to track, 1-16 items using at most 4 distinct prompt frames; see the table below |
time_range | object | No | Whole video | Video input only: analyze one part, { "begin_time": 0, "end_time": 30000 } (ms), at most 60000 long. Without it the whole video must be 60 seconds or shorter |
sample_fps | number | No | 5 | Video input only: analysis frame rate, which is also the track point density, range 1-30; capped at the source frame rate |
return_mask | boolean | No | false | Whether to also produce a per-frame mask file (COCO RLE) |
Each item of rois[]:
| Field | Type | Required | Description |
|---|---|---|---|
box | array | Yes | The target's box on the prompt frame, normalized [x1, y1, x2, y2] with 0 ≤ x1 < x2 ≤ 1 and 0 ≤ y1 < y2 ≤ 1 |
time_ms | number | Required for video input | Time of the box (ms, source timeline); must fall inside the analysis range |
frame_index | integer | Required for frame sequences | Index of the frame the box is on, starting at 0, less than the number of frame_file_ids |
label | string | No | Your own label, at most 32 characters, echoed back as is |
- The prompt frame may sit in the middle of the range: tracking runs both forward and backward from it to both ends of the analysis range.
- Targets boxed on the same frame share one prompt frame. Each distinct prompt frame needs its own bidirectional pass, hence the limit of 4.
- Video input must not carry
frame_index/frame_interval_ms; frame-sequence input must not carrytime_ms/time_range/sample_fps.
Request Example
Video, one target boxed at 5 seconds:
curl -X POST https://api.ai-mcn.tv:10000/task/video_object_track \
-H "Authorization: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"file_id": "537489015178246",
"rois": [
{"box": [0.37, 0.57, 0.40, 0.67], "time_ms": 5000, "label": "wheel"}
]
}'
Track 30 seconds of a longer video, two targets on the same frame, fast motion so the analysis rate is raised to 10, with masks:
curl -X POST https://api.ai-mcn.tv:10000/task/video_object_track \
-H "Authorization: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"file_id": "537489015178246",
"time_range": {"begin_time": 60000, "end_time": 90000},
"sample_fps": 10,
"return_mask": true,
"rois": [
{"box": [0.10, 0.30, 0.42, 0.88], "time_ms": 72000, "label": "car"},
{"box": [0.55, 0.20, 0.70, 0.60], "time_ms": 72000, "label": "rider"}
]
}'
Frame sequence, 10 images 200 ms apart, target boxed on image 0:
curl -X POST https://api.ai-mcn.tv:10000/task/video_object_track \
-H "Authorization: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"frame_file_ids": ["537489015178301", "537489015178302", "537489015178303", "537489015178304", "537489015178305", "537489015178306", "537489015178307", "537489015178308", "537489015178309", "537489015178310"],
"frame_interval_ms": 200,
"rois": [
{"box": [0.40, 0.50, 0.55, 0.80], "frame_index": 0}
]
}'
Success Response Example
{
"code": 200,
"msg": "success",
"data": {
"task_id": "537489015178247",
"task_type": "video_object_track",
"status": "queued"
}
}
Query Task
| Item | Value |
|---|---|
| Request Method | GET |
| Request Path | /task/video_object_track/{task_id} |
| Authentication | Raw API key in the Authorization header |
output_result Fields
Per-frame data is not in output_result; it is written to the track file (and the optional mask file). output_result only holds input information, a summary per target and the file references, so its size does not grow with the video length.
| Field | Type | Description |
|---|---|---|
version | string | Output schema version, video_object_track.v1 |
source | object | Input information, see below |
objects | array | One item per target, in rois order, see below |
tracks_file_id | string | Track file ID (JSON) |
tracks_download_url | string | Track file download path |
masks_file_id | string | Mask file ID (JSON); only when return_mask=true |
masks_download_url | string | Mask file download path; only when return_mask=true |
source:
| Field | Description |
|---|---|
type | video or frames |
width / height | Width and height of the source video or source frames (pixels) |
duration_ms | Full video duration; for frame sequences, image count × frame_interval_ms |
fps | Source frame rate (video only) |
analysis_begin_ms / analysis_end_ms | Actual analysis range (video only) |
analysis_fps | Actual analysis frame rate (video only; the source frame rate when sample_fps exceeds it) |
frame_interval_ms | Frame interval (frame sequences only) |
analysis_width / analysis_height | Analysis resolution, which is also the mask resolution |
analysis_frame_count | Number of analyzed frames, i.e. the length of frames in the track file |
objects[]:
| Field | Description |
|---|---|
obj_id | Target number, from 1 in rois order, stable within the task |
label | The label from the request, null if not given |
prompt | The prompt from the request: box plus time_ms (video) or frame_index (frame sequence) |
summary.visible_ratio | Share of analyzed frames in which the target is visible, 0-1 |
summary.first_visible_ms / summary.last_visible_ms | First and last visible time (ms); null if never visible |
summary.mean_score | Mean confidence over visible frames (interpolated frames excluded) |
summary.lost_segments | Invisible stretches [[begin_ms, end_ms], ...], where end_ms is the time of the stretch's last frame; sorted longest first, at most 50 |
summary.lost_segments_truncated | true when there were more than 50 invisible stretches and the list was cut |
Track File
JSON, with one frames entry per analyzed frame in time order:
{
"version": "video_object_track.v1",
"source": {"type": "video", "width": 1920, "height": 1080, "fps": 29.97, "duration_ms": 16700, "analysis_begin_ms": 0, "analysis_end_ms": 16700, "analysis_fps": 5.0, "analysis_width": 1008, "analysis_height": 568, "analysis_frame_count": 84},
"frames": [
{"i": 25, "t": 5000, "objects": [
{"obj_id": 1, "visible": true, "score": 1.0, "bbox": [0.37, 0.57, 0.40, 0.67], "bbox_smooth": [0.371, 0.571, 0.401, 0.669], "source": "prompt"}
]},
{"i": 26, "t": 5200, "objects": [
{"obj_id": 1, "visible": true, "score": 0.83, "bbox": [0.38, 0.57, 0.41, 0.67], "bbox_smooth": [0.379, 0.571, 0.409, 0.670], "source": "model"}
]},
{"i": 43, "t": 8600, "objects": [
{"obj_id": 1, "visible": false, "score": 0.12, "bbox": null, "bbox_smooth": null, "source": null}
]}
]
}
| Field | Description |
|---|---|
i | Analyzed frame index, from 0 |
t | Time of the frame on the source timeline (ms); for frame sequences i × frame_interval_ms |
objects[].visible | Whether the target is visible in this frame |
objects[].score | Model confidence that this frame still shows the original target, 0-1 |
objects[].bbox | Box taken directly from this frame's result, normalized [x1, y1, x2, y2]; null when not visible |
objects[].bbox_smooth | Box after forward-backward smoothing over visible stretches; use this one for stickers and crops; null when not visible |
objects[].source | prompt (prompt frame), model (tracked by the model) or interpolated (short gap filled by interpolation); null when not visible |
Mask File
Only produced when return_mask=true. JSON; the mask resolution equals the analysis resolution. masks has one entry per visible target per frame; interpolated and invisible frames have no mask:
{
"version": "video_object_track.v1",
"mask_width": 1008,
"mask_height": 568,
"masks": [
{"i": 25, "obj_id": 1, "rle": {"size": [568, 1008], "counts": "Xk`b0..."}}
]
}
rle is COCO compressed RLE and decodes to a binary mask with pycocotools:
from pycocotools import mask as mask_utils
binary = mask_utils.decode(item["rle"]) # shape (mask_height, mask_width), values 0 / 1
Completed Result Example
{
"code": 200,
"msg": "success",
"data": {
"task_id": "537489015178247",
"status": "completed",
"progress": 100,
"output_result": {
"version": "video_object_track.v1",
"source": {"type": "video", "width": 1920, "height": 1080, "fps": 29.97, "duration_ms": 16700, "analysis_begin_ms": 0, "analysis_end_ms": 16700, "analysis_fps": 5.0, "analysis_width": 1008, "analysis_height": 568, "analysis_frame_count": 84},
"objects": [
{
"obj_id": 1,
"label": "wheel",
"prompt": {"box": [0.37, 0.57, 0.40, 0.67], "time_ms": 5000},
"summary": {
"visible_ratio": 0.4286,
"first_visible_ms": 1400,
"last_visible_ms": 8400,
"mean_score": 0.7812,
"lost_segments": [[8600, 16600], [0, 1200]],
"lost_segments_truncated": false
}
}
],
"tracks_file_id": "537489015178248",
"tracks_download_url": "/download/a1/tracks.json"
},
"create_time": "2026-11-23T08:00:00Z",
"update_time": "2026-11-23T08:01:14Z"
}
}
Visibility and Losing the Target
- When the target is fully occluded, leaves the frame or cannot be confirmed, that frame has
visible=falseandbbox/bbox_smootharenull; no made-up box is returned. Once the target comes back and is recovered,visible=trueagain. - Visibility uses hysteresis and a minimum run length, so it does not flicker frame by frame.
- Short invisible gaps of at most 500 ms with visible frames on both sides are filled with interpolated boxes; those frames have
sourceset tointerpolated. bbox_smoothis smoothed only within visible stretches; the two sides of a lost stretch are smoothed independently and never joined into one curve.- If nothing can be recognized inside the box on the prompt frame, the task still completes and that target is invisible throughout (
visible_ratiois0); this is not a failure.
Coordinates
All boxes are normalized [x1, y1, x2, y2] relative to the source video (or source frame) size, in the 0-1 range, the same as Multi-Face Tracking. To get pixels: x × source.width, y × source.height.
Pricing
| Input | Billed duration | Price |
|---|---|---|
| Video | The actual analysis range: the time_range length if given, otherwise the whole video | 20 credits per minute |
| Frame sequence | Image count × frame_interval_ms | 20 credits per minute |
- Prorated by the second and rounded up to whole credits: for example 30 seconds costs 10 credits and 16.7 seconds costs 6 credits.
- Credits are reserved when the task is created and fully refunded if it fails.
- Same price as Multi-Face Tracking.
Tips
- The default 5 fps is enough for large targets and costs the least. When the target moves fast, or an identical object enters the frame right after it, raise
sample_fpsto 10. Otherwise, if the target leaves the frame just as a look-alike enters, the track may jump to the newcomer. - Keep the box tight around a single target, and draw it on a frame where the target is clear and barely occluded.
- For longer videos, use
time_rangeto pick the part you need; you can create several tasks. - All images in a frame sequence must have the same width and height. Otherwise the task fails and is refunded, and the error message names the first frame whose size differs.
- A video of about 15 seconds with default settings takes roughly 1–1.5 minutes from creation to completion, queueing included.
Error Codes
| Code | HTTP | Meaning | What to do |
|---|---|---|---|
6016 | 400 | Invalid parameter value: both or neither of file_id and frame_file_ids; box out of range; more than 16 rois or more than 4 prompt frames; prompt frame outside the analysis range; analysis range longer than 1 minute; sample_fps / frame_interval_ms out of range; video-only and frame-sequence-only fields mixed | No task is created and nothing is charged; fix the parameter named in the message |
6013 | 400 | Required parameter missing (such as rois) | No task is created and nothing is charged |
6004 | 400 | File not found | No task is created and nothing is charged |
6014 | 400 | File type mismatch (video input is not a video, or a frame sequence contains a non-image file) | No task is created and nothing is charged |
6201 | 402 | Insufficient balance | No task is created; top up and retry |
Failures during execution, such as frames of different sizes in a frame sequence, put the task in failed and refund all credits.