@google-cloud/video-intelligence

The @google-cloud/video-intelligence package has the following named exports:

Source:
Examples

Install the client library with npm:

npm install --save @google-cloud/video-intelligence

Import the client library:

const videoIntelligence = require('@google-cloud/video-intelligence');

Create a client that uses Application Default Credentials (ADC):

const client = new videoIntelligence.VideoIntelligenceServiceClient();

Create a client with explicit credentials:

const client = new videoIntelligence.VideoIntelligenceServiceClient({
  projectId: 'your-project-id',
  keyFilename: '/path/to/keyfile.json',
});

Full quickstart example:

  // Imports the Google Cloud Video Intelligence library
  const videoIntelligence = require('@google-cloud/video-intelligence');

  // Creates a client
  const client = new videoIntelligence.VideoIntelligenceServiceClient();

  // The GCS uri of the video to analyze
  const gcsUri = 'gs://cloud-samples-data/video/cat.mp4';

  // Construct request
  const request = {
    inputUri: gcsUri,
    features: ['LABEL_DETECTION'],
  };

  // Execute request
  const [operation] = await client.annotateVideo(request);

  console.log(
    'Waiting for operation to complete... (this may take a few minutes)'
  );

  const [operationResult] = await operation.promise();

  // Gets annotations for video
  const annotations = operationResult.annotationResults[0];

  // Gets labels for video from its annotations
  const labels = annotations.segmentLabelAnnotations;
  labels.forEach(label => {
    console.log(`Label ${label.entity.description} occurs at:`);
    label.segments.forEach(segment => {
      segment = segment.segment;
      if (segment.startTimeOffset.seconds === undefined) {
        segment.startTimeOffset.seconds = 0;
      }
      if (segment.startTimeOffset.nanos === undefined) {
        segment.startTimeOffset.nanos = 0;
      }
      if (segment.endTimeOffset.seconds === undefined) {
        segment.endTimeOffset.seconds = 0;
      }
      if (segment.endTimeOffset.nanos === undefined) {
        segment.endTimeOffset.nanos = 0;
      }
      console.log(
        `\tStart: ${segment.startTimeOffset.seconds}` +
          `.${(segment.startTimeOffset.nanos / 1e6).toFixed(0)}s`
      );
      console.log(
        `\tEnd: ${segment.endTimeOffset.seconds}.` +
          `${(segment.endTimeOffset.nanos / 1e6).toFixed(0)}s`
      );
    });
  });

Members

(static) v1 :object

Properties:
Name Type Description
VideoIntelligenceServiceClient constructor

Reference to v1.VideoIntelligenceServiceClient

Source:

(static) v1beta2 :object

Properties:
Name Type Description
VideoIntelligenceServiceClient constructor

Reference to v1beta2.VideoIntelligenceServiceClient

Source:

(static) v1p1beta1 :object

Properties:
Name Type Description
VideoIntelligenceServiceClient constructor

Reference to v1p1beta1.VideoIntelligenceServiceClient

Source:

(static) v1p2beta1 :object

Properties:
Name Type Description
VideoIntelligenceServiceClient constructor

Reference to v1p2beta1.VideoIntelligenceServiceClient

Source:

(static) v1p3beta1 :object

Properties:
Name Type Description
VideoIntelligenceServiceClient constructor

Reference to v1p3beta1.VideoIntelligenceServiceClient

Source: