Example: Streaming from an RTSP source - Amazon Kinesis Video Streams
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Example: Streaming from an RTSP source

The C++ Producer Library contains a definition for a Docker container that connects to a Real-Time Streaming Protocol (RTSP) network camera. Using Docker standardizes the operating environment for Kinesis Video Streams, which streamlines building and using the application.

The following procedure demonstrates how to set up and use the RTSP demo application.

Video tutorials

This video shows how to set up a Raspberry Pi to send RTSP feeds to Amazon cloud and Amazon Kinesis Video Streams. This is an end-to-end demonstration.

This video demonstrates how to capture images from a feed to use computer vision and Amazon Rekognition to process the images and send alerts.

Prerequisites

To run the Kinesis Video Streams RTSP example application, you must have the following:

Build the Docker image

First, build the Docker image that the demo application will run inside.

  1. Clone the Amazon Kinesis Video Streams demos repository.

    git clone https://github.com/aws-samples/amazon-kinesis-video-streams-demos.git
  2. Change to the directory containing the Dockerfile. In this case, it is the docker-rtsp directory.

    cd amazon-kinesis-video-streams-demos/producer-cpp/docker-rtsp/
  3. Use the following command to build the Docker image. This command creates the image and tags it as rtspdockertest.

    docker build -t rtspdockertest .
  4. Run docker images and search for the image ID tagged with rtspdockertest.

    For example, in the sample output below, the IMAGE ID is 54f0d65f69b2.

    REPOSITORY TAG IMAGE ID CREATED PLATFORM SIZE BLOB SIZE rtspdockertest latest 54f0d65f69b2 10 minutes ago linux/arm64 653.1 MiB 292.4 MiB

    You will need this in a later step.

Run the RTSP example application

You can run the RTSP example application either from within or outside the Docker container. Follow the appropriate instructions below.

Within the Docker container

Run the RTSP example application
  1. Start the Amazon Kinesis Video Streams Docker container using the following command:

    docker run -it YourImageId /bin/bash
  2. To start the sample application, provide your Amazon credentials, the name of the Amazon Kinesis video stream, and the URL of the RTSP network camera.

    Important

    If you are using temporary credentials, you'll also need to provide your AWS_SESSION_TOKEN. See the second example below.

    export AWS_ACCESS_KEY_ID=YourAccessKeyId export AWS_SECRET_ACCESS_KEY=YourSecretKeyId export AWS_DEFAULT_REGION=YourAWSRegion ./kvs_gstreamer_sample YourStreamName YourRtspUrl

    Temporary credentials:

    export AWS_ACCESS_KEY_ID=YourAccessKeyId export AWS_SECRET_ACCESS_KEY=YourSecretKeyId export AWS_SESSION_TOKEN=YourSessionToken export AWS_DEFAULT_REGION=YourAWSRegion ./kvs_gstreamer_sample YourStreamName YourRtspUrl
  3. Sign into the Amazon Web Services Management Console and open the Kinesis Video Streams console.

    View the stream.

  4. To exit the Docker container, close the terminal window or type exit.

Outside the Docker container

From outside the Docker container, use the following command:

docker run -it YourImageId /bin/bash -c "export AWS_ACCESS_KEY_ID=YourAccessKeyId; export AWS_SECRET_ACCESS_KEY=YourSecretKeyId; export AWS_SESSION_TOKEN=YourSessionToken; export AWS_DEFAULT_REGION=YourAmazonRegion; ./kvs_gstreamer_sample YourStreamName YourRtspUrl"