google-cloud-platform - 使用 Google Cloud Storage 上的视频文件作为 Microsoft 视频索引器的输入时出现问题
问题描述
我使用 MicroSoft Video indexer 来运行视频智能并从用户视频输入中提取有用的特征/内容。我一直在使用 Web 界面,但现在我需要使用 Rest API 来自动执行此操作。
有两种方法可以指定要上传的视频文件。一种是摄取原始字节,另一种是引用云上视频文件的地址(推荐)。请参阅API 文档。
问题是我在指定 Google Cloud Storage 存储桶上的文件时遇到问题。我了解您必须指定公开可用文件的 URL,我通过提供视频文件的签名 URL 来做到这一点。但它一直给我下面的错误,当我指定上传到 Cloudinary 的同一视频文件的地址时,不会发生这种错误。
{
"ErrorType": "INVALID_INPUT",
"Message": "Url content type 'application/xml' is not supported. Only audio and video files are supported. You can find the supported types here: https://docs.microsoft.com/ro-ro/azure/media-services/media-services-media-encoder-standard-formats. Trace id: '7e9e2626-6dd3-4e9b-8b06-5991cfdb896c"
}
供参考,这里有2个地址:
- Cloudinary:https ://res.cloudinary.com/account-id/video/upload/v1612773239/VideoAI/Elen_Hyundai_high.mp4
- GCS: https://storage.googleapis.com/project-id.appspot.com/video-files/filename?GoogleAccessId=firebase-adminsdk-some-service-account-key.com&Expires=1612857836&Signature=Rog3NWpzqXINxPWQl9sLLP8eDASNEglUehL6YkMB90YXRIWGk8PZOYGpUB9MVgTXKtFe4IjbR0tRuDUVhCeIhFTfL3kR2YXCZ3mqbOYOQlzfasq4YE4FtGiN40gNicjiLbJbq8vq4pMIwRfSirSOV92t9ev5ydPcW0BgICfd5n6QOhCvLx%2FpPgonCuGtK82Zyu21M%2BFRxuqmDTfCsZwP0fxfzwoZblusEFxIxpZFiXtow27EBYy3Dqv062UWhPuLhSyBKnFIHReaSaRcfwRVMF4Sw849eeMLGYdqHSy9LOVsw% 2FcYTJenjM4bqoj1jqSduh8A%2FmGkN3rFRok3aT4qjw%3D%3D
如果您需要测试它,我可以提供实际的 URL。
解决方案
好的,我通过编码signedURL
从 GCS 获取的查询参数路径解决了这个问题,然后将其添加到videoUrl
发送到 MicroSoft Video Indexer (MVI) 的参数中
const temp = signedURL.split('?')
videoUrl = temp[0] + encodeURIComponent(`?${temp[1]}`)
这是因为 MVIdecodeURIComponent
在 videoUrl 上运行 - 因此目标是使结果等于 GCS 发送的原始 url:
const bucketFile = bucket.file(filePath)
const [signedURL] = await bucketFile.getSignedUrl({
action: 'read',
expires: 3600 * 1000, // 1hr or add-your-expiration,
})
推荐阅读
- python-3.x - 使用 rpy2 从矩阵创建命名列表
- javascript - 我对移位问题的逻辑正确吗?
- node.js - AWS Cognito Trigger Post Authenticated - Lambda Nodejs 8.10 - 返回自定义响应错误 TypeError:无法设置属性
- postgresql - 更新 - 使用文本未按预期响应的 Where 子句
- kubernetes - Kubernetes 和不安全的注册表
- angular - 如何导出自定义颜色并在组件中使用它们?
- javascript - Three.js:将 Equirectangular (Spherical) Panorama 转换为 6 Cube Map
- r - 将 SPCM-ZIP 模型从 SAS 中的 PROC NLMIXED 转换为 R
- javascript - 从表单内的字符串两端删除空格 - React
- mysql - 在 docker 中连接 mysqld-exporter - mysql_up 0