コンテンツへスキップ

Raspberry Pi から Amazon Kinesis Video Streams へ映像アップロード

Amazon Kinesis Video Streamsを使ってストリーム映像をAWS上に流してみる【Raspberry Pi】– ClassmethodサーバーレスAdvent Calendar 2017」にならって、ラズパイにKinesis Video Streamsを設定してみます。

Amazon Kinesis Video Streamsの作成」で、AWS上でKinesis Video Streamsの作成まではできたのでその続きからになります。

AWS側の設定

記事によるとAWSのポリシーに「kinesisvideo:TagStream」が追加で必要とのことなので、AWSのマネジメントコンソール上でポリシーをJSONで開き、「kinesisvideo:TagStream」を追加します。

ラズパイ側の設定

デバイスの設定

AN INTRODUCTION TO KINESIS VIDEO STREAMS」によると、「/etc/modules」に 「bcm2835-v4l2」を1行追加するとのこと。

35.
The following steps are required to configure the device, and install pre-requisite software
a.Ensurethe camera driver is loaded when the Raspberry Pi is booted:
i. Open an editor to update the modules file with the following command:
$ sudo nano /etc/modules
ii. If it doesn’t already exist in the file, add a single line to the end of the file with
the following text:
bcm2835-v4l2
iii. Save the file and exit the editor (Ctrl-X).
iv. Reboot the Raspberry Pi:
$ sudo reboot

一方で、「Amazon Kinesis Video Streamsを使ってストリーム映像をAWS上に流してみる【Raspberry Pi】– ClassmethodサーバーレスAdvent Calendar 2017」では、

$ vcgencmd get_camera
$ sudo modprobe bcm2835-v4l2

というようにコマンドになっています。

今回はコマンドの方でやってみて、/etc/modules にも反映されるかを確認してみます。

  • コマンド実行前
mypi@raspberrypi:~ $ cat /etc/modules
# /etc/modules: kernel modules to load at boot time.
#
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with "#" are ignored.

i2c-dev
mypi@raspberrypi:~ $ ls /dev/video*
ls: '/dev/video*' にアクセスできません: そのようなファイルやディレクトリはありません
  • vcgencmd get_camera 実行
mypi@raspberrypi:~ $ vcgencmd get_camera
supported=1 detected=1
  • vcgencmd get_camera 実行後
mypi@raspberrypi:~ $ cat /etc/modules
# /etc/modules: kernel modules to load at boot time.
#
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with "#" are ignored.

i2c-dev
mypi@raspberrypi:~ $ ls /dev/video*
ls: '/dev/video*' にアクセスできません: そのようなファイルやディレクトリはありません

まだ変化はありません。

  • sudo modprobe bcm2835-v4l2 実行
mypi@raspberrypi:~ $ sudo modprobe bcm2835-v4l2
  • sudo modprobe bcm2835-v4l2 実行後
mypi@raspberrypi:~ $ cat /etc/modules
# /etc/modules: kernel modules to load at boot time.
#
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with "#" are ignored.

i2c-dev
mypi@raspberrypi:~ $ ls /dev/video*
/dev/video0

/etc/modules には「bcm2835-v4l2」の行が追加されないままですが、/dev/video0 が生成されています。

関連パッケージのインストール

AN INTRODUCTION TO KINESIS VIDEO STREAMS」のNo.36~39を実行します。

