6

I have uploaded a video to Google's Cloud Storage bucket and referenced their URL in the Video Intelligence API. When I tried to get the video duration of the uploaded video, Video Intelligence API doesn't return anything.

This is the code I used:

require "google/cloud/video_intelligence"

video_intelligence_client = Google::Cloud::VideoIntelligence.new
features_element = :LABEL_DETECTION
features = [features_element]

operation = video_intelligence_client.annotate_video input_uri: input_uri, features: features
p "PROCESSING......"
p operation
raise operation.results.message? if operation.error?

operation.wait_until_done!
metadata = operation.metadata
puts metadata

Is it possible to get video time duration using Video Intelligence API? Alternatively, how should I get it from Google Cloud Storage API?

Adriaan
  • 17,741
  • 7
  • 42
  • 75
Pez
  • 1,091
  • 2
  • 14
  • 34

1 Answers1

0
  1. Video Intelligence API does not calculate video duration. You can check available methods in API Explorer
  2. Google Cloud Storage treats any kind of content the same way (videos, music, zip files, documents, ...) so you have to calculate and store it for example as custom metadata.
  3. If you do not know the duration during upload, you can calculate it in Cloud Function triggered automatically after upload finishes.
Pawel Czuczwara
  • 1,442
  • 9
  • 20