Amazon Kinesis Video GetMedia/PutMedia

问题描述 投票:0回答:2

我使用 python 3.6,我想使用 API 将视频流发布到 aws kinesis。 我使用 python aws 客户端创建流和

GetDataEndPoint
但是当我想用我的自定义请求发布我的数据时(
PutMedia
实际上不包含在 python 客户端中),我得到一个错误
Unable to determine service/operation name to be authorized
.

我已经按照 aws kinesis 视频媒体 PutMediaGetMedia.

的 api 文档

所以我首先使用

GetDataEndPoint
client 方法 获取端点:

response = client.get_data_endpoint(  # aws client method
    StreamName=STREAM_NAME,
    APIName='PUT_MEDIA'
)
end_point = response['DataEndpoint'] # https://s-EXAMPLE.kinesisvideo.eu-west-1.amazonaws.com

我在这个网址发布我的数据:

headers = {
    "x-amzn-stream-arn": STREAM_ARN,
    "x-amzn-fragment-timecode-type": "ABSOLUTE",
    "x-amzn-producer-start-timestamp": start_tmstp
}
# Sign header...
response = requests.post(end_point, data=data, headers=headers)  # 403 - Unable to determine service/operation name to be authorized

所以我不明白为什么会出现此错误...我在 aws doc 上找到了这个故障排除。但是他们说我们必须指定 ApiName 参数。我做什么...

如果没有正确指定端点,可能会发生此错误。获取端点时,请务必在 GetDataEndpoint 调用中包含以下参数,具体取决于要调用的 API:

我也想知道

GetMedia
方法是否真的像他们所说的那样在客户端中实现here因为当我调试这个方法时,客户端不调用
GetDataEndPoint
所以在
https://kinesisvideo.region.amazonaws.com
代替
https://ID_EXAMPLE.kinesisvideo.region.amazonaws.com提出请求
.所以方法得到错误
Unable to determine service/operation name to be authorized
故障排除

中所述
python amazon-web-services amazon-kinesis
2个回答
3
投票

你得到的错误是因为你可能提供了没有“动作”的端点,在你的情况下是

putMedia
.

尝试将

/putMedia
附加到您的端点,并且不要忘记指定
"content-type": "application/json"
标头。

顺便说一句,您还必须为您的请求生成 v4 签名。您可以使用 lib 或按照此 python 指南 进行操作。


0
投票

按照@minghua 的答案代码,将源视频转换为.mkv 解决所有问题。一旦我这样做了,就完美地流动了。

© www.soinside.com 2019 - 2024. All rights reserved.