mypi@raspberrypi:~ $ sudo apt-get install git
パッケージリストを読み込んでいます... 完了
依存関係ツリーを作成しています
状態情報を読み取っています... 完了
git はすでに最新バージョン (1:2.11.0-3+deb9u2) です。
アップグレード: 0 個、新規インストール: 0 個、削除: 0 個、保留: 1 個。
mypi@raspberrypi:~ $ sudo apt-get install oracle-java8-jdk
パッケージリストを読み込んでいます... 完了
依存関係ツリーを作成しています
状態情報を読み取っています... 完了
oracle-java8-jdk はすでに最新バージョン (8u65) です。
アップグレード: 0 個、新規インストール: 0 個、削除: 0 個、保留: 1 個。
mypi@raspberrypi:~ $ ls /usr/lib/jvm/jdk-8-oracle-arm32-vfp-hflt/
COPYRIGHT LICENSE README.html THIRDPARTYLICENSEREADME.txt bin db debian include jre lib man release src.zip
mypi@raspberrypi:~ $ env | grep JAVA_HOME
mypi@raspberrypi:~ $ export JAVA_HOME=/usr/lib/jvm/jdk-8-oracle-arm32-vfp-hflt/
mypi@raspberrypi:~ $ env | grep JAVA_HOME
JAVA_HOME=/usr/lib/jvm/jdk-8-oracle-arm32-vfp-hflt/
mypi@raspberrypi:~ $ sudo apt-get install cmake
パッケージリストを読み込んでいます... 完了
依存関係ツリーを作成しています
状態情報を読み取っています... 完了
以下の追加パッケージがインストールされます:
cmake-data libjsoncpp1
提案パッケージ:
codeblocks eclipse ninja-build
以下のパッケージが新たにインストールされます:
cmake cmake-data libjsoncpp1
アップグレード: 0 個、新規インストール: 3 個、削除: 0 個、保留: 1 個。
3,685 kB のアーカイブを取得する必要があります。
この操作後に追加で 19.0 MB のディスク容量が消費されます。
続行しますか? [Y/n] Y
取得:1 http://mirrordirector.raspbian.org/raspbian stretch/main armhf cmake-data all 3.7.2-1 [1,216 kB]
取得:2 http://mirrordirector.raspbian.org/raspbian stretch/main armhf libjsoncpp1 armhf 1.7.4-3 [66.2 kB]
取得:3 http://mirrordirector.raspbian.org/raspbian stretch/main armhf cmake armhf 3.7.2-1 [2,402 kB]
3,685 kB を 10秒 で取得しました (367 kB/s)
以前に未選択のパッケージ cmake-data を選択しています。
(データベースを読み込んでいます ... 現在 124382 個のファイルとディレクトリがインストールされています。)
.../cmake-data_3.7.2-1_all.deb を展開する準備をしています ...
cmake-data (3.7.2-1) を展開しています...
以前に未選択のパッケージ libjsoncpp1:armhf を選択しています。
.../libjsoncpp1_1.7.4-3_armhf.deb を展開する準備をしています ...
libjsoncpp1:armhf (1.7.4-3) を展開しています...
以前に未選択のパッケージ cmake を選択しています。
.../cmake_3.7.2-1_armhf.deb を展開する準備をしています ...
cmake (3.7.2-1) を展開しています...
cmake-data (3.7.2-1) を設定しています ...
libc-bin (2.24-11+deb9u1) のトリガを処理しています ...
man-db (2.7.6.1-2) のトリガを処理しています ...
libjsoncpp1:armhf (1.7.4-3) を設定しています ...
cmake (3.7.2-1) を設定しています ...
libc-bin (2.24-11+deb9u1) のトリガを処理しています ...

更に追加で、後ほどインストールスクリプトを実行すると分かるのですが、他にもインストールが必要なパッケージがあるようです。

mypi@raspberrypi:~/amazon-kinesis-video-streams-producer-sdk-cpp $ ./kinesis-video-native-build/install-script
Starting to build the Kinesis Video Stream Demo Application
- will be using the following open source libraries and tools
openssl
curl
log4cplus
gettext
libffi
libpcre
zlib
iconv
googletest
bison
flex
libtools
autoconf
automake
m4
also the gstreamer, gstreamer plugins, yasm, gst-libav and x264.
Note - for MacOS High Sierra: Use
brew install autoconf
brew install bison

めんどうなのでとりあえず全部まとめてapt-getします。

mypi@raspberrypi:~/amazon-kinesis-video-streams-producer-sdk-cpp $ sudo apt-get install openssl curl log4cplus gettext libffi libpcre zlib iconv googletext bison flex libtools autoconf automake m4
パッケージリストを読み込んでいます... 完了
依存関係ツリーを作成しています
状態情報を読み取っています... 完了
パッケージ iconv は使用できませんが、別のパッケージから参照されます。
これは、パッケージが欠落しているか、廃止されたか、または別のソース
からのみ利用可能であることを意味します。

