Google Cloud Video API gives error on using "input_content" argument

Viewed 91

I am trying to use Google Video API and pass a video which is on my local drive using the "input_content" argument but I get this error: InvalidArgument: 400 Either `input_uri` or `input_content` should be set.

Here is the code based on Google Documentation:

"""Detect labels given a file path."""
video_client = videointelligence.VideoIntelligenceServiceClient()
features = [videointelligence.Feature.LABEL_DETECTION]

cwd = "E:/Google_Video_API/videos/video.mp4"
with io.open(cwd, "rb") as movie:
    input_content = movie.read()

operation = video_client.annotate_video(
    request={"features": features, "input_content": input_content}
)
1 Answers

 Video file need to be Base64 encoded so try this:

import base64 
...
operation = video_client.annotate_video(
    request={"features": features, "input_content": base64.b64encode(input_content)}
)
Related