Run the sample application (Raspberry Pi)

In this step, you will run a sample application of Amazon Kinesis Video Streams Producer SDK C++ to upload the video.

Creating a Stream

  • Open Amazon Kinesis Video Streams console
  • From the top right corner of the console, select one of the following regions
    • us-east-1 (N.Virginia), us-west-2 (Oregon), ap-northeast-1 (Tokyo), eu-west-1 (Ireland), eu-central-1 (Frankfurt)
    • Choose the nearest region if there is no special reason
  • Click on the Video streams in the left menu and then click on the Create video stream button
  • Fill in the form with the following information and click the Create video stream button
    • Video Stream Name: kvs-workshop-stream
    • Select the default configuration

That’s all. A stream has been created.

Getting AWS Credentials

Please select a step by the AWS environment you use.

A) If you are using your own AWS account.

Use the AWS CLI to get temporary credentials to upload the video.

Note that if you have not already set up the AWS CLI on the PC for operation, follow the steps: Installing the AWS CLI and Configuring the AWS CLI.

In the terminal on the PC for operation, run the following commands.

aws sts get-session-token

You will get the following results, so we will set this value to the Raspberry Pi’s environment variable.

{
    "Credentials": {
        "AccessKeyId": "...",
        "SecretAccessKey": "...",
        "SessionToken": "...",
        "Expiration": "2020-01-01T00:00:01Z"
    }
}

Next, open Raspberry Pi terminal and execute the following commands.

export AWS_DEFAULT_REGION="The region you use (e.g. ap-northeast-1, us-west-2)"
export AWS_ACCESS_KEY_ID="The AccessKeyId value of the result above"
export AWS_SECRET_ACCESS_KEY="The SecretAccessKey value of the result above"
export AWS_SESSION_TOKEN="The SessionToken value of the result above"

In this workshop, the AWS CLI is used to get temporary credentials of the IAM user to simplify the procedure, but it is difficult to do this every time on a real camera device. In a real-world use case, you can use a client certificate managed by AWS IoT to get the credentials. How to Eliminate the Need for Hardcoded AWS Credentials in Devices by Using the AWS IoT Credentials Provider

B) If you are using an account by AWS Event Engine

  • Copy the credentials like below from Team Dashboard > AWS Console of Event Engine and paste them to Raspberry Pi terminal
export AWS_DEFAULT_REGION=...
export AWS_ACCESS_KEY_ID=...
export AWS_SECRET_ACCESS_KEY=...
export AWS_SESSION_TOKEN=...

Uploading to a video stream

Connect the USB camera to the Raspberry Pi.

Next, execute the following commands on the Raspberry Pi terminal.

cd ~/amazon-kinesis-video-streams-producer-sdk-cpp/build
./kvs_gstreamer_sample kvs-workshop-stream

If you get an error, make sure you have set the AWS credentials as the environment variables and the stream name (kvs-workshop-stream) is correct.

This video stream will be used in the following steps, leave the command running, or rerun it when you run the next step.

Checking the video stream

  • Open Amazon Kinesis Video Streams console
  • Click on the Video streams in the left menu > Click on kvs-workshop-stream in the list of streams
  • Click on the Media playback section to expand it, and you will see the video from the camera

Media Playback

That’s it. You learned how to upload your videos with Amazon Kinesis Video Streams Producer SDK C++. Next, let’s jump to 1-4 to download the video in MP4 format.