Skip to content

AWS.KinesisVideo reference

Source: src/AWS/KinesisVideo/GetClip.ts

Runtime binding for kinesisvideo:GetClip (archived media data plane).

Bind this operation to a Stream inside a function runtime to get a callable that resolves the per-stream data endpoint (GetDataEndpoint) and downloads an MP4 clip covering the requested fragment range. The response Payload is a streaming body.

// init
const getClip = yield* AWS.KinesisVideo.GetClip(stream);
// runtime
const clip = yield* getClip({
ClipFragmentSelector: {
FragmentSelectorType: "SERVER_TIMESTAMP",
TimestampRange: { StartTimestamp: start, EndTimestamp: end },
},
});

Source: src/AWS/KinesisVideo/GetDASHStreamingSessionURL.ts

Runtime binding for kinesisvideo:GetDASHStreamingSessionURL (archived media data plane).

Bind this operation to a Stream inside a function runtime to get a callable that resolves the per-stream data endpoint (GetDataEndpoint) and returns a short-lived MPEG-DASH playback URL.

// init
const getDash = yield* AWS.KinesisVideo.GetDASHStreamingSessionURL(stream);
// runtime
const { DASHStreamingSessionURL } = yield* getDash({
PlaybackMode: "LIVE",
});

Source: src/AWS/KinesisVideo/GetHLSStreamingSessionURL.ts

Runtime binding for kinesisvideo:GetHLSStreamingSessionURL (archived media data plane).

Bind this operation to a Stream inside a function runtime to get a callable that resolves the per-stream data endpoint (GetDataEndpoint) and returns a short-lived HLS playback URL.

Live HLS Playback URL

// init
const getHls = yield* AWS.KinesisVideo.GetHLSStreamingSessionURL(stream);
// runtime
const { HLSStreamingSessionURL } = yield* getHls({
PlaybackMode: "LIVE",
});

Wire into a Lambda Function

// Provide the GetHLSStreamingSessionURLHttp layer on the Function's
// init Effect. Data-plane calls fan out to GetDataEndpoint first, so
// allow a generous timeout.
export default PlaybackFunction.make(
{ main: import.meta.url, functionUrl: true, timeout: Duration.seconds(30) },
Effect.gen(function* () {
const stream = yield* AWS.KinesisVideo.Stream("Camera", {
mediaType: "video/h264",
dataRetention: "24 hours",
});
const getHls = yield* AWS.KinesisVideo.GetHLSStreamingSessionURL(stream);
return {
fetch: Effect.gen(function* () {
const { HLSStreamingSessionURL } = yield* getHls({
PlaybackMode: "LIVE",
});
return HttpServerResponse.json({ url: HLSStreamingSessionURL });
}),
};
}).pipe(Effect.provide(AWS.KinesisVideo.GetHLSStreamingSessionURLHttp)),
);

Source: src/AWS/KinesisVideo/GetIceServerConfig.ts

Runtime binding for kinesisvideo:GetIceServerConfig (WebRTC signaling data plane).

Bind this operation to a SignalingChannel inside a function runtime to get a callable that resolves the per-channel HTTPS signaling endpoint (GetSignalingChannelEndpoint) and returns TURN server URIs with short-lived credentials for establishing WebRTC connectivity.

ICE Server Configuration

// init
const getIceServers = yield* AWS.KinesisVideo.GetIceServerConfig(channel);
// runtime
const { IceServerList } = yield* getIceServers({ ClientId: "viewer-1" });

Wire into a Lambda Function

// Provide the GetIceServerConfigHttp layer on the Function's init Effect.
export default SignalingFunction.make(
{ main: import.meta.url, functionUrl: true, timeout: Duration.seconds(30) },
Effect.gen(function* () {
const channel = yield* AWS.KinesisVideo.SignalingChannel("Doorbell");
const getIceServers = yield* AWS.KinesisVideo.GetIceServerConfig(channel);
return {
fetch: Effect.gen(function* () {
const { IceServerList } = yield* getIceServers({
ClientId: "viewer-1",
});
return HttpServerResponse.json({ iceServers: IceServerList });
}),
};
}).pipe(Effect.provide(AWS.KinesisVideo.GetIceServerConfigHttp)),
);

