An idiomatic C++ client library for the Cloud Video Intelligence API, a service to detect objects, explicit content, and scene changes in videos. It also specifies the region for annotation and transcribes speech to text.
While this library is GA, please note Google Cloud C++ client libraries do not follow Semantic Versioning.
Quickstart
The following shows the code that you'll run in the google/cloud/videointelligence/quickstart/ directory, which should give you a taste of the Cloud Video Intelligence API C++ client library API.
#include "google/cloud/videointelligence/v1/video_intelligence_client.h"
#include <google/protobuf/util/time_util.h>
#include <iostream>
int main(int argc, char* argv[]) try {
auto constexpr kDefaultUri = "gs://cloud-samples-data/video/animals.mp4";
if (argc > 2) {
std::cerr << "Usage: " << argv[0] << " [video-uri]\n"
<< " The gcs-uri must be in gs://... format and must point to a"
<< " MP4 video.\n"
<< "It defaults to " << kDefaultUri << "\n";
return 1;
}
auto uri = std::string{argc == 2 ? argv[1] : kDefaultUri};
namespace videointelligence = ::google::cloud::videointelligence_v1;
auto client = videointelligence::VideoIntelligenceServiceClient(
videointelligence::MakeVideoIntelligenceServiceConnection());
using google::cloud::videointelligence::v1::Feature;
google::cloud::videointelligence::v1::AnnotateVideoRequest request;
request.set_input_uri(uri);
request.add_features(Feature::SPEECH_TRANSCRIPTION);
auto& config =
*request.mutable_video_context()->mutable_speech_transcription_config();
config.set_language_code("en-US"); // Adjust based
config.set_max_alternatives(1); // We will just print the highest-confidence
auto future = client.AnnotateVideo(request);
std::cout << "Waiting for response";
auto const delay = std::chrono::seconds(5);
while (future.wait_for(delay) == std::future_status::timeout) {
std::cout << '.' << std::flush;
}
std::cout << "DONE\n";
auto response = future.get();
if (!response) throw std::move(response).status();
for (auto const& result : response->annotation_results()) {
using ::google::protobuf::util::TimeUtil;
std::cout << "Segment ["
<< TimeUtil::ToString(result.segment().start_time_offset())
<< ", " << TimeUtil::ToString(result.segment().end_time_offset())
<< "]\n";
for (auto const& transcription : result.speech_transcriptions()) {
if (transcription.alternatives().empty()) continue;
std::cout << transcription.alternatives(0).transcript() << "\n";
}
}
return 0;
} catch (google::cloud::Status const& status) {
std::cerr << "google::cloud::Status thrown: " << status << "\n";
return 1;
}
The library automatically retries requests that fail with transient errors, and uses exponential backoff to backoff between retries. Application developers can override the default policies.
More Information
Error Handling - describes how the library reports errors.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-14 UTC."],[[["\u003cp\u003eThis webpage details the C++ client library for the Cloud Video Intelligence API, which offers capabilities like object detection, explicit content analysis, scene change detection, region annotation, and speech-to-text transcription in videos.\u003c/p\u003e\n"],["\u003cp\u003eThe latest available release candidate version is 2.37.0-rc, and the page also provides links to documentation for a range of previous versions, starting from version 2.11.0 up to version 2.36.0.\u003c/p\u003e\n"],["\u003cp\u003eThe C++ client library is generally available (GA) but does not adhere to Semantic Versioning, and it automatically handles retries for transient errors using exponential backoff.\u003c/p\u003e\n"],["\u003cp\u003eThe main class in this library is \u003ccode\u003evideointelligence_v1::VideoIntelligenceServiceClient\u003c/code\u003e, and it can perform all the RPCs.\u003c/p\u003e\n"],["\u003cp\u003eThe page provides information on error handling, overriding the default endpoint, changing authentication credentials, and using environment variables to configure the library.\u003c/p\u003e\n"]]],[],null,["Version 2.11.0keyboard_arrow_down\n\n- [2.42.0-rc (latest)](/cpp/docs/reference/videointelligence/latest)\n- [2.41.0](/cpp/docs/reference/videointelligence/2.41.0)\n- [2.40.0](/cpp/docs/reference/videointelligence/2.40.0)\n- [2.39.0](/cpp/docs/reference/videointelligence/2.39.0)\n- [2.38.0](/cpp/docs/reference/videointelligence/2.38.0)\n- [2.37.0](/cpp/docs/reference/videointelligence/2.37.0)\n- [2.36.0](/cpp/docs/reference/videointelligence/2.36.0)\n- [2.35.0](/cpp/docs/reference/videointelligence/2.35.0)\n- [2.34.0](/cpp/docs/reference/videointelligence/2.34.0)\n- [2.33.0](/cpp/docs/reference/videointelligence/2.33.0)\n- [2.32.0](/cpp/docs/reference/videointelligence/2.32.0)\n- [2.31.0](/cpp/docs/reference/videointelligence/2.31.0)\n- [2.30.0](/cpp/docs/reference/videointelligence/2.30.0)\n- [2.29.0](/cpp/docs/reference/videointelligence/2.29.0)\n- [2.28.0](/cpp/docs/reference/videointelligence/2.28.0)\n- [2.27.0](/cpp/docs/reference/videointelligence/2.27.0)\n- [2.26.0](/cpp/docs/reference/videointelligence/2.26.0)\n- [2.25.1](/cpp/docs/reference/videointelligence/2.25.1)\n- [2.24.0](/cpp/docs/reference/videointelligence/2.24.0)\n- [2.23.0](/cpp/docs/reference/videointelligence/2.23.0)\n- [2.22.1](/cpp/docs/reference/videointelligence/2.22.1)\n- [2.21.0](/cpp/docs/reference/videointelligence/2.21.0)\n- [2.20.0](/cpp/docs/reference/videointelligence/2.20.0)\n- [2.19.0](/cpp/docs/reference/videointelligence/2.19.0)\n- [2.18.0](/cpp/docs/reference/videointelligence/2.18.0)\n- [2.17.0](/cpp/docs/reference/videointelligence/2.17.0)\n- [2.16.0](/cpp/docs/reference/videointelligence/2.16.0)\n- [2.15.1](/cpp/docs/reference/videointelligence/2.15.1)\n- [2.14.0](/cpp/docs/reference/videointelligence/2.14.0)\n- [2.13.0](/cpp/docs/reference/videointelligence/2.13.0)\n- [2.12.0](/cpp/docs/reference/videointelligence/2.12.0)\n- [2.11.0](/cpp/docs/reference/videointelligence/2.11.0) \n\nCloud Video Intelligence API C++ Client Library\n===============================================\n\nAn idiomatic C++ client library for the [Cloud Video Intelligence API](https://cloud.google.com/videointelligence), a service to detect objects, explicit content, and scene changes in videos. It also specifies the region for annotation and transcribes speech to text.\n\nWhile this library is **GA** , please note Google Cloud C++ client libraries do **not** follow [Semantic Versioning](https://semver.org/).\n\n### Quickstart\n\nThe following shows the code that you'll run in the `google/cloud/videointelligence/quickstart/` directory, which should give you a taste of the Cloud Video Intelligence API C++ client library API. \n\n #include \"google/cloud/videointelligence/v1/video_intelligence_client.h\"\n #include \u003cgoogle/protobuf/util/time_util.h\u003e\n #include \u003ciostream\u003e\n\n int main(int argc, char* argv[]) try {\n auto constexpr kDefaultUri = \"gs://cloud-samples-data/video/animals.mp4\";\n if (argc \u003e 2) {\n std::cerr \u003c\u003c \"Usage: \" \u003c\u003c argv[0] \u003c\u003c \" [video-uri]\\n\"\n \u003c\u003c \" The gcs-uri must be in gs://... format and must point to a\"\n \u003c\u003c \" MP4 video.\\n\"\n \u003c\u003c \"It defaults to \" \u003c\u003c kDefaultUri \u003c\u003c \"\\n\";\n return 1;\n }\n auto uri = std::string{argc == 2 ? argv[1] : kDefaultUri};\n\n namespace videointelligence = ::google::cloud::videointelligence_v1;\n auto client = videointelligence::VideoIntelligenceServiceClient(\n videointelligence::MakeVideoIntelligenceServiceConnection());\n\n using google::cloud::videointelligence::v1::Feature;\n google::cloud::videointelligence::v1::AnnotateVideoRequest request;\n request.set_input_uri(uri);\n request.add_features(Feature::SPEECH_TRANSCRIPTION);\n auto& config =\n *request.mutable_video_context()-\u003emutable_speech_transcription_config();\n config.set_language_code(\"en-US\"); // Adjust based\n config.set_max_alternatives(1); // We will just print the highest-confidence\n\n auto future = client.AnnotateVideo(request);\n std::cout \u003c\u003c \"Waiting for response\";\n auto const delay = std::chrono::seconds(5);\n while (future.wait_for(delay) == std::future_status::timeout) {\n std::cout \u003c\u003c '.' \u003c\u003c std::flush;\n }\n std::cout \u003c\u003c \"DONE\\n\";\n\n auto response = future.get();\n if (!response) throw std::move(response).status();\n\n for (auto const& result : response-\u003eannotation_results()) {\n using ::google::protobuf::util::TimeUtil;\n std::cout \u003c\u003c \"Segment [\"\n \u003c\u003c TimeUtil::ToString(result.segment().start_time_offset())\n \u003c\u003c \", \" \u003c\u003c TimeUtil::ToString(result.segment().end_time_offset())\n \u003c\u003c \"]\\n\";\n for (auto const& transcription : result.speech_transcriptions()) {\n if (transcription.alternatives().empty()) continue;\n std::cout \u003c\u003c transcription.alternatives(0).transcript() \u003c\u003c \"\\n\";\n }\n }\n\n return 0;\n } catch (google::cloud::Status const& status) {\n std::cerr \u003c\u003c \"google::cloud::Status thrown: \" \u003c\u003c status \u003c\u003c \"\\n\";\n return 1;\n }\n\n### Main classes\n\nThe main class in this library is [`videointelligence_v1::VideoIntelligenceServiceClient`](/cpp/docs/reference/videointelligence/2.11.0/classgoogle_1_1cloud_1_1videointelligence__v1_1_1VideoIntelligenceServiceClient). All RPCs are exposed as member functions of this class. Other classes provide helpers, configuration parameters, and infrastructure to mock [`videointelligence_v1::VideoIntelligenceServiceClient`](/cpp/docs/reference/videointelligence/2.11.0/classgoogle_1_1cloud_1_1videointelligence__v1_1_1VideoIntelligenceServiceClient) when testing your application.\n\n### Retry, Backoff, and Idempotency Policies.\n\nThe library automatically retries requests that fail with transient errors, and uses [exponential backoff](https://en.wikipedia.org/wiki/Exponential_backoff) to backoff between retries. Application developers can override the default policies.\n\n### More Information\n\n- [Error Handling](https://cloud.google.com/cpp/docs/reference/common/latest/common-error-handling.html) - describes how the library reports errors.\n- [How to Override the Default Endpoint](/cpp/docs/reference/videointelligence/2.11.0/videointelligence-override-endpoint) - describes how to override the default endpoint.\n- [How to Override the Authentication Credentials](/cpp/docs/reference/videointelligence/2.11.0/videointelligence-override-authentication) - describes how to change the authentication credentials used by the library.\n- [Environment Variables](/cpp/docs/reference/videointelligence/2.11.0/videointelligence-env) - describes environment variables that can configure the behavior of the library."]]