【发布时间】:2021-12-06 06:18:12
【问题描述】:
我想从 Cloudinary 获取视频时长。我找到了this question,但我在 curl 中找不到任何方法。我想我应该使用explicit method,但我试过了,但我得到了找不到页面的错误。
【问题讨论】:
标签: curl wget cloudinary
我想从 Cloudinary 获取视频时长。我找到了this question,但我在 curl 中找不到任何方法。我想我应该使用explicit method,但我试过了,但我得到了找不到页面的错误。
【问题讨论】:
标签: curl wget cloudinary
我是 Danny,在 Cloudinary 的客户成功团队工作。
无需使用 Upload API 的显式方法,您只需从 Admin API 获取资源,此处解释:https://cloudinary.com/documentation/admin_api#get_the_details_of_a_single_resource
您需要向/resources(/:resource_type)(/:type)/public_id 发出GET 请求。默认情况下不返回视频时长,因此您需要在 GET 请求中指定 ?image_metadata=true 才能返回。
例如,要返回our sample dog video 的持续时间,我会在此 URL 上执行 GET,并根据需要替换 API 密钥和秘密:https://API_KEY:API_SECRET@api.cloudinary.com/v1_1/demo/resources/video/upload/dog?image_metadata=true
这将返回以下 JSON,其中包括 video_duration:
{
"asset_id": "c07b6c11dfbc9b8849eacbd4c20da607",
"public_id": "dog",
"format": "mp4",
"version": 1426536413,
"resource_type": "video",
"type": "upload",
"created_at": "2015-03-16T20:06:53Z",
"bytes": 9094354,
"width": 854,
"height": 480,
"backup": true,
"access_mode": "public",
"url": "http://res.cloudinary.com/demo/video/upload/v1426536413/dog.mp4",
"secure_url": "https://res.cloudinary.com/demo/video/upload/v1426536413/dog.mp4",
[...]
"video_duration": 13.4134,
"audio_duration": 13.413396,
"audio_start_time": 0.0,
"video_start_time": 0.0,
[...]
}
我希望这会有所帮助。如果您有任何后续问题,欢迎在此处发布,或通过我们的Support Portal 向我们提出问题。
【讨论】: