Getting Started With Google Cloud Video Intelligence API In Python | GCP Tutorial For Beginners

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
in this tutorial you will learn how to get started with Google Cloud's video AI video intelligence API in Python to perform video analysis this powerful tool enables enhanced content Discovery and engaging video experiences by offering precise video analysis capable of recognizing over 20,000 objects places and actions in video content whether you're managing media creating intelligent video applications or improving customer engagement this API provides the tool you need before diving into the tutorial let's cover some of the business use cases that highlight how Google Cloud's video AI video intelligence API can be leveraged effectively content moderation use the video intelligence API to identify and manage inappropriate content in your videos this feature is essential for maintaining brand safety and compliance allowing you to moderate vast amounts of data swiftly and efficiently recommended content improve your user engagement by building a Content recommendation engine by utilizing metadata generated by the video intelligence API along with user viewing history and preferences you can guide users to content that is most relevant and engaging for them media archives create an indexed searchable archive of your video content the video intelligence API automates the analysis of your media files making the enriched metadata immediately accessible via the API this is particularly beneficial for Mass media companies looking to efficiently manage their digital assets contextual advertisements enhance monetization of your video content by placing ads that are contextually relevant to the video's content by aligning the labels from your video with the content of your advertisements you can create a more seamless and effective ad experience for viewers next let's go over Google video intelligence API pricing the Google Cloud platform video elligence API has distinct pricing structures for stored video annotation and streaming video annotation understanding these costs is crucial for budgeting and planning your video analysis projects for stored video annotation the first 1,000 minutes of features such as label detection shot detection explicit content detection speech transcription object tracking text detection logo detection face detection person detection and celebrity recognition are free after the initial 1,000 minutes the pricing varies label detection costs 10 cents per minute shot detection is 5 cents per minute or free when combined with label detection explicit content detection is 10 cents per minute speech transcription cost 4.8 cents per minute but this charge applies only to English US transcription object tracking text detection logo detection face detection person detection and celebrity recognition each cost 15 cents per minute except face and person detection which are 10 cents per minute for streaming video annotation the pricing model is slightly higher to accommodate the real-time processing needs again the first 1,000 minutes are free with subsequent usage priced as follows label detection is 12 cents per minute shot detection costs 7 cents per minute explicit content detection is 12 cents per minute object tracking is 17 cents per minute please note that all prices are calculated per minute and partial minutes are rounded up to the next full minute this pricing allows for scalable usage based on your Project's size and needs ensuring you only pay for what you use beyond the generous initial free tier that covers video intelligence API general information now let's dive into the tutorial to navigate to Google Cloud console go to console. cloud.google.com ensure you have an active Google Cloud project select the Google Cloud project you wish to use in the navigation menu go to apis and services then select Library search for cloud video intelligence API click Cloud video intelligence API from the search results enable enable Cloud video intelligence API next we'll create a service account on the navigation menu go to apis and services then select credentials at the top click create credentials then choose service account in the service account name field enter a name the Google Cloud console automatically fills in the service service account ID field based on this name in the service account description field type a description such as service account for video intelligence API click create and continue in the roll dropdown menu select the role that best suits your needs although video intelligence is part of the vision AI product category for this demonstration I'll select the owner role for Simplicity click continue click done to finish creating the service account next we need to create a service account key file in the Google Cloud console click the email address for the service account that you created click Keys click add key then create new key set Json as the key type then click create to download the Json key file to your project folder click close to use the Google Cloud video intelligence API in Python you need to install two python libraries python. anv and Google Cloud video intelligence launch a terminal and run the command pip install google-cloud DV video intelligence python. Envy in your project directory create an environment variable file called EnV inside the EnV file create an environment variable called Google application credentials and assign the client key file path to it save and close now let's dive into a python example create a python file named demo. piy open the python file in a code editor for the example we'll use the video intelligence API to analyze a short video loaded from a local drive and return to descriptions categories and timestamps for the identified labels for this tutorial I prepared a short clip video with my cat in it let's start out by importing the io module which provides tools for handling streams of data import the load do and V function from the EnV Library used to load environment variables from a EnV file import the video intelligence module from google. cloud which provides tools for working with video intelligence features in Google Cloud create the main function as the starting point for the script execution inside the main function create a video intelligence service client object named video client create a list named features add the label detection constant from the video intelligence. feature enumeration to this list this constant specifies that the video analysis should focus on detecting and categorizing entities within the video such as objects scenes and activities open the file cat. MP4 in read binary mode storing its file object in the media file variable read the file content and store it in the input content variable proceed to create an operation object by calling the annotate video method on the video client object pass a dictionary to this method with two key value pairs features which is the previously created features list and input content to load the bite data from the video file if your media files are stored on Google Cloud Storage change the dictionary key to input URI and set the value to the URI of a video is stored print a message indicating that the video processing for label annotations has started next create an object named result from calling the result method on the operation object with a timeout set to 180 seconds print a message stating that the video processing has finished extract segment labels from the first element of the results annotation results list and name it segment labels this contains the label annotations for different video segments iterate over segment labels using a for Loop for each segment label print its description by accessing the entity. description attribute this description provides a textual representation of what the label identifies next iterate over the category entities of each segment label and print the description of each category entity by accessing the description attribute which could be more General categories or related Concepts continue in the same outer loop to iterate over the segments of each segment label for each segment calculate the start time by adding the seconds and microc seconds from segment. segment. start time offset do the same for end time using segment. segment. end time offset format these times into a string representing the segment's duration create a string named positions that formats the start and end times to clearly show the segment's duration in seconds additionally Define a variable named confidence to capture the confidence score for each segment print the segment index and its corresponding positions to indicate which part of the video the segment refers to and print the confidence level of each segment which indicates how confident the model is about the assigned label finally after processing all segments for a given segment label print a new line character to separate the out outputs for different segment labels for better readability now add the entry point to run the main function start by adding an if statement to check if the script is being run as the main program inside the if statement called the load. EnV function to load the environment variables from the EnV file into the scripts environment which is essential for managing sensitive data or configuration options without hardcoding them into the source code finally call the main function to perform the video analysis run the script to perform the video analysis now from the output you should see the results of the video label detected from the video which include descriptions of what is recognized in each segment categorization of these labels specific time segments indicating where these labels occur and the confidence levels for each detection these details provide a comprehensive breakdown of the content analyzed by the video intelligence API and that concludes this tutorial I hope you found this video useful for more tutorials make sure to subscribe and don't forget to like the video if you have any questions or topics you would like me to cover in future videos please leave a comment below happy coding and I'll see you in the next video
Info
Channel: Jie Jenn
Views: 535
Rating: undefined out of 5
Keywords: google cloud, python tutorial, google cloud video intelligence api, google cloud video ai, gcp
Id: Q_0vDsQ9YkE
Channel Id: undefined
Length: 12min 26sec (746 seconds)
Published: Thu May 09 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.