Video

Send H.264 encoded video files to the edgeflow for inference.

Video files no larger than 150MB can be uploaded into the Edgeflow using the /1/video API. These files must be passed into a video segmentation application for further processing. The segmentation application will create individual JPEG files from the video stream and forward these to downstream applications.
An example of a typical workflow using a video segmentation application is shown below. The input source can be an HTTP input application or an RTSP camera stream.

2614

The configuration of the video segmentation application requires a frames per second value. Frames are sample at the specified rate from the incoming video file or stream and JPEGs are created which are sent to a downstream application. Example configuration:

1918
POST /1/video/{subject_uid}
HOST: http://<gateway ip address or hostname>:8000

Additional arguments can be provided as part of form-data.

ArgumentDescriptionExample
external_media_id
string
(optional) arbitrary external id for this media.
Default: subject_uid-timestamp
test-one-mp4-tag
media_timestamp
float
(optional) actual timestamp of media creation/occurrence time
Default: timestamp media was received.
1604007056.62
user_id
string
(optional) user originating request[email protected]
domain_unit
string
(optional) domain id for set assignment grouping or allowing correlation between groups of images
Default: timestamp
"test-domain-1"
async_resp
bool
(optional) If set to False, will respond with all assertions from all downstream apps. Default: True - will send a response once a video-segmentation app has completed creating JPEG images form the incoming media. It is recommended that the POST URL feature is used to send retrieve detections from downstream applications.aync_resp = False

Responses:
The response status code can be one of the following:

Status CodeDescription
200Image included in json response message
403Invalid Media - unsupported or corrupted media file
404Subject UID not found - subject uid not configured in HTTP Input application
500Cannot parse input data - invalid additional data.
504Backend system timeout processing media.

An example JSON formatted response is shown below. The primary key is 'detections' which, when the async_resp input value is set to false will return the status from the video-segmentation application. When set to true, the detections from downstream applications will be included as part fo the list of detections - in a similar output format to the /1/process API. The media section of the response contains details of how the input media was processed.

{'detections': [{'app_data': None,
         'app_data_type': None,
         'app_id': '61i8zlcg',
         'assertion_prefix': None,
         'created_at': 1626276844.395973,
         'detection_id': None,
         'domain_unit': None,
         'external_media_id': 'at_httpinput_6eu-1626276843011176',
         'filename': None,
         'focus': None,
         'input_subject_association': {'probability': 1.0,
                         'subject_uid': 'at_httpinput_6e'},
         'media_md5': '8eaac673ca127288df5d5057896649a0',
         'model_id': None,
         'other_subject_associations': [],
         'uncal_prob': None,
         'user_id': None}],
 'media': {'app_id': '61i8zlcg',
      'capture_timestamp': 1626276844.390501,
      'container': ['mov', 'mp4', 'm4a', '3gp', '3g2', 'mj2'],
      'duration': 8.4,
      'external_media_id': 'at_httpinput_6eu-1626276843011176',
      'fps': 25,
      'frame': 200,
      'height': 576,
      'media_format': 'AVC1',
      'media_md5': '8eaac673ca127288df5d5057896649a0',
      'num_frames': 9,
      'num_images': 1,
      'segment_num': 1,
      'seq_number': 8,
      'time_base': 12800,
      'timestamp': 1626276844.395973,
      'upload_timestamp': 1626276843.01953,
      'user_id': None,
      'video_context': '/tmp/8586c61bcec3249a6fe0ca14888ef736.mp4',
      'width': 704}}

API Usage example

import requests
from time import time

API_VERSION = 1
GATEWAY_HOST_IP="10.1.20.100"
URL_PREFIX = 'http://%s:8000/%d/' % (GATEWAY_HOST_IP, API_VERSION)
TIMEOUT_SECS = 60
SUBJECT_UID = 'drone_images_6op'
filename = 'tesvideo.mp4'
files = {'file': open(filename, 'rb')}
data = {"media_timestamp": time(),
        "external_media_id":"abcde-tag", 
        'uploaded_by_user': '[email protected]', 
        'domain_unit': 'test_domain_1',
        'aysnc_resp': True}

resp = requests.post(URL_PREFIX + 'video/%s' % SUBJECT_UID, data=data, files=files, timeout=TIMEOUT_SECS)

if resp.status_code == 200:
  	detections = resp.json()