Analytics Log - Adil Khan

View Original

Google Cloud Video Intelligence API - Object Tracking in Python Example [Multiple Videos]

Ok, so last week, I had covered how use the Google Cloud Video Intelligence API in Python to run object tracking on a single video.

This is an extension of that post to cover multiple videos in a bucket within GCS.

input_uri field from the API documentation: https://googleapis.dev/python/videointelligence/latest/gapic/v1/types.html

Input video location. Currently, only Cloud Storage URIs are supported. URIs must be specified in the following format: gs://bucket- id/object-id (other URI formats return [google.rpc.Code.INVA LID_ARGUMENT][google.rpc.Code.INVALID_ARGUMENT]). To identify multiple videos, a video URI may include wildcards in the object-id. Supported wildcards: ’*’ to match 0 or more characters; ‘?’ to match 1 character.

Both videos are in the same bucket: video_intel3

As I got the wildcard parameter wrong, the google people at Stackoverflow corrected the input_uri field and it worked:

gcs_uri = 'gs://video_intel3/*.*'

https://stackoverflow.com/questions/64233020/google-cloud-video-intelligence-api-in-python-unable-to-run-object-tracking-on?noredirect=1#comment113675169_64233020


Once you run the below Py script, you should find the response.json file in the same bucket in GCS.

Converted the response.JSON to an Excel file and checked the input_uri field. It does show 2 videos there. Therefore, the script works!

See this content in the original post