E: パッケージ log4cplus が見つかりません
E: パッケージ libffi が見つかりません
E: パッケージ libpcre が見つかりません
E: パッケージ zlib が見つかりません
E: パッケージ 'iconv' にはインストール候補がありません
E: パッケージ googletext が見つかりません
E: パッケージ libtools が見つかりません
mypi@raspberrypi:~/amazon-kinesis-video-streams-producer-sdk-cpp $ sudo apt-get install openssl curl gettext bison flex autoconf automake m4
パッケージリストを読み込んでいます... 完了
依存関係ツリーを作成しています
状態情報を読み取っています... 完了
curl はすでに最新バージョン (7.52.1-5+deb9u4) です。
gettext はすでに最新バージョン (0.19.8.1-2) です。
openssl はすでに最新バージョン (1.1.0f-3+deb9u1) です。
以下の追加パッケージがインストールされます:
autotools-dev libbison-dev libfl-dev libsigsegv2
提案パッケージ:
autoconf-archive gnu-standards autoconf-doc libtool bison-doc m4-doc
以下のパッケージが新たにインストールされます:
autoconf automake autotools-dev bison flex libbison-dev libfl-dev libsigsegv2 m4
アップグレード: 0 個、新規インストール: 9 個、削除: 0 個、保留: 1 個。
3,041 kB のアーカイブを取得する必要があります。
この操作後に追加で 7,864 kB のディスク容量が消費されます。
続行しますか? [Y/n] Y
取得:1 http://mirrordirector.raspbian.org/raspbian stretch/main armhf libsigsegv2 armhf 2.10-5 [28.4 kB]
取得:2 http://mirrordirector.raspbian.org/raspbian stretch/main armhf m4 armhf 1.4.18-1 [185 kB]
取得:3 http://mirrordirector.raspbian.org/raspbian stretch/main armhf flex armhf 2.6.1-1.3 [414 kB]
取得:4 http://mirrordirector.raspbian.org/raspbian stretch/main armhf autoconf all 2.69-10 [338 kB]
取得:5 http://mirrordirector.raspbian.org/raspbian stretch/main armhf autotools-dev all 20161112.1 [73.4 kB]
取得:6 http://mirrordirector.raspbian.org/raspbian stretch/main armhf automake all 1:1.15-6 [733 kB]
取得:7 http://mirrordirector.raspbian.org/raspbian stretch/main armhf libbison-dev armhf 2:3.0.4.dfsg-1 [433 kB]
取得:8 http://mirrordirector.raspbian.org/raspbian stretch/main armhf bison armhf 2:3.0.4.dfsg-1 [744 kB]
取得:9 http://mirrordirector.raspbian.org/raspbian stretch/main armhf libfl-dev armhf 2.6.1-1.3 [93.0 kB]
3,041 kB を 19秒 で取得しました (154 kB/s)
以前に未選択のパッケージ libsigsegv2:armhf を選択しています。
(データベースを読み込んでいます ... 現在 126815 個のファイルとディレクトリがインストールされています。)
.../0-libsigsegv2_2.10-5_armhf.deb を展開する準備をしています ...
libsigsegv2:armhf (2.10-5) を展開しています...
以前に未選択のパッケージ m4 を選択しています。
.../1-m4_1.4.18-1_armhf.deb を展開する準備をしています ...
m4 (1.4.18-1) を展開しています...
以前に未選択のパッケージ flex を選択しています。
.../2-flex_2.6.1-1.3_armhf.deb を展開する準備をしています ...
flex (2.6.1-1.3) を展開しています...
以前に未選択のパッケージ autoconf を選択しています。
.../3-autoconf_2.69-10_all.deb を展開する準備をしています ...
autoconf (2.69-10) を展開しています...
以前に未選択のパッケージ autotools-dev を選択しています。
.../4-autotools-dev_20161112.1_all.deb を展開する準備をしています ...
autotools-dev (20161112.1) を展開しています...
以前に未選択のパッケージ automake を選択しています。
.../5-automake_1%3a1.15-6_all.deb を展開する準備をしています ...
automake (1:1.15-6) を展開しています...
以前に未選択のパッケージ libbison-dev:armhf を選択しています。
.../6-libbison-dev_2%3a3.0.4.dfsg-1_armhf.deb を展開する準備をしています ...
libbison-dev:armhf (2:3.0.4.dfsg-1) を展開しています...
以前に未選択のパッケージ bison を選択しています。
.../7-bison_2%3a3.0.4.dfsg-1_armhf.deb を展開する準備をしています ...
bison (2:3.0.4.dfsg-1) を展開しています...
以前に未選択のパッケージ libfl-dev:armhf を選択しています。
.../8-libfl-dev_2.6.1-1.3_armhf.deb を展開する準備をしています ...
libfl-dev:armhf (2.6.1-1.3) を展開しています...
libsigsegv2:armhf (2.10-5) を設定しています ...
install-info (6.3.0.dfsg.1-1+b1) のトリガを処理しています ...
m4 (1.4.18-1) を設定しています ...
libc-bin (2.24-11+deb9u1) のトリガを処理しています ...
autotools-dev (20161112.1) を設定しています ...
libbison-dev:armhf (2:3.0.4.dfsg-1) を設定しています ...
man-db (2.7.6.1-2) のトリガを処理しています ...
bison (2:3.0.4.dfsg-1) を設定しています ...
update-alternatives: /usr/bin/yacc (yacc) を提供するために自動モードで /usr/bin/bison.yacc を使います
flex (2.6.1-1.3) を設定しています ...
autoconf (2.69-10) を設定しています ...
libfl-dev:armhf (2.6.1-1.3) を設定しています ...
automake (1:1.15-6) を設定しています ...
update-alternatives: /usr/bin/automake (automake) を提供するために自動モードで /usr/bin/automake-1.15 を使います
libc-bin (2.24-11+deb9u1) のトリガを処理しています ...