Source: src/AWS/KinesisVideo/GetImages.ts

Runtime binding for kinesisvideo:GetImages (archived media data plane).

Bind this operation to a Stream inside a function runtime to get a callable that resolves the per-stream data endpoint (GetDataEndpoint) and extracts base64-encoded still images (JPEG/PNG) from the stored media at the requested sampling interval.

// init
const getImages = yield* AWS.KinesisVideo.GetImages(stream);
// runtime
const { Images } = yield* getImages({
ImageSelectorType: "SERVER_TIMESTAMP",
StartTimestamp: start,
EndTimestamp: end,
Format: "JPEG",
});

Source: src/AWS/KinesisVideo/GetMedia.ts

Runtime binding for kinesisvideo:GetMedia (media data plane).

Bind this operation to a Stream inside a function runtime to get a callable that resolves the per-stream data endpoint (GetDataEndpoint) and opens a media stream starting at the requested selector. The response Payload is a streaming body of MKV-packaged media.

Read Media from the Earliest Fragment

// init
const getMedia = yield* AWS.KinesisVideo.GetMedia(stream);
// runtime
const media = yield* getMedia({
StartSelector: { StartSelectorType: "EARLIEST" },
});

Wire into a Lambda Function

// Provide the GetMediaHttp layer on the Function's init Effect; merge
// with the other KinesisVideo layers when using several bindings.
export default MediaFunction.make(
{ main: import.meta.url, functionUrl: true, timeout: Duration.seconds(30) },
Effect.gen(function* () {
const stream = yield* AWS.KinesisVideo.Stream("Camera", {
mediaType: "video/h264",
dataRetention: "24 hours",
});
const getMedia = yield* AWS.KinesisVideo.GetMedia(stream);
// ... read media.Payload in the fetch handler
return { fetch: handler };
}).pipe(Effect.provide(AWS.KinesisVideo.GetMediaHttp)),
);

Source: src/AWS/KinesisVideo/GetMediaForFragmentList.ts

Runtime binding for kinesisvideo:GetMediaForFragmentList (archived media data plane).

Bind this operation to a Stream inside a function runtime to get a callable that resolves the per-stream data endpoint (GetDataEndpoint) and downloads MKV-packaged media for an explicit list of fragment numbers (typically discovered via ListFragments). The response Payload is a streaming body.

// init
const getFragmentMedia =
yield* AWS.KinesisVideo.GetMediaForFragmentList(stream);
// runtime
const media = yield* getFragmentMedia({
Fragments: fragments.map((f) => f.FragmentNumber!),
});

Source: src/AWS/KinesisVideo/JoinStorageSession.ts

Runtime binding for kinesisvideo:JoinStorageSession (WebRTC storage data plane).

Bind this operation to a SignalingChannel inside a function runtime to get a callable that resolves the per-channel WEBRTC storage endpoint (GetSignalingChannelEndpoint) and joins the ongoing WebRTC session as the video-producing master so the media is recorded into the channel’s associated Kinesis Video stream.

Requires the channel’s media storage to be configured (an ENABLED MediaStorageConfiguration linking the channel to a stream); without it the endpoint discovery fails with the typed SignalingEndpointUnavailable error.

// init
const joinStorage = yield* AWS.KinesisVideo.JoinStorageSession(channel);
// runtime
yield* joinStorage();

Source: src/AWS/KinesisVideo/JoinStorageSessionAsViewer.ts

Runtime binding for kinesisvideo:JoinStorageSessionAsViewer (WebRTC storage data plane).

Bind this operation to a SignalingChannel inside a function runtime to get a callable that resolves the per-channel WEBRTC storage endpoint (GetSignalingChannelEndpoint) and joins the ongoing WebRTC session as a viewer, identified by clientId.

Requires the channel’s media storage to be configured (an ENABLED MediaStorageConfiguration linking the channel to a stream); without it the endpoint discovery fails with the typed SignalingEndpointUnavailable error.

JoinStorageSessionAsViewer: WebRTC Storage

