Skip to main content

ExtractFrames

Retrieve frames (as separate images) from a referenced video.

Frames are returned as encoded images in the array of blobs.

Parameters​

  • video_ref: Reference to videos within the transaction (either the result of a FindVideo or an AddVideo) from which the corresponding frames will be retrieved.

  • frame_spec: specification of what frames numbers to extract.

  • [optional] as_format: Specify the format of the returned frames.

  • [optional] operations

Details​

The frames to be extracted and returned can be specified in two ways: either by specifying the frame_spec parameter with an array of frame indexes, or by passing an object (see examples below) with start, stop, and step indexes.

Examples​

Find the video with the "name" property equal to "my_video_1", and returns 1st, 10th, and 100th frames of it:


[{
"FindVideo": {
"_ref": 1,
"constraints": {
"name": ["==", "my_video_1"]
}
}
}, {
"ExtractFrames": {
"video_ref": 1,
"frame_spec": [0, 9, 99]
}
}]

Successful response:


[{
"FindVideo": {
"status": 0,
"returned": 0
}
}, {
"ExtractFrames": {
"status": 0,
"returned": 3,
"blobs_start": 0
}
}]

Find the video with the "name" property equal to "my_video_1", and return 1 every 5 frames in the range between the 1st and the 100th frame with 1080p resolution as "PNG":


[{
"FindVideo": {
"_ref": 1,
"constraints": {
"name": ["==", "Family Guy"]
},
"unique": true
}
}, {
"ExtractFrames": {
"video_ref": 1,
"as_format": "png",
"frame_spec": {
"start": 0,
"stop": 99,
"step": 5
},
"operations": [{
"type": "resize",
"width": 1920,
"height": 1080
}]
}
}]

Successful response:


[{
"FindVideo": {
"status": 0,
"returned": 0
}
}, {
"ExtractFrames": {
"status": 0,
"returned": 20,
"blobs_start": 0
}
}]