Kinesis Video Streams SDK のビルド準備

AN INTRODUCTION TO KINESIS VIDEO STREAMS」のNo.40 a~bを実行します。

mypi@raspberrypi:~ $ git clone https://github.com/awslabs/amazon-kinesis-video-streams-producer-sdk-cpp.git
Cloning into 'amazon-kinesis-video-streams-producer-sdk-cpp'...
remote: Counting objects: 689, done.
remote: Compressing objects: 100% (15/15), done.
remote: Total 689 (delta 9), reused 14 (delta 6), pack-reused 668
Receiving objects: 100% (689/689), 580.57 KiB | 431.00 KiB/s, done.
Resolving deltas: 100% (255/255), done.
mypi@raspberrypi:~ $ cd amazon-kinesis-video-streams-producer-sdk-cpp/
mypi@raspberrypi:~/amazon-kinesis-video-streams-producer-sdk-cpp $ chmod +x ./kinesis-video-native-build/install-script

ヘッダファイルを一部修正

このままだと./startを実行してテストが走った時に1GiB以上メモリを確保しようとして、512MiBしかない Raspberry Pi 3 Model B だとSegmentation faultを起こしてしまいます(中略)確保するメモリを以下のファイルを編集し256MiBにします

Amazon Kinesis Video Streamsを使ってストリーム映像をAWS上に流してみる【Raspberry Pi】– ClassmethodサーバーレスAdvent Calendar 2017 #serverless #adventcalendar #reinvent

とのことなので、記事のとおり修正します。

mypi@raspberrypi:~/amazon-kinesis-video-streams-producer-sdk-cpp $ cp -p ./kinesis-video-producer/tst/ProducerTestFixture.h ./kinesis-video-producer/tst/ProducerTestFixture.h.org
mypi@raspberrypi:~/amazon-kinesis-video-streams-producer-sdk-cpp $ vi ./kinesis-video-producer/tst/ProducerTestFixture.h
mypi@raspberrypi:~/amazon-kinesis-video-streams-producer-sdk-cpp $ diff ./kinesis-video-producer/tst/ProducerTestFixture.h.org ./kinesis-video-producer/tst/ProducerTestFixture.h
28c28
< #define TEST_STORAGE_SIZE_IN_BYTES 1024 * 1024 * 1024ull
---
> #define TEST_STORAGE_SIZE_IN_BYTES 256 * 1024 * 1024ull

Kinesis Video Streams SDK のビルド

AN INTRODUCTION TO KINESIS VIDEO STREAMS」のNo.40 cを実行。

mypi@raspberrypi:~/amazon-kinesis-video-streams-producer-sdk-cpp $ ./kinesis-video-native-build/install-script
Starting to build the Kinesis Video Stream Demo Application
- will be using the following open source libraries and tools
openssl
curl
log4cplus
gettext
libffi
libpcre
zlib
iconv
googletest
bison
flex
libtools
autoconf
automake
m4
also the gstreamer, gstreamer plugins, yasm, gst-libav and x264.
Note - for MacOS High Sierra: Use
brew install autoconf
brew install bison

Y - Confirm to proceed with build install
N - Exit build install
Enter selection: Y

3、4時間程度かかってようやくビルドが終わったものの、実行ファイルが見当たらないので、もう一度インストールスクリプトを実行してみるとエラーが。

