Skip to content

Commit 8cbb9fa

Browse files
committed
Release note for v1.4.2
Revised logging & Producer SDK (CPP) as a GStreamer plugin element (sink) and log support Bug fixes
1 parent 79ed881 commit 8cbb9fa

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+4099
-268
lines changed

README.md

+232-75
Large diffs are not rendered by default.

docker_native_scripts/Dockerfile

+2-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ RUN git clone https://github.com/awslabs/amazon-kinesis-video-streams-producer-s
3030

3131
WORKDIR /opt/amazon-kinesis-video-streams-producer-sdk-cpp/kinesis-video-native-build/
3232
RUN chmod a+x ./install-script
33-
RUN ./install-script a
33+
RUN ./install-script a
34+
RUN ./java-install-script
3435
COPY start_rtsp_in_docker.sh /opt/amazon-kinesis-video-streams-producer-sdk-cpp/kinesis-video-native-build/
3536
RUN chmod a+x ./start_rtsp_in_docker.sh
3637

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# Build docker with
2+
# docker build -t kvs-sdk-amazonlinux.
3+
#
4+
FROM amazonlinux
5+
RUN yum update -y && \
6+
yum upgrade -y && \
7+
yum install -y autoconf && \
8+
yum install -y automake && \
9+
yum install -y bison && \
10+
yum install -y bzip2 && \
11+
yum install -y cmake && \
12+
yum install -y curl && \
13+
yum install -y diffutils && \
14+
yum install -y flex && \
15+
yum install -y gcc-c++ && \
16+
yum install -y git && \
17+
yum install -y gmp-devel && \
18+
yum install -y libffi && \
19+
yum install -y libffi-devel && \
20+
yum install -y libmpc-devel && \
21+
yum install -y libtool && \
22+
yum install -y m4 && \
23+
yum install -y mpfr-devel && \
24+
yum install -y pkgconfig && \
25+
yum install -y vim && \
26+
yum install -y wget
27+
28+
29+
RUN wget https://cmake.org/files/v3.2/cmake-3.2.3-Linux-x86_64.tar.gz
30+
RUN tar -zxvf cmake-3.2.3-Linux-x86_64.tar.gz
31+
ENV PATH=/cmake-3.2.3-Linux-x86_64/bin/:$PATH
32+
RUN wget https://ftp.gnu.org/gnu/gcc/gcc-7.2.0/gcc-7.2.0.tar.gz
33+
RUN tar -xvf gcc-7.2.0.tar.gz
34+
WORKDIR gcc-7.2.0
35+
RUN ./configure --disable-multilib --enable-languages=c,c++
36+
WORKDIR /gcc-7.2.0
37+
RUN pwd
38+
RUN make
39+
RUN make install
40+
RUN /usr/local/bin/gcc "--version"
41+
WORKDIR /opt/
42+
43+
RUN git clone https://github.com/awslabs/amazon-kinesis-video-streams-producer-sdk-cpp.git
44+
45+
WORKDIR /opt/amazon-kinesis-video-streams-producer-sdk-cpp/kinesis-video-native-build/
46+
COPY install-script /opt/amazon-kinesis-video-streams-producer-sdk-cpp/kinesis-video-native-build/
47+
48+
ENV CC=/usr/local/bin/gcc
49+
ENV CXX=/usr/local/bin/g++
50+
RUN chmod a+x ./install-script
51+
RUN chmod a+x ./gstreamer-plugin-install-script
52+
# ================= HTTPS Certificate =====================================================================
53+
RUN wget https://www.amazontrust.com/repository/SFSRootCAG2.pem
54+
RUN cp SFSRootCAG2.pem /opt/amazon-kinesis-video-streams-producer-sdk-cpp
55+
# ================ Build producer sdk and gstreamer plugin ================================================
56+
#
57+
RUN ./install-script -a
58+
RUN cp libproducer.so /opt/amazon-kinesis-video-streams-producer-sdk-cpp/kinesis-video-native-build/downloads/local/lib/
59+
ENV KINESIS_VIDEO_STREAMS_PRODUCER_SDK_SOURCE_DIR=/opt/amazon-kinesis-video-streams-producer-sdk-cpp/
60+
ENV SDK_SOURCE_DIR=/opt/amazon-kinesis-video-streams-producer-sdk-cpp/
61+
RUN pwd
62+
RUN ./gstreamer-plugin-install-script
63+
64+
#
65+
# Copy dynamic libraries into lib folder
66+
RUN cp /opt/amazon-kinesis-video-streams-producer-sdk-cpp/kinesis-video-gstreamer-plugin/libgstkvssink.so /opt/amazon-kinesis-video-streams-producer-sdk-cpp/kinesis-video-native-build/downloads/local/lib/
67+
RUN cp /opt/amazon-kinesis-video-streams-producer-sdk-cpp/kinesis-video-native-build/libproducer.so /opt/amazon-kinesis-video-streams-producer-sdk-cpp/kinesis-video-native-build/downloads/local/lib/
68+
# Copy all demo sample application binaries kinesis-video-native-build
69+
RUN cp /opt/amazon-kinesis-video-streams-producer-sdk-cpp/kinesis-video-gstreamer-plugin/kvs_producer_plugin* /opt/amazon-kinesis-video-streams-producer-sdk-cpp/kinesis-video-native-build/
70+
# Copy gst-launch-1.0 and gst-inspect-1.0 kinesis-video-native-build
71+
RUN cp /opt/amazon-kinesis-video-streams-producer-sdk-cpp/kinesis-video-native-build/downloads/local/bin/gst* /opt/amazon-kinesis-video-streams-producer-sdk-cpp/kinesis-video-native-build/
72+
73+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# Using Docker images for Producer SDK (CPP and GStreamer plugin):
2+
3+
Please follow the four steps below to get the Docker image for Producer SDK (includes CPP and GStreamer plugin) and start streaming to Kinesis Video.
4+
5+
#### Pre-requisite:
6+
7+
This requires docker is installed in your system.
8+
9+
Follow instructions to download and start Docker
10+
11+
* [Docker download instructions](https://www.docker.com/community-edition#/download)
12+
* [Getting started with Docker](https://docs.docker.com/get-started/)
13+
14+
15+
Once you have docker installed, you can download the Kinesis Video Producer SDK (CPP and GStreamer plugin) from Amazon ECR (Elastic Container Service) using `docker pull` command.
16+
17+
18+
#### Step 1:
19+
20+
Authenticate your Docker client to the Amazon ECR registry that you intend to pull your image from. Authentication tokens must be obtained for each registry used, and the tokens are valid for 12 hours. For more information, see Registry Authentication.
21+
22+
Example:
23+
24+
You can authenticate to Amazon ECR using the following two commands:
25+
26+
1. `aws ecr get-login --no-include-email --region us-west-2`
27+
28+
you will see an **output** similar to the one below.
29+
30+
2. `docker login -u AWS -p <Password> https://PublicAccountIdForDockerAccess.dkr.ecr.us-west-2.amazonaws.com`
31+
32+
Run the command as such in your command prompt. This will authorize the `docker pull` which you will be running next.
33+
34+
35+
#### Step 2: Pull Image
36+
37+
##### 2.1 Steps for getting the Docker images built with AmazonLinux
38+
39+
Run the following command to get the AmazonLinux Docker image to your local environment.
40+
41+
`sudo docker pull PublicAccountIdForDockerAccess.dkr.ecr.us-west-2.amazonaws.com/kinesis-video-producer-cpp-amazonlinux`
42+
43+
you can verify the images in your local docker environment by running `docker images`.
44+
45+
46+
#### Step 3: Run the Docker Image (start the container)
47+
48+
Run the following command to start the kinesis video sdk container
49+
50+
`sudo docker run -it --network="host" --device=/dev/video0 --device=/dev/video1 PublicAccountIdForDockerAccess.dkr.ecr.us-west-2.amazonaws.com/kinesis-video-producer-cpp-amazonlinux /bin/bash`
51+
52+
53+
#### Step 4: Run the GStreamer plugin
54+
55+
Follow the next few steps to start Producer SDK GStreamer plugin element for sending video streams from webcamera to Kinesis Video:
56+
57+
##### 4.1 Set these environment variable:
58+
59+
`export LD_LIBRARY_PATH=/opt/awssdk/amazon-kinesis-video-streams-producer-sdk-cpp/kinesis-video-native-build/downloads/local/lib:$LD_LIBRARY_PATH`
60+
61+
`export PATH=/opt/awssdk/amazon-kinesis-video-streams-producer-sdk-cpp/kinesis-video-native-build/downloads/local/bin:$PATH`
62+
63+
`export GST_PLUGIN_PATH=/opt/awssdk/amazon-kinesis-video-streams-producer-sdk-cpp/kinesis-video-native-build/downloads/local/lib:$GST_PLUGIN_PATH`
64+
65+
66+
##### 4.2 Start the streaming with `gst-launch-1.0` command.
67+
68+
`gst-launch-1.0 v4l2src do-timestamp=TRUE device=/dev/video0 ! videoconvert ! video/x-raw,format=I420,width=640,height=480,framerate=30/1 ! x264enc bframes=0 key-int-max=45 bitrate=512 ! h264parse ! video/x-h264,stream-format=avc,alignment=au,width=640,height=480,framerate=30/1 ! kvssink stream-name="YOURSTREAMNAME" access-key="YOURACCESSKEY" secret-key="YOURSECRETKEY"`
69+
70+
For additional examples refer [Readme](https://github.com/awslabs/amazon-kinesis-video-streams-producer-sdk-cpp/blob/master/README.md) in https://github.com/awslabs/amazon-kinesis-video-streams-producer-sdk-cpp.
71+
72+
73+
74+

kinesis-video-gst-demo/kinesis_video_gstreamer_sample_app.cpp

+50-38
Original file line numberDiff line numberDiff line change
@@ -217,20 +217,30 @@ static GstFlowReturn on_new_sample(GstElement *sink, CustomData *data) {
217217
return GST_FLOW_OK;
218218
}
219219

220-
static bool format_supported_by_source(GstCaps *src_caps, bool h264_stream, int width, int height, int framerate) {
221-
GstCaps *query_caps;
222-
query_caps = gst_caps_new_simple(h264_stream ? "video/x-h264" : "video/x-raw",
223-
"width", G_TYPE_INT, width,
224-
"height", G_TYPE_INT, height,
225-
"framerate", GST_TYPE_FRACTION_RANGE, framerate, 1, framerate + 1, 1,
226-
NULL);
227-
return gst_caps_can_intersect(query_caps, src_caps);
220+
static bool format_supported_by_source(GstCaps *src_caps, GstCaps *query_caps, int width, int height, int framerate) {
221+
gst_caps_set_simple(query_caps,
222+
"width", G_TYPE_INT, width,
223+
"height", G_TYPE_INT, height,
224+
"framerate", GST_TYPE_FRACTION, framerate, 1,
225+
NULL);
226+
bool is_match = gst_caps_can_intersect(query_caps, src_caps);
227+
228+
// in case the camera has fps as 10000000/333333
229+
if(!is_match) {
230+
gst_caps_set_simple(query_caps,
231+
"framerate", GST_TYPE_FRACTION_RANGE, framerate, 1, framerate+1, 1,
232+
NULL);
233+
is_match = gst_caps_can_intersect(query_caps, src_caps);
234+
}
235+
236+
return is_match;
228237
}
229238

230-
static bool resolution_supported(GstCaps *src_caps, CustomData &data, int width, int height, int framerate) {
231-
if (format_supported_by_source(src_caps, true, width, height, framerate)) {
239+
static bool resolution_supported(GstCaps *src_caps, GstCaps *query_caps_raw, GstCaps *query_caps_h264,
240+
CustomData &data, int width, int height, int framerate) {
241+
if (query_caps_h264 && format_supported_by_source(src_caps, query_caps_h264, width, height, framerate)) {
232242
data.h264_stream_supported = true;
233-
} else if (format_supported_by_source(src_caps, false, width, height, framerate)) {
243+
} else if (query_caps_raw && format_supported_by_source(src_caps, query_caps_raw, width, height, framerate)) {
234244
data.h264_stream_supported = false;
235245
} else {
236246
return false;
@@ -334,8 +344,7 @@ void kinesis_video_init(CustomData *data, char *stream_name) {
334344
}
335345

336346
int gstreamer_init(int argc, char* argv[]) {
337-
BasicConfigurator config;
338-
config.configure();
347+
PropertyConfigurator::doConfigure("kvs_log_configuration");
339348

340349
if (argc < 2) {
341350
LOG_ERROR(
@@ -454,19 +463,28 @@ int gstreamer_init(int argc, char* argv[]) {
454463
GstCaps *src_caps = gst_pad_query_caps(srcpad, NULL);
455464
gst_element_set_state(data.source, GST_STATE_NULL);
456465

466+
GstCaps *query_caps_raw = gst_caps_new_simple("video/x-raw",
467+
"width", G_TYPE_INT, width,
468+
"height", G_TYPE_INT, height,
469+
NULL);
470+
GstCaps *query_caps_h264 = gst_caps_new_simple("video/x-h264",
471+
"width", G_TYPE_INT, width,
472+
"height", G_TYPE_INT, height,
473+
NULL);
474+
457475
if (width != 0 && height != 0) {
458-
if (!resolution_supported(src_caps, data, width, height, framerate)) {
476+
if (!resolution_supported(src_caps, query_caps_raw, query_caps_h264, data, width, height, framerate)) {
459477
g_printerr("Resolution %dx%d not supported by video source\n", width, height);
460478
return 1;
461479
}
462480
} else {
463-
vector<int> res_width = {1920, 1280, 640};
464-
vector<int> res_height = {1080, 720, 480};
481+
vector<int> res_width = {640, 1280, 1920};
482+
vector<int> res_height = {480, 720, 1080};
465483
bool found_resolution = false;
466484
for (int i = 0; i < res_width.size(); i++) {
467485
width = res_width[i];
468486
height = res_height[i];
469-
if (resolution_supported(src_caps, data, width, height, framerate)) {
487+
if (resolution_supported(src_caps, query_caps_raw, query_caps_h264, data, width, height, framerate)) {
470488
found_resolution = true;
471489
break;
472490
}
@@ -491,32 +509,29 @@ int gstreamer_init(int argc, char* argv[]) {
491509
}
492510

493511
/* source filter */
494-
GstCaps *source_caps;
495512
if (!data.h264_stream_supported) {
496-
source_caps = gst_caps_new_simple("video/x-raw",
497-
"format", G_TYPE_STRING, "I420",
498-
"width", G_TYPE_INT, width,
499-
"height", G_TYPE_INT, height,
500-
"framerate", GST_TYPE_FRACTION_RANGE, framerate, 1, framerate + 1, 1,
501-
NULL);
513+
gst_caps_set_simple(query_caps_raw,
514+
"format", G_TYPE_STRING, "I420",
515+
NULL);
516+
g_object_set(G_OBJECT (data.source_filter), "caps", query_caps_raw, NULL);
502517
} else {
503-
source_caps = gst_caps_new_simple("video/x-h264",
504-
"stream-format", G_TYPE_STRING, "byte-stream",
505-
"alignment", G_TYPE_STRING, "au",
506-
NULL);
518+
gst_caps_set_simple(query_caps_h264,
519+
"stream-format", G_TYPE_STRING, "byte-stream",
520+
"alignment", G_TYPE_STRING, "au",
521+
NULL);
522+
g_object_set(G_OBJECT (data.source_filter), "caps", query_caps_h264, NULL);
507523
}
508-
509-
g_object_set(G_OBJECT (data.source_filter), "caps", source_caps, NULL);
510-
gst_caps_unref(source_caps);
524+
gst_caps_unref(query_caps_h264);
525+
gst_caps_unref(query_caps_raw);
511526

512527
/* configure encoder */
513528
if (!data.h264_stream_supported){
514529
if (vtenc) {
515530
g_object_set(G_OBJECT (data.encoder), "allow-frame-reordering", FALSE, "realtime", TRUE, "max-keyframe-interval",
516531
45, "bitrate", bitrateInKBPS, NULL);
517532
} else if (isOnRpi) {
518-
g_object_set(G_OBJECT (data.encoder), "control-rate", 1, "target-bitrate", bitrateInKBPS*10000,
519-
"periodicity-idr", 45, "inline-header", FALSE, NULL);
533+
g_object_set(G_OBJECT (data.encoder), "control-rate", 2, "target-bitrate", bitrateInKBPS*1000,
534+
"periodicty-idr", 45, "inline-header", FALSE, NULL);
520535
} else {
521536
g_object_set(G_OBJECT (data.encoder), "bframes", 0, "key-int-max", 45, "bitrate", bitrateInKBPS, NULL);
522537
}
@@ -527,9 +542,6 @@ int gstreamer_init(int argc, char* argv[]) {
527542
GstCaps *h264_caps = gst_caps_new_simple("video/x-h264",
528543
"stream-format", G_TYPE_STRING, "avc",
529544
"alignment", G_TYPE_STRING, "au",
530-
"width", G_TYPE_INT, width,
531-
"height", G_TYPE_INT, height,
532-
"framerate", GST_TYPE_FRACTION_RANGE, framerate, 1, framerate + 1, 1,
533545
NULL);
534546
if (!data.h264_stream_supported) {
535547
gst_caps_set_simple(h264_caps, "profile", G_TYPE_STRING, "baseline",
@@ -552,8 +564,8 @@ int gstreamer_init(int argc, char* argv[]) {
552564
return 1;
553565
}
554566
} else {
555-
gst_bin_add_many(GST_BIN (data.pipeline), data.source, data.h264parse, data.filter, data.appsink, NULL);
556-
if (gst_element_link_many(data.source, data.h264parse, data.filter, data.appsink, NULL) != TRUE) {
567+
gst_bin_add_many(GST_BIN (data.pipeline), data.source, data.source_filter, data.h264parse, data.filter, data.appsink, NULL);
568+
if (gst_element_link_many(data.source, data.source_filter, data.h264parse, data.filter, data.appsink, NULL) != TRUE) {
557569
g_printerr("Elements could not be linked.\n");
558570
gst_object_unref(data.pipeline);
559571
return 1;

kinesis-video-gst-demo/kinesis_video_gstreamer_sample_rtsp_app.cpp

+3-4
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ static GstFlowReturn on_new_sample(GstElement *sink, CustomData *data) {
196196

197197
bool delta = GST_BUFFER_FLAG_IS_SET(buffer, GST_BUFFER_FLAG_DELTA_UNIT);
198198
FRAME_FLAGS kinesis_video_flags;
199-
199+
200200
if (GST_BUFFER_PTS_IS_VALID(buffer)) {
201201
buffer->dts = buffer->pts;
202202
}
@@ -330,8 +330,7 @@ static void cb_rtsp_pad_created(GstElement *element, GstPad *pad, CustomData *da
330330
}
331331

332332
int gstreamer_init(int argc, char *argv[]) {
333-
BasicConfigurator config;
334-
config.configure();
333+
PropertyConfigurator::doConfigure("kvs_log_configuration");
335334

336335
if (argc < 3) {
337336
LOG_ERROR(
@@ -365,7 +364,7 @@ int gstreamer_init(int argc, char *argv[]) {
365364

366365
// RTSP source component
367366
data.source = gst_element_factory_make("rtspsrc", "source");
368-
367+
369368
data.filter = gst_element_factory_make("capsfilter", "encoder_filter");
370369

371370
GstCaps *h264_caps = gst_caps_new_simple("video/x-h264",

0 commit comments

Comments
 (0)