node.jsgoogle-cloud-platformvideo-intelligence-api

Handling Long Running Task in Cloud Function - Google Cloud Video Intelligence API


We're currently using the cloud intelligence api for tracking objects in videos, but this may take > 10 minutes for large videos.

I'm curious if there is any functionality with Google Cloud products to publish to a pub/sub queue of sorts after a job is completed.

The only API appears to make us wait for await operation.promise().

Amazon has a solution which allows the function to go to sleep, and you can just check if the job is completed later on.

Anyone know if this exists for Google?

  const [operation] = await video.annotateVideo(request);
  console.log('Waiting for operation to complete...');
  const [operationResult] = await operation.promise();
  // Gets shot changes
  let shotChanges = operationResult.annotationResults[0];

Solution

  • You can specify an outputUri which will write the results to your GCS bucket. If you do it this way, your method won't have to wait.

    Then you can set up a trigger on the output GCS bucket that will process the result.