Working With Video Intelligence API in Python Setting Up to Work


Working With Video Intelligence API in Python



1.Setup and requirements

  • Create New Project or Select Project
  • Start Cloud Shell

Run the following command in Cloud Shell to confirm that you are authenticated:

gcloud auth list
gcloud config list project
gcloud config set project <PROJECT_ID>

2.Enable the API

Enter the Command in Cloud Shell
gcloud services enable videointelligence.googleapis.com

3.Authenticate API requests

First, set a PROJECT_ID environment variable:
export PROJECT_ID=$(gcloud config get-value core/project)
Next, create a new service account to access the Video Intelligence API by using:
gcloud iam service-accounts create my-video-intelligence-sa \
  --display-name "my video intelligence service account"
  
 Next, create credentials that your Python code will use to login as your new service account. Create and save these credentials as a ~/key.json JSON file by using the following command:
 
gcloud iam service-accounts keys create ~/key.json \
  --iam-account my-video-intelligence-sa@${PROJECT_ID}.iam.gserviceaccount.com
  
 Finally, set the GOOGLE_APPLICATION_CREDENTIALS environment variable
export GOOGLE_APPLICATION_CREDENTIALS=~/key.json
4.Install the client library
pip3 install --user --upgrade google-cloud-videointelligence
5.Start Interactive Python
Start a session by running ipython in Cloud Shell
ipython
6.Sample Video Link

Comments