Skip to content

get_clip

get_clip(
    clip_fragment_selector: ClipFragmentSelector,
    *,
    config_overrides: Optional[KinesisVideoArchivedMediaClientConfig] = None,
    stream_name: Optional[StreamName] = None,
    stream_arn: Optional[ResourceARN] = None,
) -> Generator[GetClipOutput]

Downloads an MP4 file (clip) containing the archived, on-demand media from the specified video stream over the specified time range.

Both the StreamName and the StreamARN parameters are optional, but you must specify either the StreamName or the StreamARN when invoking this API operation.

As a prerequisite to using GetCLip API, you must obtain an endpoint using GetDataEndpoint, specifying GET_CLIP for the APIName parameter.

An Amazon Kinesis video stream has the following requirements for providing data through MP4:

  • The media must contain h.264 or h.265 encoded video and, optionally, AAC or G.711 encoded audio. Specifically, the codec ID of track 1 should be V_MPEG/ISO/AVC (for h.264) or V_MPEGH/ISO/HEVC (for H.265). Optionally, the codec ID of track 2 should be A_AAC (for AAC) or A_MS/ACM (for G.711).

  • Data retention must be greater than 0.

  • The video track of each fragment must contain codec private data in the Advanced Video Coding (AVC) for H.264 format and HEVC for H.265 format. For more information, see MPEG-4 specification ISO/IEC 14496-15. For information about adapting stream data to a given format, see NAL Adaptation Flags.

  • The audio track (if present) of each fragment must contain codec private data in the AAC format (AAC specification ISO/IEC 13818-7) or the MS Wave format.

You can monitor the amount of outgoing data by monitoring the GetClip.OutgoingBytes Amazon CloudWatch metric. For information about using CloudWatch to monitor Kinesis Video Streams, see Monitoring Kinesis Video Streams. For pricing information, see Amazon Kinesis Video Streams Pricing and Amazon Web Services Pricing. Charges for outgoing Amazon Web Services data apply.

Parameters:

  • stream_name (Optional[StreamName], default: None ) –

    The name of the stream for which to retrieve the media clip.

    You must specify either the StreamName or the StreamARN.

  • stream_arn (Optional[ResourceARN], default: None ) –

    The Amazon Resource Name (ARN) of the stream for which to retrieve the media clip.

    You must specify either the StreamName or the StreamARN.

  • clip_fragment_selector (ClipFragmentSelector) –

    The time range of the requested clip and the source of the timestamps.

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.

  • InvalidCodecPrivateDataException –

    The codec private data in at least one of the tracks of the video stream is not valid for this operation.

  • InvalidMediaFrameException –

    One or more frames in the requested clip could not be parsed based on the specified codec.

  • MissingCodecPrivateDataException –

    No codec private data was found in at least one of tracks of the video stream.

  • NoDataRetentionException –

    GetImages was requested for a stream that does not retain data (that is, has a DataRetentionInHours of 0).

  • 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.

  • UnsupportedStreamMediaTypeException –

    The type of the media (for example, h.264 or h.265 video or ACC or G.711 audio) could not be determined from the codec IDs of the tracks in the first fragment for a playback session. The codec ID for track 1 should be V_MPEG/ISO/AVC and, optionally, the codec ID for track 2 should be A_AAC.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_kinesis_video_archived_media/_services/kinesis_video_archived_media.py
