4

Under the boto3 docs: https://boto3.readthedocs.io/en/latest/reference/services/kinesis-video-media.html#KinesisVideoMedia.Client.get_media

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?

So I have tried to run:

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

and that returns:

ClientError: An error occurred (403) when calling the GetMedia operation: <AccessDeniedException>
  <Message>Unable to determine service/operation name to be authorized</Message>
</AccessDeniedException>

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?

John Rotenstein
  • 241,921
  • 22
  • 380
  • 470
KillerSnail
  • 3,321
  • 11
  • 46
  • 64

1 Answers1

12

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')

The response variable contains:

{'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'}

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'})

The stream variable contains:

{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'}}}
John Rotenstein
  • 241,921
  • 22
  • 380
  • 470
  • Hey @John Rotenstein So I want to feed the audio stream output of the Kinesis stream to Transcribe service and get realtime audio to text conversion is it feasible ? Am concern about which format kinesis deliver (I hope its Payload format) and will trancoder able to support it or any way I can convert to transcoder understandable format (hope it supports only 'mp3'|'mp4'|'wav'|'flac' ) ? – sudhir tataraju Mar 16 '19 at 18:56
  • @sudhirtataraju Please create a new question rather than asking via a comment on an old question. – John Rotenstein Mar 16 '19 at 21:50
  • Created new question: https://stackoverflow.com/questions/55204098/how-to-feed-the-audio-stream-output-of-the-aws-kinesis-video-stream-to-aws-trans please help – sudhir tataraju Mar 17 '19 at 06:05