Gets media for a list of fragments (specified by fragment number) from the archived data in an Amazon Kinesis video stream.
You must first call the GetDataEndpoint API to get an endpoint. Then send the GetMediaForFragmentList requests to this endpoint using the --endpoint-url parameter.
For limits, see Kinesis Video Streams Limits.
If an error is thrown after invoking a Kinesis Video Streams archived media API, in addition to the HTTP status code and the response body, it includes the following pieces of information:
-
x-amz-ErrorType HTTP header – contains a more specific error type in addition to what the HTTP status code provides.
-
x-amz-RequestId HTTP header – if you want to report an issue to Amazon Web Services, the support team can better diagnose the problem if given the Request Id.
Both the HTTP status code and the ErrorType header can be utilized to make programmatic decisions about whether errors are retry-able and under what conditions, as well as provide information on what actions the client programmer might need to take in order to successfully try again.
For more information, see the Errors section at the bottom of this topic, as well as Common Errors.
Parameters:
-
stream_name
(Optional[StreamName], default:
None
)
–
The name of the stream from which to retrieve fragment media. Specify either this parameter or the StreamARN parameter.
-
stream_arn
(Optional[ResourceARN], default:
None
)
–
The Amazon Resource Name (ARN) of the stream from which to retrieve fragment media. Specify either this parameter or the StreamName parameter.
-
fragments
(FragmentNumberList)
–
A list of the numbers of fragments for which to retrieve media. You retrieve these values with ListFragments.
Raises:
-
ClientLimitExceededException
–
Kinesis Video Streams has throttled the request because you have exceeded a limit. Try making the call later. For information about limits, see Kinesis Video Streams Limits.
-
InvalidArgumentException
–
A specified parameter exceeds its restrictions, is not supported, or can't be used.
-
NotAuthorizedException
–
Status Code: 403, The caller is not authorized to perform an operation on the given stream, or the token has expired.
-
ResourceNotFoundException
–
GetImages will throw this error when Kinesis Video Streams can't find the stream that you specified.
GetHLSStreamingSessionURL and GetDASHStreamingSessionURL throw this error if a session with a PlaybackMode of ON_DEMAND or LIVE_REPLAYis requested for a stream that has no fragments within the requested time range, or if a session with a PlaybackMode of LIVE is requested for a stream that has no fragments within the last 30 seconds.
-
UnknownServiceError
–
The service returned an error code this client does not model.
Source code in docs_src/capo_kinesis_video_archived_media/_services/async_kinesis_video_archived_media.py
| @asynccontextmanager
async def get_media_for_fragment_list(
self,
fragments: "capo_kinesis_video_archived_media.types.fragment_number_list.FragmentNumberList",
*,
config_overrides: Optional[AsyncKinesisVideoArchivedMediaClientConfig] = None,
stream_name: Optional[
"capo_kinesis_video_archived_media.types.stream_name.StreamName"
] = None,
stream_arn: Optional[
"capo_kinesis_video_archived_media.types.resource_arn.ResourceARN"
] = None,
) -> "AsyncGenerator[capo_kinesis_video_archived_media.types.get_media_for_fragment_list_output.GetMediaForFragmentListOutput]":
"""<p>Gets media for a list of fragments (specified by fragment number) from the archived data in an Amazon Kinesis video stream.</p> <note> <p>You must first call the <code>GetDataEndpoint</code> API to get an endpoint. Then send the <code>GetMediaForFragmentList</code> requests to this endpoint using the <a href="https://docs.aws.amazon.com/cli/latest/reference/">--endpoint-url parameter</a>. </p> </note> <p>For limits, see <a href="http://docs.aws.amazon.com/kinesisvideostreams/latest/dg/limits.html">Kinesis Video Streams Limits</a>.</p> <important> <p>If an error is thrown after invoking a Kinesis Video Streams archived media API, in addition to the HTTP status code and the response body, it includes the following pieces of information: </p> <ul> <li> <p> <code>x-amz-ErrorType</code> HTTP header – contains a more specific error type in addition to what the HTTP status code provides. </p> </li> <li> <p> <code>x-amz-RequestId</code> HTTP header – if you want to report an issue to Amazon Web Services, the support team can better diagnose the problem if given the Request Id.</p> </li> </ul> <p>Both the HTTP status code and the ErrorType header can be utilized to make programmatic decisions about whether errors are retry-able and under what conditions, as well as provide information on what actions the client programmer might need to take in order to successfully try again.</p> <p>For more information, see the <b>Errors</b> section at the bottom of this topic, as well as <a href="https://docs.aws.amazon.com/kinesisvideostreams/latest/dg/CommonErrors.html">Common Errors</a>. </p> </important>
Args:
stream_name: <p>The name of the stream from which to retrieve fragment media. Specify either this parameter or the <code>StreamARN</code> parameter.</p>
stream_arn: <p>The Amazon Resource Name (ARN) of the stream from which to retrieve fragment media. Specify either this parameter or the <code>StreamName</code> parameter.</p>
fragments: <p>A list of the numbers of fragments for which to retrieve media. You retrieve these values with <a>ListFragments</a>.</p>
Raises:
capo_kinesis_video_archived_media.errors.client_limit_exceeded_exception.ClientLimitExceededException: <p>Kinesis Video Streams has throttled the request because you have exceeded a limit. Try making the call later. For information about limits, see <a href="http://docs.aws.amazon.com/kinesisvideostreams/latest/dg/limits.html">Kinesis Video Streams Limits</a>.</p>
capo_kinesis_video_archived_media.errors.invalid_argument_exception.InvalidArgumentException: <p>A specified parameter exceeds its restrictions, is not supported, or can't be used.</p>
capo_kinesis_video_archived_media.errors.not_authorized_exception.NotAuthorizedException: <p>Status Code: 403, The caller is not authorized to perform an operation on the given stream, or the token has expired.</p>
capo_kinesis_video_archived_media.errors.resource_not_found_exception.ResourceNotFoundException: <p> <code>GetImages</code> will throw this error when Kinesis Video Streams can't find the stream that you specified.</p> <p> <code>GetHLSStreamingSessionURL</code> and <code>GetDASHStreamingSessionURL</code> throw this error if a session with a <code>PlaybackMode</code> of <code>ON_DEMAND</code> or <code>LIVE_REPLAY</code>is requested for a stream that has no fragments within the requested time range, or if a session with a <code>PlaybackMode</code> of <code>LIVE</code> is requested for a stream that has no fragments within the last 30 seconds.</p>
capo_kinesis_video_archived_media.errors.UnknownServiceError: The service returned an error code this client does not model.
"""
async def _handler(
req: "AsyncOperationRequest[capo_kinesis_video_archived_media.types.get_media_for_fragment_list_input.GetMediaForFragmentListInput]",
) -> AsyncOperationResponse[
"capo_kinesis_video_archived_media.types.get_media_for_fragment_list_output.GetMediaForFragmentListOutput"
]:
import capo_kinesis_video_archived_media._operations.aws_acuity_reader.get_media_for_fragment_list
(
output,
http_response,
) = await capo_kinesis_video_archived_media._operations.aws_acuity_reader.get_media_for_fragment_list.async_get_media_for_fragment_list(
req.options, req.input
)
return AsyncOperationResponse(output=output, response=http_response)
def _redact_output(
output: "capo_kinesis_video_archived_media.types.get_media_for_fragment_list_output.GetMediaForFragmentListOutput",
) -> dict[str, Any]:
import capo_kinesis_video_archived_media.types.get_media_for_fragment_list_output
return capo_kinesis_video_archived_media.types.get_media_for_fragment_list_output.redact_sensitive(
output
)
interceptors_, options_ = self.operation_options(
config_overrides,
OperationLogging("GetMediaForFragmentList", redact_output=_redact_output),
)
input_: capo_kinesis_video_archived_media.types.get_media_for_fragment_list_input.GetMediaForFragmentListInput = {
"fragments": fragments
}
if stream_name is not None:
input_["stream_name"] = stream_name
if stream_arn is not None:
input_["stream_arn"] = stream_arn
response = await aexecute_pipeline(
AsyncOperationRequest(input=input_, options=options_),
handler=_handler,
interceptors=list(interceptors_),
)
try:
yield response.output
finally:
await response.response.aclose()
|