如何获取Google Cloud Storage中存在的视频的视频时长

Pez*_*Pez 5 google-cloud-storage google-cloud-platform video-intelligence-api

我已将视频上传到Google的Cloud Storage存储桶,并在Video Intelligence API中引用了它们的URL。当我尝试获取上载视频的视频时长时,Video Intelligence API不会返回任何内容。

这是我使用的代码:

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
Run Code Online (Sandbox Code Playgroud)

使用Video Intelligence API是否可以获取视频时长?另外,我应该如何从Google Cloud Storage API获取它?

Paw*_*ara 0

  1. Video Intelligence API 不计算视频时长。您可以在API Explorer中检查可用的方法
  2. Google Cloud Storage 以相同的方式处理任何类型的内容(视频、音乐、zip 文件、文档等),因此您必须计算并将其存储为自定义元数据等等。
  3. 如果您不知道上传时长,可以在上传完成后自动触发的云函数中计算。