mypi@raspberrypi:~/amazon-kinesis-video-streams-producer-sdk-cpp $ ./kinesis-video-native-build/install-script
Starting to build the Kinesis Video Stream Demo Application
- will be using the following open source libraries and tools
openssl
curl
log4cplus
gettext
libffi
libpcre
zlib
iconv
googletest
bison
flex
libtools
autoconf
automake
m4
also the gstreamer, gstreamer plugins, yasm, gst-libav and x264.
Note - for MacOS High Sierra: Use
brew install autoconf
brew install bison

Y - Confirm to proceed with build install
N - Exit build install
Enter selection: Y

cmake version 3.7.2 CMake suite maintained and supported by Kitware (kitware.com/cmake).
Checking openssl at /home/mypi/amazon-kinesis-video-streams-producer-sdk-cpp/downloads/local/lib/libssl.a
Checking curl at /home/mypi/amazon-kinesis-video-streams-producer-sdk-cpp/downloads/local/lib/libcurl.a
Checking log4cplus at /home/mypi/amazon-kinesis-video-streams-producer-sdk-cpp/downloads/local/lib/liblog4cplus.dylib/.so
Checking gettext at /home/mypi/amazon-kinesis-video-streams-producer-sdk-cpp/downloads/local/lib/libgettextlib.dylib/.so
Checking libffi at /home/mypi/amazon-kinesis-video-streams-producer-sdk-cpp/downloads/local/lib/libffi.a
Checking pcre at /home/mypi/amazon-kinesis-video-streams-producer-sdk-cpp/downloads/local/lib/libpcre.dylib/.so
Checking zlib at /home/mypi/amazon-kinesis-video-streams-producer-sdk-cpp/downloads/local/lib/libz.dylib/.so
Checking iconv at /home/mypi/amazon-kinesis-video-streams-producer-sdk-cpp/downloads/local/lib/libiconv.dylib/.so
Checking util-linux at /home/mypi/amazon-kinesis-video-streams-producer-sdk-cpp/downloads/local/lib/libmount.dylib/.so
Checking glib at /home/mypi/amazon-kinesis-video-streams-producer-sdk-cpp/downloads/local/lib/libglib-2.0.dylib/.so
Checking googletest at /home/mypi/amazon-kinesis-video-streams-producer-sdk-cpp/downloads/local/lib/libgtest.a
Checking gstreamer at /home/mypi/amazon-kinesis-video-streams-producer-sdk-cpp/downloads/local/lib/libgstreamer-1.0.dylib/.so
Checking gst-plugin-base at /home/mypi/amazon-kinesis-video-streams-producer-sdk-cpp/downloads/local/lib/libgstvideo-1.0.dylib/.so
Checking gst-plugin-good at /home/mypi/amazon-kinesis-video-streams-producer-sdk-cpp/downloads/local/lib/gstreamer-1.0/libgstavi.la
Checking gst-plugin-bad at /home/mypi/amazon-kinesis-video-streams-producer-sdk-cpp/downloads/local/lib/libgstbadvideo-1.0.dylib/.so
Checking x264 at /home/mypi/amazon-kinesis-video-streams-producer-sdk-cpp/downloads/local/lib/libx264.dylib/.so
Checking gst-plugin-ugly at /home/mypi/amazon-kinesis-video-streams-producer-sdk-cpp/downloads/local/lib/gstreamer-1.0/libgstx264.dylib/.so
Checking for yasm
Checking gst-libav in /home/mypi/amazon-kinesis-video-streams-producer-sdk-cpp/downloads/local/lib/
Checking gst-omx
CMake Error: The source directory "/home/mypi/amazon-kinesis-video-streams-producer-sdk-cpp" does not appear to contain CMakeLists.txt.
Specify --help for usage, or press the help button on the CMake GUI.

スクリプトを実行したときのカレントディレクトリである
/home/mypi/amazon-kinesis-video-streams-producer-sdk-cpp
に CMakeLists.txt が無いのがいけないようです。それは1個下の kinesis-video-native-build ディレクトリにありました。その中でインストールスクリプトを実行するべきだったのか? 「AN INTRODUCTION TO KINESIS VIDEO STREAMS」の手順が間違っているということなのか?たしかにこちらでは1個下のディレクトリの中に入ってから実行しています。

