AWS Kinesis

Streaming with Raspberry Pi to AWS Kinesis

AWS Kinesis

Streaming with Raspberry Pi to AWS Kinesis

Live video streaming in few simple steps

This article describes the procedure of streaming video from Raspberry Pi to AWS Kinesis including services configuration, Raspberry Pi and camera setup and C++ SDK installation. 

 

Prerequisites

 

Before diving into the details of implementation, let’s take a step back and prepare the tools. 

RaspberryPi

To stream video from Raspberry Pi to AWS a couple of things are needed. To get the things working we need:

  • Raspberry Pi 3 model B or newer.
  • Camera module or USB camera alternatively.
  • 8 GB or bigger SD card.
  • The Raspbian OS installed on the Raspberry.

To get the Raspbian OS, download and install Raspberry Pi Imager from Raspberry Pi official website. Then, flash an SD card with Raspberry Pi OS. Once that’s done, plug the SD card into Raspberry.

RPi Login screen
RPi Login screen

 

Amazon Kinesis Video Stream

 

For the AWS Account, an IAM user with permission to write to a Kinesis video stream and access permission should be created. Then, visit Amazon Kinesis Video home page. Choose Create video stream, enter StreamName (remember to save it for later). The rest can remain as default. For now, AWS should not charge You for anything.

 

Camera module

 

Now it’s time to check if the hardware works correctly. Power up Raspberry and connect it to WiFi. For convenience, one can connect to RPi using ssh protocol. Next, depending on the model of the camera, follow the appropriate steps. If You are using a USB Webcam, skip to the next chapter.

 

Camera module 1

The first step is to update the /etc/modules file by adding the bcm2835-v4l2 line, if it’s not already there and then reboot Raspberry Pi. The next step is to open raspi-config and select two options:

  • Interfacing Options
  • Legacy Camera

The last step is to verify if the camera works. To do so execute the command raspistill -v -o test.jpg. The camera should take the picture and save it as test.jpg.

Camera module 2 or 3

In this case, simply execute these four commands

 

sudo apt-get update

sudo apt-get upgrade

sudo reboot

libcamera-hello



As the first three commands are well-known, describing them is not necessary. The last one starts a camera preview stream and displays it on the screen.

 

Install software prerequisites

 

So the camera should be working by now and it’s time to install the C++ producer SDK. However, beforehand the installation of a couple of libraries is mandatory.

 

sudo apt update

sudo apt install -y \

  automake \

  build-essential \

  cmake \

  git \

  gstreamer1.0-plugins-base-apps \

  gstreamer1.0-plugins-bad \

  gstreamer1.0-plugins-good \

  gstreamer1.0-plugins-ugly \

  gstreamer1.0-tools \

  gstreamer1.0-omx-generic \

  libcurl4-openssl-dev \

  libgstreamer1.0-dev \

  libgstreamer-plugins-base1.0-dev \

  liblog4cplus-dev \

  libssl-dev \

  pkg-config



Moreover, the GStreamer plugin libcamerasrc is needed if You are using libcamera. The last step before installing the SDK is to get the PEM file and copy its content to /etc/ssl/cert.pem.

 

sudo curl https://www.amazontrust.com/repository/AmazonRootCA1.pem -o /etc/ssl/AmazonRootCA1.pem

sudo chmod 644 /etc/ssl/AmazonRootCA1.pem



Kinesis Video Streams C++ producer SDK

 

Download the sdk from GitHub:

git clone

https://github.com/awslabs/amazon-kinesis-video-streams-producer-sdk-cpp.git –single-branch -b master kvs-producer-sdk-cpp

 


Create a build for in the repository and build SDK:

 

cmake .. -DBUILD_GSTREAMER_PLUGIN=ON -DBUILD_DEPENDENCIES=OFF -DALIGNED_MEMORY_MODEL=ON

make -j$(nproc)

 

 

Check if libgstkvssink.so is present. If yes, then set the GST_PLUGIN_PATH to the directory where it is located. The last step is to load kvssink

 

gst-inspect-1.0 kvssink

 

 

To navigate use arrows or press ‘q’ to quit.

 

Stream video

 

Finally, everything is ready to stream the video. In order to do so, set Your credentials and region:

 

export AWS_ACCESS_KEY_ID=YourAccessKey

export AWS_SECRET_ACCESS_KEY=YourSecretKey

export AWS_DEFAULT_REGION=YourRegion

 

 

Next, start streaming with the gst-launch-1.0 command. Remember to provide stream name set in the Prerequisites and adjust parameters depending on Your camera module.

 

To play the video, open Kinesis Video Streams console and select Stream name. The video from Raspberry Pi should appear there after a couple of seconds.

 

Conclusion

 

This article covers the process of streaming video from Raspberry Pi to AWS Kinesis Video Stream. It starts with explaining how to configure Raspberry Pi and AWS, camera module implementation, SDK installation and finally streaming the video. The whole process, even with potential troubleshooting and debugging,should not take more than eight hours. Don’t hesitate to contact us with any questions!



 



 

Recent entries

IoT in Space image

IoT in Space – Expanding Horizons

Spacetech future   Introduction   Space exploration is more advanced than ever before, and future generations might become modern-day Columbus. As we venture into space exploration deeper and deeper, we have

IoT in Space image

IoT in Space – Expanding Horizons

Spacetech future   Introduction   Space exploration is more advanced than ever before, and future generations might become modern-day Columbus. As we venture into space exploration deeper and deeper, we have

We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.