Cloud Video Intelligence API C++ Client Library

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.


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(

  using google::cloud::videointelligence::v1::Feature;
  google::cloud::videointelligence::v1::AnnotateVideoRequest request;
  auto& 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;

Main classes

The main class in this library is videointelligence_v1::VideoIntelligenceServiceClient. All RPCs are exposed as member functions of this class. Other classes provide helpers, configuration parameters, and infrastructure to mock videointelligence_v1::VideoIntelligenceServiceClient when testing your application.

Retry, Backoff, and Idempotency Policies.

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