気を取り直して1個下のディレクトリに入ってからもう一度ビルドします。

mypi@raspberrypi:~/amazon-kinesis-video-streams-producer-sdk-cpp $ cd kinesis-video-native-build/
mypi@raspberrypi:~/amazon-kinesis-video-streams-producer-sdk-cpp/kinesis-video-native-build $ ./install-script

エラー発生。

Scanning dependencies of target KinesisVideoProducerJNI
[ 40%] Building CXX object CMakeFiles/KinesisVideoProducerJNI.dir/home/mypi/amazon-kinesis-video-streams-producer-sdk-cpp/kinesis-video-producer-jni/src/source/com/amazonaws/kinesis/video/producer/jni/KinesisVideoClientWrapper.cpp.o
In file included from /home/mypi/amazon-kinesis-video-streams-producer-sdk-cpp/kinesis-video-producer-jni/src/source/com/amazonaws/kinesis/video/producer/jni/KinesisVideoClientWrapper.cpp:5:0:
/home/mypi/amazon-kinesis-video-streams-producer-sdk-cpp/kinesis-video-native-build/../kinesis-video-producer-jni/src/include/com/amazonaws/kinesis/video/producer/jni/KinesisVideoClientWrapper.h:14:54: fatal error: jni.h: そのようなファイルやディレクトリはありません
#include <jni.h> // Basic native API
^
compilation terminated.
CMakeFiles/KinesisVideoProducerJNI.dir/build.make:62: ターゲット 'CMakeFiles/KinesisVideoProducerJNI.dir/home/mypi/amazon-kinesis-video-streams-producer-sdk-cpp/kinesis-video-producer-jni/src/source/com/amazonaws/kinesis/video/producer/jni/KinesisVideoClientWrapper.cpp.o' のレシピで失敗しました
make[2]: *** [CMakeFiles/KinesisVideoProducerJNI.dir/home/mypi/amazon-kinesis-video-streams-producer-sdk-cpp/kinesis-video-producer-jni/src/source/com/amazonaws/kinesis/video/producer/jni/KinesisVideoClientWrapper.cpp.o] エラー 1
CMakeFiles/Makefile2:141: ターゲット 'CMakeFiles/KinesisVideoProducerJNI.dir/all' のレシピで失敗しました
make[1]: *** [CMakeFiles/KinesisVideoProducerJNI.dir/all] エラー 2
Makefile:83: ターゲット 'all' のレシピで失敗しました
make: *** [all] エラー 2

jni.h が見つからないとのことで、そういえばビルドの前にラズパイを再起動していたので、再起動前に行っていた「export JAVA HOME」が無しになってしまっていて、そのせいかもしれません。あらためてexportしてから再ビルドします。

mypi@raspberrypi:~/amazon-kinesis-video-streams-producer-sdk-cpp/kinesis-video-native-build $ export JAVA_HOME=/usr/lib/jvm/jdk-8-oracle-arm32-vfp-hflt/
mypi@raspberrypi:~/amazon-kinesis-video-streams-producer-sdk-cpp/kinesis-video-native-build $ ./install-script

今度はビルドが成功しました。

ビルド完了後のテスト

ビルドが完了するとstartというプログラムが生成されているので実行します。

mypi@raspberrypi:~/amazon-kinesis-video-streams-producer-sdk-cpp/kinesis-video-native-build $ ./start
./start: error while loading shared libraries: liblog4cplus-1.2.so.5: cannot open shared object file: No such file or directory

エラー発生。既知の問題らしく、暫定的な解決策が「オフィシャル(GitHubのAmazon Kinesis Video Streams Producer SDK for C++のReadme.md)」に載っています。

Ubuntu builds link issues

Ubuntu bulds link against the system versions of the open source component libraries or missing .so files (./start in the kinesis-video-native-build directory shows linkage against system versions of the open source libraries).We are working on providing fix but the immediate steps to remedy is to run

rm -rf ./kinesis-video-native-build/CMakeCache.txt ./kinesis-video-native-build/CMakeFiles

and run

./install-script

to rebuild and re-link the project only.

上記の通り削除してから再ビルドしあらためてstartを実行したところ、今度はテストが通りました。

[----------] Global test environment tear-down
[==========] 309 tests from 30 test cases ran. (23904 ms total)
[ PASSED ] 309 tests.

YOU HAVE 1 DISABLED TEST