Section titled “JoinStorageSessionAsViewer: WebRTC Storage”
// init
const joinAsViewer =
yield* AWS.KinesisVideo.JoinStorageSessionAsViewer(channel);
// runtime
yield* joinAsViewer({ clientId: "viewer-1" });

Source: src/AWS/KinesisVideo/ListFragments.ts

Runtime binding for kinesisvideo:ListFragments (archived media data plane).

Bind this operation to a Stream inside a function runtime to get a callable that resolves the per-stream data endpoint (GetDataEndpoint) and lists the media fragments stored in the requested timestamp range.

// init
const listFragments = yield* AWS.KinesisVideo.ListFragments(stream);
// runtime
const { Fragments } = yield* listFragments({
FragmentSelector: {
FragmentSelectorType: "SERVER_TIMESTAMP",
TimestampRange: { StartTimestamp: start, EndTimestamp: end },
},
});

Source: src/AWS/KinesisVideo/SendAlexaOfferToMaster.ts

Runtime binding for kinesisvideo:SendAlexaOfferToMaster (WebRTC signaling data plane).

Bind this operation to a SignalingChannel inside a function runtime to get a callable that resolves the per-channel HTTPS signaling endpoint (GetSignalingChannelEndpoint) and delivers a base64-encoded SDP offer from an Alexa display device to the connected master peer, returning the master’s SDP answer.

If no master is connected the service holds the offer for redelivery until the message TTL expires — bound the call with a timeout when the master may be offline.

SendAlexaOfferToMaster: WebRTC Connectivity

Section titled “SendAlexaOfferToMaster: WebRTC Connectivity”
// init
const sendOffer = yield* AWS.KinesisVideo.SendAlexaOfferToMaster(channel);
// runtime
const { Answer } = yield* sendOffer({
SenderClientId: "alexa-device-1",
MessagePayload: base64SdpOffer,
});

Source: src/AWS/KinesisVideo/SignalingChannel.ts

An Amazon Kinesis Video Streams WebRTC signaling channel — the rendezvous point that WebRTC master and viewer peers use to exchange SDP offers, answers, and ICE candidates.

messageTtl is updated in place; changing channelName or type replaces the channel.

Basic Signaling Channel

import * as AWS from "alchemy/AWS";
const channel = yield* AWS.KinesisVideo.SignalingChannel("Doorbell");

Channel with Message TTL

const channel = yield* AWS.KinesisVideo.SignalingChannel("Doorbell", {
messageTtl: "30 seconds",
tags: { Environment: "production" },
});
// init
const getIceServers = yield* AWS.KinesisVideo.GetIceServerConfig(channel);
// runtime — TURN URIs + short-lived credentials for a WebRTC peer
const { IceServerList } = yield* getIceServers({ ClientId: "viewer-1" });

Source: src/AWS/KinesisVideo/Stream.ts

An Amazon Kinesis Video Stream for ingesting, storing, and consuming live video.

Stream creation is asynchronous — the provider waits (bounded) for the stream to become ACTIVE before returning. deviceName and mediaType are updated in place; dataRetention converges via UpdateDataRetention; changing streamName or kmsKeyId replaces the stream.

Basic Video Stream

import * as AWS from "alchemy/AWS";
const stream = yield* AWS.KinesisVideo.Stream("Camera");

Stream with Retention and Media Type

const stream = yield* AWS.KinesisVideo.Stream("Camera", {
mediaType: "video/h264",
dataRetention: "24 hours",
tags: { Environment: "production" },
});

Bind data-plane read operations in the init phase and use them in runtime handlers. The bindings resolve the per-stream data endpoint (GetDataEndpoint) automatically.

HLS Playback URL

// init
const getHls = yield* AWS.KinesisVideo.GetHLSStreamingSessionURL(stream);
// runtime
const { HLSStreamingSessionURL } = yield* getHls({ PlaybackMode: "LIVE" });

Raw Media

// init
const getMedia = yield* AWS.KinesisVideo.GetMedia(stream);
// runtime
const media = yield* getMedia({
StartSelector: { StartSelectorType: "EARLIEST" },
});