0

Body of the handler:

const one: ValidatedEventAPIGatewayProxyEvent<typeof schema> = async (event) => {
  const input = {
    "EndTimestamp": new Date(1653843539000),
    "Format": "JPEG",
    "ImageSelectorType": "PRODUCER_TIMESTAMP",   
    "MaxResults": 10,
    "SamplingInterval": 3000,
    "StartTimestamp": new Date(1653843480000),
    "StreamName": "ExampleStream"
  }

  console.log('input', JSON.stringify(input, null,2))
  const client = new KinesisVideoArchivedMediaClient({ region: "eu-central-1" });
  const command = new GetImagesCommand(input);
  const res = await client.send(command);

  console.log('res', JSON.stringify(res, null,2))

  return formatJSONResponse({
    message: 'success',
    event,
  });
}

Current result - log from the code:

2022-05-29T17:43:31.063Z    2d#################535  INFO    res {
    "$metadata": {
        "httpStatusCode": 200,
        "requestId": "38##################0e",
        "attempts": 1,
        "totalRetryDelay": 0
    }
}

Expected: response including Images, NextToken properties

Other details:

Request with the same input executed from Postman gives a correct response:

{
    "Images": [
        {
            "Error": "NO_MEDIA",
            "ImageContent": null,
            "TimeStamp": 1.65384348E9
        },
        {
            "Error": null,
            "ImageContent": "/9j/4AAQSkZJRgABAgAAAQABAAD//gARTGF2YzU4LjEzNC4xMDAA/...",
            "TimeStamp": 1.653843486E9
        }
    ],
    "NextToken": "eyJleHB...n0ifQ=="
}

What I'm doing wrong? Thanks in advance

DarekW
  • 21
  • 6

1 Answers1

0

I had the same issue using the v3 SDK so I tried using v2 with no luck and data was returning anything.

But I manage to make it work with v2 by getting first the data endpoint before calling getImages.

Like this:

import { KinesisVideo, KinesisVideoArchivedMedia } from 'aws-sdk'

const kinesisVideoClient = new KinesisVideo({
  apiVersion: '2017-09-30'
  region: process.env.AWS_REGION
})

const { DataEndpoint } = await kinesisVideoClient.getDataEndpoint({ APIName: 'GET_IMAGES', StreamName: 'my-stream' }).promise()

const params = {
  StreamName: 'my-stream',
  ImageSelectorType: 'PRODUCER_TIMESTAMP',
  StartTimestamp: new Date(),
  EndTimestamp: new Date(),
  SamplingInterval: 3000,
  Format: 'JPEG'
}

const options = {
  endpoint: DataEndpoint,
  apiVersion: '2017-09-30',
  region: process.env.AWS_REGION
}

const kinesisVideoArchiveMediaClient = new KinesisVideoArchivedMedia(options)

const { Images } = await kinesisVideoArchiveMediaClient.getImages(params).promise()

console.log(Images)

Hope this helps :)

PS. I used the latest AWS SDK v2 with a Lambda layer, the version provided by default on Lambda doesn't have the getImages function.

jagonzalr
  • 1
  • 1
  • 2