INFO - Curl shutdown.
2018-03-09 22:58:31 [1996284656]

ただ、「YOU HAVE 1 DISABLED TEST」というのが気になるけどテストは一通り通ったっぽいので無視する…。

サンプルプログラムの実行

AWSのアクセスキーIDとシークレットアクセスキーIDを設定して、サンプルプログラムを実行します。

mypi@raspberrypi:~/amazon-kinesis-video-streams-producer-sdk-cpp/kinesis-video-native-build $ export AWS_ACCESS_KEY_ID=<アクセスキーID>
mypi@raspberrypi:~/amazon-kinesis-video-streams-producer-sdk-cpp/kinesis-video-native-build $ export AWS_SECRET_ACCESS_KEY=<シークレットアクセスキーID>
mypi@raspberrypi:~/amazon-kinesis-video-streams-producer-sdk-cpp/kinesis-video-native-build $ ./kinesis_video_gstreamer_sample_app <ストリーム名>

以下のようなエラーが複数出ました。

ERROR - curl perform failed for url https://kinesisvideo.us-west-2.amazonaws.com/describeStream with result Problem with the SSL CA cert (path? access rights?): error setting certificate verify locations:
CAfile: /etc/ssl/cert.pem
CApath: none

これも既知の問題とのことで、解決策が GitHub に載っています。

Curl SSL issue – “unable to get local issuer certificate”

If curl throws “Peer certificate cannot be authenticated with given CA certificates: SSL certificate problem: unable to get local issuer certificate” error while sending data to KVS, then the local curl was not built properly with --with-ca-bundle path. So please remove the curl binaries and libraries and rebuilt it again by following below steps.

rm <producer_sdk_path/kinesis-video-native-build/downloads/local/lib/libcurl*
rm <producer_sdk_path/kinesis-video-native-build/downloads/local/bin/curl*
cd <producer_sdk_path/kinesis-video-native-build/downloads/curl-7.57.0
export DOWNLOADS=<producer_sdk_path>/kinesis-video-native-build/downloads
make clean
./configure --prefix=$DOWNLOADS/local/ --enable-dynamic --disable-rtsp --disable-ldap --without-zlib --with-ssl=$DOWNLOADS/local/ --with-ca-bundle=/etc/ssl/cert.pem
make
make install

上記の通り実行して、あらためてサンプルプログラムを実行します。しかし同様にエラー。

そもそも /etc/ssl/cert.pem がありませんでした。これも GitHub に書いてあります…。

Certificate store integration

Kinesis Video Streams Produicer SDK for C++ needs to establish trust with the backend service through TLS. This is done through validating the CAs in the public certificate store. On Linux-based models, this store is located in /etc/ssl/ directory by default.

Please download the PEM file from https://www.amazontrust.com/repository/SFSRootCAG2.pem

to /etc/ssl/cert.pem. Append to the end of the file if it exists.

Many platforms come with a cert file with a lot of the well-known public certs in them.

AN INTRODUCTION TO KINESIS VIDEO STREAMS」に沿って試してきたましたが、最初からGitHubの方をちゃんと見ておけばよかったかもしれません。

とにかく証明書をダウンロードして /etc/ssl/cert.pem として格納し、サンプルプログラムを再実行します。

エラー。

WARN - HTTP Error 404: Response: {"Message":"Stream raspi doesn't exist"}

これについても GitHub をよく読んでみるとちゃんと書いてあります…。

AWS_DEFAULT_REGION for the region other than us-west-2

今回は東京リージョンを使っているので以下を実行します。

export AWS_DEFAULT_REGION=ap-northeast-1

これで上記のエラーはなくなりましたが、相変わらずサンプルプログラムは一瞬で終了してしまい、ビデオはアップロードされません。

$ vcgencmd get_camera
$ sudo modprobe bcm2835-v4l2

で生成されていたはずの /dev/video0 が無くなっています。OSを再起動するとこれも揮発してしまう模様。あらためてまた実行し、サンプルプログラムを実行します。

ついに成功。

Kinesisビデオストリーム成功

「sudo modprobe bcm2835-v4l2」だとOS再起動で揮発してしまうようなので、「AN INTRODUCTION TO KINESIS VIDEO STREAMS」のNo.35のとおり、/etc/modules の最終行に「bcm2835-v4l2」と書いた方がいいようです。

コメントを残す

%d人のブロガーが「いいね」をつけました。