Amazon Kinesis Video Streams
Developer Guide

Using the C++ Producer SDK on Windows

This tutorial demonstrates how to build and run the Producer Libraries on Microsoft Windows. You can then stream video to Kinesis Video Streams from sources such as webcams, USB cameras, or RTSP (Real Time Streaming Protocol) cameras. When you start streaming from your media source to a Kinesis video stream, you can view the video in the Kinesis Video Streams console. You can also build applications that operate on the streaming video that is available in your Kinesis video stream.

Building and Running the Producer SDK: Minimalist GNU for Windows (MinGW)

Minimalist GNU for Windows (MinGW) is an open-source programming toolchain for developing native Windows applications. You can use MinGW to build the Kinesis Video Streams Producer SDK for Windows and then run one of the sample applications to start streaming video.

This section describes prerequisites and steps needed to build the Amazon Kinesis Video Streams Producer SDK using the MinGW compiler.

Prerequisites

Before you start, ensure that you have the following:

  • Download and install the MSYS2 version for your specific Windows platform. MSYS2 provides all the tools to build native Windows applications using MinGW toolchains.

Building the Producer SDK Using MinGW

Follow these steps to use the MinGW runtime environment to compile the Kinesis Video StreamsProducer SDK on Windows.

  1. Launch the MinGW shell (mingw64.exe) from the C:\msys32 or C:\msys64 directory. Make sure that you are opening the mingw64.exe or mingw32.exe based on your platform, and not the MSYS2 application. The MSYS2 application is the default application that is opened after you finish installing MSYS2.

  2. Install Git by running the following command in the MinGW shell:

    pacman -S git
  3. Download the Kinesis Video Streams Producer SDK from GitHub:

    git clone https://github.com/awslabs/amazon-kinesis-video-streams-producer-sdk-cpp.git
  4. Navigate to the amazon-kinesis-video-streams-producer-sdk-cpp/kinesis-video-native-build directory, and run the following install script to build the Producer SDK:

    msys2-install-script -a

    Note

    • Accept all of the prompts when the script runs.

    • Log4cplus is compiled from source, but all other components are downloaded as pre-built binaries.

Running the Producer SDK to Send Video to Kinesis Video Streams

After compiling the Kinesis Video Streams Producer SDK using MinGW, follow these steps to run it:

Step 1: Set Environment Variables

  • In the MinGW shell, set the following environment variables:

    export AWS_ACCESS_KEY_ID=YOUR_ACCESS_KEY export AWS_SECRET_ACCESS_KEY=YOUR_SECRET_ACCESS_KEY export GST_PLUGIN_PATH=$PWD

    Note

    YOUR_ACCESS_KEY and YOUR_SECRET_ACCESS_KEY are the access keys for your AWS account used for signing programmatic requests that you make to AWS. For more information, see Managing Access Keys for IAM Users.

Step 2: Run the Sample Application for Your Media Source

  1. To stream video from your PC webcam, run the sample application from the kinesis-video-native-build directory using the following command:

    kinesis_video_gstreamer_sample_app.exe my-stream-name
  2. To stream video from your PC webcam using a custom configuration, such as a specific bitrate or resolution, run the Kinesis Video Streams Producer SDK GStreamer plugin using the gst-launch-1.0 command:

    gst-launch-1.0 ksvideosrc do-timestamp=TRUE ! video/x-raw,width=640,height=480,framerate=30/1 ! videoconvert ! x264enc bframes=0 key-int-max=45 bitrate=512 ! video/x-h264,profile=baseline,stream-format=avc,alignment=au,width=640,height=480,framerate=30/1 ! kvssink stream-name="your-stream-name" access-key=your_accesskey_id secret-key=your_secret_access_key

    For information about how to determine the parameters for the gst-launch-1.0 command, see GStreamer Element Parameter Reference.

    Note

    If you are using IoT credentials instead of your access key and secret key to authenticate, you can supply IoT credentials as parameters to the gst-launch-1.0 command.

    The following example demonstrates using IoT parameters to stream video from an RTSP camera:

    gst-launch-1.0 rtspsrc location=rtsp://YourCameraRtspUrl short-header=TRUE ! rtph264depay ! video/x-h264, format=avc,alignment=au ! kvssink stream-name="your-iot-stream" iot-certificate="iot-certificate,endpoint=endpoint,cert-path=/path/to/certificate,key-path=/path/to/private/key,ca-path=/path/to/ca-cert,role-aliases=role-aliases"
  3. To stream video from an RTSP (network) camera, run the sample application from the kinesis-video-native-build directory using the following command:

    kinesis_video_gstreamer_sample_rtsp_app.exe RTSP-camera-URL my-test-rtsp-stream

Building and Running the Producer SDK: Microsoft Visual C++ Compiler (MSVC)

