An idiomatic C++ client library for theCloud 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 isGA, please note Google Cloud C++ client libraries donotfollowSemantic Versioning.
Quickstart
The following shows the code that you'll run in thegoogle/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;
}
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[[["\u003cp\u003eThe webpage provides documentation for the Cloud Video Intelligence API C++ client library, which allows for the detection of objects, explicit content, and scene changes in videos, as well as region specification for annotation and speech-to-text transcription.\u003c/p\u003e\n"],["\u003cp\u003eThe latest release candidate version for the library is 2.37.0-rc, with version 2.36.0 being the currently displayed version, and several other previous versions listed, such as 2.35.0 and 2.11.0.\u003c/p\u003e\n"],["\u003cp\u003eThe library does not follow Semantic Versioning, despite being in General Availability (GA), and it uses the \u003ccode\u003evideointelligence_v1::VideoIntelligenceServiceClient\u003c/code\u003e class as the primary class for exposing Remote Procedure Calls (RPCs).\u003c/p\u003e\n"],["\u003cp\u003eThe quickstart section provides an example of how to use the library to perform speech transcription on a video file, including setting the language code and the maximum number of transcription alternatives.\u003c/p\u003e\n"],["\u003cp\u003eThe library supports customization through various overrides and environment variables, allowing users to tailor endpoint, authentication credentials, retry policies, and other library behaviors to their specific needs.\u003c/p\u003e\n"]]],[],null,["Version 2.36.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.36.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.36.0/classgoogle_1_1cloud_1_1videointelligence__v1_1_1VideoIntelligenceServiceClient) when testing your application.\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.36.0/videointelligence-override-endpoint) - describes how to override the default endpoint.\n- [How to Override the Authentication Credentials](/cpp/docs/reference/videointelligence/2.36.0/videointelligence-override-authentication) - describes how to change the authentication credentials used by the library.\n- [Override Retry, Backoff, and Idempotency Policies](/cpp/docs/reference/videointelligence/2.36.0/videointelligence-override-retry) - describes how to change the default retry policies.\n- [Environment Variables](/cpp/docs/reference/videointelligence/2.36.0/videointelligence-env) - describes environment variables that can configure the behavior of the library."]]