Skip to content

GetMedia

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, url: 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)),
);