The Microsoft Visual C++ Compiler (MSVC) is the compiler for Microsoft Visual Studio. The following sections include the prerequisites and steps that are required to build the Kinesis Video Streams Producer SDK using MSVC.

Prerequisites

Before you start, ensure that you have the following:

  • Microsoft Windows version 7 or later.

  • Microsoft .NET Framework version 4.6.1 or later.

  • Windows PowerShell version 5.1 (included in Windows 10). On Windows 7, update Windows PowerShell.

  • Git. In the Adjusting your PATH environment installation step, choose Use Git from the Windows Command Prompt.

Building the Producer SDK Using MSVC

Follow these steps to use MSVC to compile the Producer SDK on Windows.

Note

If you previously installed the Producer SDK for Windows using MinGW, do the following cleanup steps before building the SDK using MSVC:

  • Delete the files in the kinesis-video-native-build/downloads directory.

  • Remove the CMakeFiles directory and the CMakeCachedList.txt file in the kinesis-video-native-build directory.

  1. Open a Windows command prompt as an administrator.

  2. Download the Producer SDK:

    git clone https://github.com/awslabs/amazon-kinesis-video-streams-producer-sdk-cpp.git
  3. After the download is complete, change to the kinesis-video-native-build directory within the downloaded project.

  4. Run the Visual Studio build tools install script:

    vs-buildtools-install.bat
  5. After the install script completes, if you are using Windows 10 or Windows 7, reboot your computer. Then re-open a Windows command prompt as an administrator.

  6. In the kinesis-video-native-build directory, run windows-install.bat, specifying your system's bit width (32 or 64):

    windows-install.bat 32 or windows-install.bat 64

    Note

    This script builds the following components:

    • The C++ Producer Library libraries.

    • The C++ Producer SDK GStreamer (kvssink).

    • The demo, which shows how to stream data from an RTSP (network) camera.

Running the Producer SDK to Send Video to Kinesis Video Streams

After compiling the Kinesis Video Streams Producer SDK using MSVC, follow these steps to run it as a GStreamer plugin.

You have several options for starting the SDK. We recommend that you use the GStreamer, which you can run using the example executables available in the kinesis-video-native-build/start directory.

  1. Add the following directories to your path (specify the location for the Producer SDK, including the drive):

    set PATH=%PATH%;install directory\amazon-kinesis-video-streams-producer-sdk-cpp\kinesis-video-native-build\downloads\gstreamer\1.0\x86_64\bin;
  2. Set the following environment variables (replace install directory with the location for the Producer SDK, including the drive):

    set GST_PLUGIN_PATH=install directory\amazon-kinesis-video-streams-producer-sdk-cpp\kinesis-video-native-build\Release set GST_PLUGIN_SYSTEM_PATH=install directory\amazon-kinesis-video-streams-producer-sdk-cpp\kinesis-video-native-build\downloads\gstreamer\1.0\x86_64\lib\gstreamer-1.0
  3. Stream video from the webcam on the PC to the Kinesis Video Streams service using the gst-launch-1.0 command:

    gst-launch-1.0 ksvideosrc do-timestamp=TRUE ! video/x-raw,width=640,height=480,framerate=30/1 ! videoconvert ! x264enc bframes=0 key-int-max=45 bitrate=512 ! video/x-h264,profile=baseline,stream-format=avc,alignment=au,width=640,height=480,framerate=30/1 ! kvssink stream-name="your-stream-name" access-key=your_accesskey_id secret-key=your_secret_access_key

    For information about how to determine the parameters for the gst-launch-1.0 command, see GStreamer Element Parameter Reference.

    Note

    If you are using IoT credentials instead of your access key and secret key, you can supply them as parameters to the gst-launch-1.0 command. The following example demonstrates using IoT parameters to stream video from an RTSP camera:

    gst-launch-1.0 rtspsrc location=rtsp://YourCameraRtspUrl short-header=TRUE ! rtph264depay ! video/x-h264, format=avc,alignment=au ! kvssink stream-name="your-iot-stream" iot-certificate="iot-certificate,endpoint=endpoint,cert-path=/path/to/certificate,key-path=/path/to/private/key,ca-path=/path/to/ca-cert,role-aliases=role-aliases"
  4. Alternatively, you can set the following environment variables and use one of our pre-build sample applications.

    export AWS_ACCESS_KEY_ID=YOUR_ACCESS_KEY export AWS_SECRET_ACCESS_KEY=YOUR_SECRET_ACCESS_KEY
  5. To stream video from a PC webcam, run the sample application from the kinesis-video-native-build\Release directory using the following command:

    kinesis_video_gstreamer_sample_app.exe my-stream-name
  6. To stream video from an RTSP (network) camera, run the sample application from the kinesis-video-native-build\Release directory using the following command:

    kinesis_video_gstreamer_sample_rtsp_app.exe RTSP-camera-URL my-test-rtsp-stream