问题描述
Under the boto3 docs: https://boto3.readthedocs.io/en/latest/reference/services/kinesis-video-media.html#KinesisVideoMedia.Client.get_media
它说我需要在运行 GetMedia
之前先运行 GetDataEndpoint
API 来获取端点,但它没有说明如何输入该端点?
it says that I need to run the GetDataEndpoint
API first to get an endpoint before I run GetMedia
but it doesn't say how to feed that endpoint in?
所以我尝试运行:
import boto3
kinesis_media = boto3.client('kinesis-video-media' region_name='region')
stream = kinesis_media.get_media(StreamARN='my-arn',
StartSelector={'StartSelectorType': 'EARLIEST'}) # this is not the endpoint
然后返回:
ClientError: An error occurred (403) when calling the GetMedia operation: <AccessDeniedException>
<Message>Unable to determine service/operation name to be authorized</Message>
</AccessDeniedException>
我猜是因为没有指定端点,但是 kinesis-video-media
类型的客户端没有获取端点所需的 get_data_endpoint
方法网址?
I am guessing cause endpoint wasn't specified but the clients of type kinesis-video-media
don't have the get_data_endpoint
method which is required to get the endpoint url?
推荐答案
首先使用kinesisvideo
客户端获取一个Endpoint:
First, use the kinesisvideo
client to obtain an Endpoint:
import boto3
kinesis_client = boto3.client('kinesisvideo',region_name='us-west-2')
response = kinesis_client.get_data_endpoint(StreamARN='...ARN...',APIName='GET_MEDIA')
response
变量包含:
{'ResponseMetadata': {'RetryAttempts': 0, 'HTTPStatusCode': 200, 'RequestId': '...', 'HTTPHeaders': {'x-amzn-requestid': '...', 'date': 'Tue, 10 Apr 2018 08:22:59 GMT', 'content-length': '74', 'content-type': 'application/json'}}, u'DataEndpoint': u'https://s-4010cf70.kinesisvideo.us-west-2.amazonaws.com'}
然后,使用给定的端点调用 kinesis-video-media
客户端:
Then, call the kinesis-video-media
client with the given endpoint:
video_client = boto3.client('kinesis-video-media',endpoint_url='https://s-4010cf70.kinesisvideo.us-west-2.amazonaws.com',region_name='us-west-2')
stream = video_client.get_media(StreamARN='arn:aws:kinesisvideo:us-west-2:...',StartSelector={'StartSelectorType': 'NOW'})
stream
变量包含:
{u'ContentType': 'video/webm', u'Payload': <botocore.response.StreamingBody object at 0x7f1fab294850>, 'ResponseMetadata': {'RetryAttempts': 0, 'HTTPStatusCode': 200, 'RequestId': '...', 'HTTPHeaders': {'x-amzn-requestid': '...', 'transfer-encoding': 'chunked', 'content-type': 'video/webm', 'date': 'Tue, 10 Apr 2018 08:27:19 GMT'}}}
这篇关于Boto3 kinesis 视频流:调用 GetMedia 操作时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!