Example: Streaming from an RTSP source
The C++ contains
a definition for a Docker
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 AWS 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:
-
Docker: For information about installing and using Docker, see the following links:
-
RTSP network camera source: For information about recommended cameras, see System requirements.
Build the Docker image
First, build the Docker image that the demo application will run inside.
-
Clone the Amazon Kinesis Video Streams demos repository.
git clone https://github.com/aws-samples/amazon-kinesis-video-streams-demos.git
-
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/
-
Use the following command to build the Docker image. This command creates the image and tags it as rtspdockertest.
docker build -t rtspdockertest .
-
Run
docker images
and search for the image ID tagged withrtspdockertest
.For example, in the sample output below, the
IMAGE ID
is54f0d65f69b2
.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
-
Start the Amazon Kinesis Video Streams Docker container using the following command:
docker run -it
YourImageId
/bin/bash -
To start the sample application, provide your AWS 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_sampleYourStreamName
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_sampleYourStreamName
YourRtspUrl
-
Sign into the AWS Management Console and open the Kinesis Video Streams console
. View the stream.
-
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=YourAWSRegion
; ./kvs_gstreamer_sampleYourStreamName
YourRtspUrl
"