@contextmanager
def get_clip(
    self,
    clip_fragment_selector: "capo_kinesis_video_archived_media.types.clip_fragment_selector.ClipFragmentSelector",
    *,
    config_overrides: Optional[KinesisVideoArchivedMediaClientConfig] = 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,
) -> "Generator[capo_kinesis_video_archived_media.types.get_clip_output.GetClipOutput]":
    """<p>Downloads an MP4 file (clip) containing the archived, on-demand media from the specified video stream over the specified time range. </p> <p>Both the StreamName and the StreamARN parameters are optional, but you must specify either the StreamName or the StreamARN when invoking this API operation. </p> <p>As a prerequisite to using GetCLip API, you must obtain an endpoint using <code>GetDataEndpoint</code>, specifying GET_CLIP for<code></code> the <code>APIName</code> parameter. </p> <p>An Amazon Kinesis video stream has the following requirements for providing data through MP4:</p> <ul> <li> <p>The media must contain h.264 or h.265 encoded video and, optionally, AAC or G.711 encoded audio. Specifically, the codec ID of track 1 should be <code>V_MPEG/ISO/AVC</code> (for h.264) or V_MPEGH/ISO/HEVC (for H.265). Optionally, the codec ID of track 2 should be <code>A_AAC</code> (for AAC) or A_MS/ACM (for G.711).</p> </li> <li> <p>Data retention must be greater than 0.</p> </li> <li> <p>The video track of each fragment must contain codec private data in the Advanced Video Coding (AVC) for H.264 format and HEVC for H.265 format. For more information, see <a href="https://www.iso.org/standard/55980.html">MPEG-4 specification ISO/IEC 14496-15</a>. For information about adapting stream data to a given format, see <a href="http://docs.aws.amazon.com/kinesisvideostreams/latest/dg/producer-reference-nal.html">NAL Adaptation Flags</a>.</p> </li> <li> <p>The audio track (if present) of each fragment must contain codec private data in the AAC format (<a href="https://www.iso.org/standard/43345.html">AAC specification ISO/IEC 13818-7</a>) or the <a href="http://www-mmsp.ece.mcgill.ca/Documents/AudioFormats/WAVE/WAVE.html">MS Wave format</a>.</p> </li> </ul> <p>You can monitor the amount of outgoing data by monitoring the <code>GetClip.OutgoingBytes</code> Amazon CloudWatch metric. For information about using CloudWatch to monitor Kinesis Video Streams, see <a href="http://docs.aws.amazon.com/kinesisvideostreams/latest/dg/monitoring.html">Monitoring Kinesis Video Streams</a>. For pricing information, see <a href="https://aws.amazon.com/kinesis/video-streams/pricing/">Amazon Kinesis Video Streams Pricing</a> and <a href="https://aws.amazon.com/pricing/"> Amazon Web Services Pricing</a>. Charges for outgoing Amazon Web Services data apply.</p>

    Args:
        stream_name: <p>The name of the stream for which to retrieve the media clip. </p> <p>You must specify either the StreamName or the StreamARN. </p>
        stream_arn: <p>The Amazon Resource Name (ARN) of the stream for which to retrieve the media clip. </p> <p>You must specify either the StreamName or the StreamARN. </p>
        clip_fragment_selector: <p>The time range of the requested clip and the source of the timestamps.</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.invalid_codec_private_data_exception.InvalidCodecPrivateDataException: <p>The codec private data in at least one of the tracks of the video stream is not valid for this operation.</p>
        capo_kinesis_video_archived_media.errors.invalid_media_frame_exception.InvalidMediaFrameException: <p>One or more frames in the requested clip could not be parsed based on the specified codec.</p>
        capo_kinesis_video_archived_media.errors.missing_codec_private_data_exception.MissingCodecPrivateDataException: <p>No codec private data was found in at least one of tracks of the video stream.</p>
        capo_kinesis_video_archived_media.errors.no_data_retention_exception.NoDataRetentionException: <p> <code>GetImages</code> was requested for a stream that does not retain data (that is, has a <code>DataRetentionInHours</code> of 0). </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.unsupported_stream_media_type_exception.UnsupportedStreamMediaTypeException: <p>The type of the media (for example, h.264 or h.265 video or ACC or G.711 audio) could not be determined from the codec IDs of the tracks in the first fragment for a playback session. The codec ID for track 1 should be <code>V_MPEG/ISO/AVC</code> and, optionally, the codec ID for track 2 should be <code>A_AAC</code>.</p>
        capo_kinesis_video_archived_media.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_kinesis_video_archived_media.types.get_clip_input.GetClipInput]",
    ) -> OperationResponse[
        "capo_kinesis_video_archived_media.types.get_clip_output.GetClipOutput"
    ]:
        import capo_kinesis_video_archived_media._operations.aws_acuity_reader.get_clip

        output, http_response = (
            capo_kinesis_video_archived_media._operations.aws_acuity_reader.get_clip.get_clip(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    def _redact_output(
        output: "capo_kinesis_video_archived_media.types.get_clip_output.GetClipOutput",
    ) -> dict[str, Any]:
        import capo_kinesis_video_archived_media.types.get_clip_output

        return capo_kinesis_video_archived_media.types.get_clip_output.redact_sensitive(
            output
        )

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("GetClip", redact_output=_redact_output)
    )
    input_: capo_kinesis_video_archived_media.types.get_clip_input.GetClipInput = {
        "clip_fragment_selector": clip_fragment_selector
    }
    if stream_name is not None:
        input_["stream_name"] = stream_name
    if stream_arn is not None:
        input_["stream_arn"] = stream_arn

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    try:
        yield response.output
    finally:
        response.response.close()