Menu
Amazon Kinesis Video Streams
Developer Guide

GetMedia

Use this API to retrieve media content from a Kinesis video stream. In the request, you identify the stream name or stream Amazon Resource Name (ARN), and the starting chunk. Kinesis Video Streams then returns a stream of chunks in order by fragment number.

Note

You must first call the GetDataEndpoint API to get an endpoint. Then send the GetMedia requests to this endpoint using the --endpoint-url parameter.

When you put media data (fragments) on a stream, Kinesis Video Streams stores each incoming fragment and related metadata in what is called a "chunk." For more information, see PutMedia. The GetMedia API returns a stream of these chunks starting from the chunk that you specify in the request.

The following limits apply when using the GetMedia API:

  • A client can call GetMedia up to five times per second per stream.

  • Kinesis Video Streams sends media data at a rate of up to 25 megabytes per second (or 200 megabits per second) during a GetMedia session.

Request Syntax

POST /getMedia HTTP/1.1 Content-type: application/json { "StartSelector": { "AfterFragmentNumber": "string", "ContinuationToken": "string", "StartSelectorType": "string", "StartTimestamp": number }, "StreamARN": "string", "StreamName": "string" }

URI Request Parameters

The request does not use any URI parameters.

Request Body

The request accepts the following data in JSON format.

StartSelector

Identifies the starting chunk to get from the specified stream.

Type: StartSelector object

Required: Yes

StreamARN

The ARN of the stream from where you want to get the media content. If you don't specify the streamARN, you must specify the streamName.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 1024.

Pattern: arn:aws:kinesisvideo:[a-z0-9-]+:[0-9]+:[a-z]+/[a-zA-Z0-9_.-]+/[0-9]+

Required: No

StreamName

The Kinesis video stream name from where you want to get the media content. If you don't specify the streamName, you must specify the streamARN.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 256.

Pattern: [a-zA-Z0-9_.-]+

Required: No

Response Syntax

HTTP/1.1 200 Content-Type: ContentType Payload

Response Elements

If the action is successful, the service sends back an HTTP 200 response.

The response returns the following HTTP headers.

ContentType

The content type of the requested media.

Length Constraints: Minimum length of 1. Maximum length of 128.

Pattern: ^[a-zA-Z0-9_\.\-]+$

The response returns the following as the HTTP body.

Payload

The payload Kinesis Video Streams returns is a sequence of chunks from the specified stream. For information about the chunks, see PutMedia. The chunks that Kinesis Video Streams returns in the GetMedia call also include the following additional Matroska (MKV) tags:

  • AWS_KINESISVIDEO_CONTINUATION_TOKEN (UTF-8 string) - In the event your GetMedia call terminates, you can use this continuation token in your next request to get the next chunk where the last request terminated.

  • AWS_KINESISVIDEO_MILLIS_BEHIND_NOW (UTF-8 string) - Client applications can use this tag value to determine how far behind the chunk returned in the response is from the latest chunk on the stream.

  • AWS_KINESISVIDEO_FRAGMENT_NUMBER - Fragment number returned in the chunk.

  • AWS_KINESISVIDEO_SERVER_TIMESTAMP - Server time stamp of the fragment.

  • AWS_KINESISVIDEO_PRODUCER_TIMESTAMP - Producer time stamp of the fragment.

The following tags will be present if an error occurs:

  • AWS_KINESISVIDEO_ERROR_CODE - String description of an error that caused GetMedia to stop.

  • AWS_KINESISVIDEO_ERROR_ID: Integer code of the error.

The error codes are as follows:

  • 3002 - Error writing to the stream

  • 4000 - Requested fragment is not found

  • 4500 - Access denied for the stream's KMS key

  • 4501 - Stream's KMS key is disabled

  • 4502 - Validation error on the Stream's KMS key

  • 4503 - KMS key specified in the stream is unavailable

  • 4504 - Invalid usage of the KMS key specified in the stream

  • 4505 - Invalid state of the KMS key specified in the stream

  • 4506 - Unable to find the KMS key specified in the stream

  • 5000 - Internal error

Errors

For information about the errors that are common to all actions, see Common Errors.

ClientLimitExceededException

Kinesis Video Streams has throttled the request because you have exceeded the limit of allowed client calls. Try making the call later.

HTTP Status Code: 400

ConnectionLimitExceededException

Kinesis Video Streams has throttled the request because you have exceeded the limit of allowed client connections.

HTTP Status Code: 400

InvalidArgumentException

The value for this input parameter is invalid.

HTTP Status Code: 400

InvalidEndpointException

Status Code: 400, Caller used wrong endpoint to write data to a stream. On receiving such an exception, the user must call GetDataEndpoint with AccessMode set to "READ" and use the endpoint Kinesis Video returns in the next GetMedia call.

HTTP Status Code: 400

NotAuthorizedException

Status Code: 403, The caller is not authorized to perform an operation on the given stream, or the token has expired.

HTTP Status Code: 401

ResourceNotFoundException

Status Code: 404, The stream with the given name does not exist.

HTTP Status Code: 404

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following: