320
Amazon Kinesis Video Streams 開発者ガイド

Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

  • Upload
    others

  • View
    74

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams開発者ガイド

Page 2: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイド

Amazon Kinesis Video Streams: 開発者ガイドCopyright © 2020 Amazon Web Services, Inc. and/or its affiliates. All rights reserved.

Amazon's trademarks and trade dress may not be used in connection with any product or service that is not Amazon's,in any manner that is likely to cause confusion among customers, or in any manner that disparages or discreditsAmazon. All other trademarks not owned by Amazon are the property of their respective owners, who may or may notbe affiliated with, connected to, or sponsored by Amazon.

Page 3: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイド

Table of ContentsAmazon Kinesis ビデオストリーム とは? ............................................................................................... 1

Kinesis ビデオストリーム を初めてお使いになる方向けの情報 .......................................................... 2システム要件 ..................................................................................................................................... 3

カメラの要件 ............................................................................................................................. 3テスト済みカメラ ............................................................................................................... 3テスト済みオペレーティングシステム .................................................................................... 4

SDK ストレージ要件 ................................................................................................................... 4仕組み ............................................................................................................................................... 5

API およびプロデューサーライブラリ ............................................................................................ 6Kinesis ビデオストリーム API .............................................................................................. 6プロデューサーライブラリ ................................................................................................... 8

動画再生 .................................................................................................................................... 9HLS を使用した動画再生 ..................................................................................................... 9MPEG-DASH を使用した動画再生 ....................................................................................... 13

ストリーミングメタデータの使用 ................................................................................................ 15Kinesis ビデオストリームにメタデータを追加する ................................................................. 16Kinesis ビデオストリームに埋め込まれたメタデータを使用する ............................................... 17ストリーミングメタデータの制限事項 .................................................................................. 18

データモデル ............................................................................................................................ 18ストリームヘッダー要素 .................................................................................................... 19トラックデータのストリーミング ........................................................................................ 22フレームヘッダー要素 ....................................................................................................... 23MKV フレームデータ ......................................................................................................... 23

はじめに .......................................................................................................................................... 24ステップ 1: アカウントを設定する .............................................................................................. 24

AWS へのサインアップ ..................................................................................................... 24IAM ユーザー管理者の作成 ................................................................................................. 25AWS アカウントキーを作成する ......................................................................................... 25次のステップ .................................................................................................................... 25

ステップ 2: Kinesis ビデオストリームを作成する .......................................................................... 25コンソールを使用してビデオストリームを作成するには ......................................................... 26AWS CLI を使用したビデオストリームの作成 ....................................................................... 26次のステップ .................................................................................................................... 26

ステップ 3: Kinesis ビデオストリームにデータを送信する .............................................................. 26C++ プロデューサー SDK をダウンロードする ...................................................................... 27GStreamer サンプルのコンパイル ....................................................................................... 27GStreamer サンプルの実行 ................................................................................................ 27メディアデータの使用 ....................................................................................................... 28次のステップ .................................................................................................................... 29

次のステップ ............................................................................................................................ 29セキュリティ .................................................................................................................................... 30

データ保護 ............................................................................................................................... 30Kinesis ビデオストリーム 用のサーバー側の暗号化とは .......................................................... 31コスト、リージョン、およびパフォーマンスに関する考慮事項 ................................................ 31サーバー側の暗号化の使用を開始する方法 ............................................................................ 32ユーザー生成 AWS KMS マスターキーの作成と使用 .............................................................. 32ユーザー生成 AWS KMS マスターキーを使用するためのアクセス許可 ...................................... 32

IAM により Kinesis ビデオストリーム リソースへのアクセスを制御する ........................................... 34ポリシー構文 .................................................................................................................... 34Kinesis ビデオストリーム のアクション ............................................................................... 35Kinesis ビデオストリーム 用の Amazon リソースネーム(ARN) ............................................ 35他の IAM アカウントに Kinesis ビデオストリームに対するアクセス許可を付与する .................... 35ポリシーの例 .................................................................................................................... 36

AWS IoT により Kinesis ビデオストリーム リソースへのアクセスを制御する .................................... 37

iii

Page 4: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイド

ストリーム名としての IoT ThingName ................................................................................. 38ストリーム名としての IoT CertificateId ................................................................................ 43

モニタリング ............................................................................................................................ 44コンプライアンス検証 ............................................................................................................... 44耐障害性 .................................................................................................................................. 45インフラストラクチャセキュリティ ............................................................................................. 45セキュリティベストプラクティス ................................................................................................ 45

最小特権アクセスの実装 .................................................................................................... 45IAM ロールの使用 ............................................................................................................. 46CloudTrail を使った API コールのモニタリング ..................................................................... 46

プロデューサーライブラリ ................................................................................................................. 47Kinesis ビデオストリーム プロデューサークライアント .................................................................. 47Kinesis ビデオストリーム Producer Library ................................................................................... 48関連トピック ............................................................................................................................ 48Java プロデューサーライブラリ .................................................................................................. 48

手順: Java プロデューサー SDK を使用する ......................................................................... 49ステップ 1: コードをダウンロードして設定する .................................................................... 50ステップ 2: コードを作成してテストする ............................................................................. 50ステップ 3: コードを実行して検証する ................................................................................ 52

Android プロデューサーライブラリ .............................................................................................. 52手順: Android プロデューサー SDK を使用する ..................................................................... 52ステップ 1: コードをダウンロードして設定する .................................................................... 54ステップ 2: コードを検証する ............................................................................................ 55ステップ 3: コードを実行して検証する ................................................................................ 56

C++ プロデューサーライブラリ .................................................................................................. 57オブジェクトモデル .......................................................................................................... 57ストリームへのメディアの挿入 ........................................................................................... 57コールバックインターフェイス ........................................................................................... 58手順: C++ プロデューサー SDK を使用する .......................................................................... 58ステップ 1: コードをダウンロードして設定する .................................................................... 60ステップ 2: コードを作成してテストする ............................................................................. 61ステップ 3: コードを実行して検証する ................................................................................ 65C++ プロデューサー SDK を GStreamer プラグインとして使用する ......................................... 66Docker コンテナで C++ プロデューサー SDK を GStreamer プラグインとして使用する .............. 66Windows で C++ プロデューサー SDK を使用する ................................................................ 67Raspberry Pi で C++ プロデューサー SDK を使用する ........................................................... 69ログ記録の使用 ................................................................................................................. 75

C プロデューサーライブラリ ...................................................................................................... 75オブジェクトモデル .......................................................................................................... 75ストリームへのメディアの挿入 ........................................................................................... 76手順: C プロデューサー SDK を使用する ............................................................................. 76ステップ 1: コードをダウンロードする ................................................................................ 78ステップ 2: コードを作成してテストする ............................................................................. 79ステップ 3: コードを実行して検証する ................................................................................ 81

リファレンス ............................................................................................................................ 82プロデューサー SDK の制限 ............................................................................................... 82エラーコードのリファレンス .............................................................................................. 84NAL 適応フラグ .............................................................................................................. 108プロデューサーの構造 ...................................................................................................... 109ストリーム構造 ............................................................................................................... 110コールバック .................................................................................................................. 122

ストリームパーサーライブラリ ......................................................................................................... 128手順: Kinesis ビデオストリームパーサーライブラリの使用 ............................................................ 128前提条件 ................................................................................................................................ 128ステップ 1: コードをダウンロードして設定する .......................................................................... 129

次のステップ .................................................................................................................. 129ステップ 2: コードを作成してテストする ................................................................................... 129

iv

Page 5: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイド

StreamingMkvReader ....................................................................................................... 129FragmentMetadataVisitor .................................................................................................. 130OutputSegmentMerger ..................................................................................................... 131KinesisVideoExample ....................................................................................................... 132次のステップ .................................................................................................................. 134

ステップ 3: コードを実行して検証する ....................................................................................... 134例 ................................................................................................................................................. 136

例: Kinesis ビデオストリーム へのデータの送信 .......................................................................... 136例: Kinesis ビデオストリーム からのデータの取得 ....................................................................... 136例: ビデオデータの再生 ............................................................................................................ 136前提条件 ................................................................................................................................ 136GStreamer ............................................................................................................................. 137

GStreamer エレメントのダウンロード、構築、設定 ............................................................. 138GStreamer エレメントを実行します。 ............................................................................... 138起動コマンド .................................................................................................................. 139Docker コンテナで GStreamer エレメントを実行します。 .................................................... 141パラメータリファレンス ................................................................................................... 143

PutMedia API ......................................................................................................................... 146ステップ 1: コードをダウンロードして設定する .................................................................. 146ステップ 2: コードを作成してテストする ............................................................................ 147ステップ 3: コードを実行して検証する ............................................................................... 149

RTSP および Docker ............................................................................................................... 149前提条件 ........................................................................................................................ 150Docker イメージの作成 .................................................................................................... 150RTSP サンプルアプリケーションを実行する ....................................................................... 150

レンダラー ............................................................................................................................. 151前提条件 ........................................................................................................................ 151レンダラ―の例の実行 ....................................................................................................... 151仕組み ........................................................................................................................... 152

Amazon SageMaker ................................................................................................................ 153前提条件 ........................................................................................................................ 153アプリケーションの作成 ................................................................................................... 154アプリケーションのモニタリング ...................................................................................... 156アプリケーションの機能拡張 ............................................................................................. 157アプリケーションのクリーンアップ ................................................................................... 158

モニタリング .................................................................................................................................. 159CloudWatch を使用したメトリクスのモニタリング ...................................................................... 159

CloudWatch メトリクスのガイダンス ................................................................................. 167CloudTrail を使用した API コールのログ作成 .............................................................................. 170

Kinesis ビデオストリーム および CloudTrail ........................................................................ 170例: Amazon Kinesis ビデオストリーム ログファイルエントリ ................................................ 171

制限 .............................................................................................................................................. 174コントロールプレーン API の制限 ............................................................................................. 174メディアおよびアーカイブ済みメディア API の制限 ..................................................................... 176

トラブルシューティング ................................................................................................................... 179一般的な問題のトラブルシューティング ..................................................................................... 179

レイテンシーが高すぎる ................................................................................................... 179API の問題のトラブルシューティング ........................................................................................ 179

エラー:「未知のオプション」 ............................................................................................ 180エラー: "承認するサービス/オペレーション名を特定できませんでした" .................................... 180エラー: "ストリームにフレームを配置できませんでした" ....................................................... 180エラー: "最終 AckEvent が受信される前に、サービスによって接続が終了されました" ................ 181エラー: 「STATUS_STORE_OUT_OF_MEMORY」 .............................................................. 181

HLS の問題のトラブルシューティング ....................................................................................... 181HLS ストリーミングセッション URL の取得は成功するが、ビデオプレーヤーで再生が失敗する . 181プロデューサーとプレーヤー間のレイテンシーが高すぎる ..................................................... 182

Java の問題のトラブルシューティング ....................................................................................... 183

v

Page 6: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイド

Java ログの有効化 .......................................................................................................... 183プロデューサーライブラリの問題のトラブルシューティング .......................................................... 183

プロデューサー SDK をコンパイルできない ........................................................................ 184ビデオストリームはコンソールには表示されません。 ........................................................... 184エラー: GStreamer デモアプリケーションを使用したデータのストリーミング時の "リクエストに含まれているセキュリティトークンが無効です" ................................................................ 185エラー: 「Kinesis Video クライアントにフレームを送信できませんでした」 ............................ 185GStreamer アプリケーションが、OS X で "ストリーミングが中止されました。ネゴシエーションされていないという理由です" というメッセージで停止する ............................................... 185エラー: Raspberry Pi の GStreamer デモで Kinesis ビデオクライアントを作成するときの "ヒープを割り当てできませんでした" ........................................................................................ 186エラー: Raspberry Pi での GStreamer デモの実行時の "無効な命令" ........................................ 186カメラで Raspberry Pi のロードに失敗する ........................................................................ 186カメラが macOS High Sierra で見つからない ...................................................................... 187macOS High Sierra でコンパイルするときに、jni.h ファイルが見つかりません ......................... 187GStreamer デモアプリケーションを実行中の Curl エラー ...................................................... 187Raspberry Pi での実行時のタイムスタンプ/範囲アサーション ................................................ 187Raspberry Pi の gst_value_set_fraction_range_full でのアサーション ....................................... 187Android での STATUS_MKV_INVALID_ANNEXB_NALU_IN_FRAME_DATA(0x3200000d) エラー . 187最大フラグメント継続時間に達しました ............................................................................. 188IoT 認証の使用中に "無効なモノの名前が渡されました (Invalid thing name passed)" エラーが発生 ................................................................................................................................. 188

Stream Parser ライブラリの問題のトラブルシューティング .......................................................... 188ストリームから 1 つのフレームにアクセスできない ............................................................. 188フラグメントのデコードエラー ......................................................................................... 189

ドキュメント履歴 ............................................................................................................................ 190API リファレンス ............................................................................................................................ 194

Actions .................................................................................................................................. 194Amazon Kinesis Video Streams ......................................................................................... 194Amazon Kinesis Video Streams Media ............................................................................... 250Amazon Kinesis Video Streams Archived Media .................................................................. 261

Data Types ............................................................................................................................ 287Amazon Kinesis Video Streams ......................................................................................... 287Amazon Kinesis Video Streams Media ............................................................................... 298Amazon Kinesis Video Streams Archived Media .................................................................. 300

Common Errors ...................................................................................................................... 311Common Parameters ............................................................................................................... 313

vi

Page 7: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイド

Amazon Kinesis ビデオストリーム とは?

Amazon Kinesis ビデオストリーム は、デバイスから AWS クラウドへのビデオのライブストリーミングに使用したり、あるいはリアルタイムのビデオ処理やバッチ指向のビデオ分析のためのアプリケーションを構築できる完全管理の AWS のサービスです。

Kinesis ビデオストリーム 単なるビデオデータ用のストレージではありません。これを使用すると、ビデオストリームをクラウドで受信しながらリアルタイムで視聴できます。AWS マネジメントコンソールでライブストリームをモニタリングすることも、Kinesis ビデオストリーム API を使用してライブビデオを表示するモニタリングアプリケーションを開発することもできます。

Kinesis ビデオストリーム を使用すると、スマートフォン、セキュリティカメラ、ウェブカメラ、車、ドローンやその他のソースに設置されるカメラのような何百万ものソースからライブビデオデータの膨大な量を取得できます。また、オーディオデータ、熱画像、深度データ、RADAR データなどの多くの時刻シリアル化された非ビデオデータも送信できます。このようなソースから Kinesis ビデオストリームへのライブストリーミングのために、フレームごとにリアルタイムの低レイテンシー処理のデータにアクセスできるアプリケーションを構築できます。Kinesis ビデオストリーム はソースに依存しません。GStreamer (p. 137) ライブラリを使用してコンピュータのウェブカメラから、または RTSP を使用してネットワーク上のカメラからビデオをストリーミングできます。

また、指定する保持期間でメディアデータを永続的に保存するように Kinesis ビデオストリームを設定することもできます。Kinesis ビデオストリーム は、このデータを自動的に保存し、保管時に暗号化します。また Kinesis ビデオストリーム は、保存されたデータをプロデューサータイムスタンプと取り込み時刻スタンプの両方で時刻インデックス化します。定期的にビデオデータをバッチ処理するアプリケーションを構築するか、あるいは異なるユースケースに応じた履歴データへのアドホックアクセスを必要とするアプリケーションを作成できます。

カスタム、リアルタイム、あるいはバッチ指向のアプリケーションは、Amazon EC2 インスタンスで実行できます。このようなアプリケーションは、オープンソースのディープラーニングのアルゴリズム、あるいは Kinesis ビデオストリーム に統合されるサードパーティーのアプリケーションを使用してデータを処理することができます。

Kinesis ビデオストリーム を使用すると、次のような利点があります。

• 何百万ものデバイスに接続してストリームする – Kinesis ビデオストリーム は、消費者のスマートフォン、ドローン、車載カメラやその他数多くのデバイスからビデオ、オーディオやその他のデータに接続してストリームできます。Kinesis ビデオストリーム プロデューサーライブラリを使用すると、デバイスを設定して、リアルタイムまたは事後メディアアップロードによる安定したストリーミングを行うことができます。

• データの永続的な保存、暗号化とインデックス– カスタムの保存期間用にメディアデータを永続的に保管するように Kinesis ビデオストリームを設定できます。また、Kinesis ビデオストリーム は、プロデューサーの生成あるいはサービス側のタイムスタンプに基づいた保存データのインデックスも生成します。アプリケーションは、タイムインデックスを使用して指定するデータを簡単に取得できます。

• インフラストラクチャではなく、アプリケーションの管理に集中 – Kinesis ビデオストリーム はサービスレスのため、セットアップや管理するインフラストラクチャの必要はありません。データストリームおよび受信側アプリケーションの拡大や縮小に伴って基盤となるインフラストラクチャのデプロイや設定、伸縮自在なスケーリングを心配する必要はありません。Kinesis ビデオストリーム は、ストリームを扱うために必要なすべての管理や維持を自動的に行うため、インフラストラクチャではなく、アプリケーションに集中することができます。

• データストリームでリアルタイムのバッチアプリケーションを構築 – Kinesis ビデオストリーム を使用して、ライブデータストリームで運用するカスタムリアルタイムアプリケーションを構築することも、

1

Page 8: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドKinesis ビデオストリーム を初めてお使いになる方向けの情報

厳格なレイテンシー要件なしで永続的に保持されるデータを運用するバッチあるいはアドホックのアプリケーションを作成することもできます。カスタムアプリケーションの構築、デプロイおよび管理ができます。オープンソース (Apache MXNet、OpenCV)、自社開発、あるいは AWS Marketplace を通したサードパーティのソリューションでストリームを処理、分析します。Kinesis ビデオストリーム Get APIは、リアルタイムあるいはバッチ指向をベースに、複数の現行アプリケーション処理データを構築できます。

• ストリームデータをより安全に – Kinesis ビデオストリーム はこのサービスを経由してデータとなる際のすべてのデータを暗号化します。Kinesis ビデオストリーム は、デバイスからのデータストリーミングを Transport Layer Security (TLS) ベースで暗号化し、AWS Key Management Service (AWS KMS) を使用して保管中のすべてのデータを暗号化します。また、AWS Identity and Access Management (IAM)を使用してデータへのアクセスを管理することもできます。

• 従量課金制 – 詳細は、「AWS 料金表」を参照してください。

Kinesis ビデオストリーム を初めてお使いになる方向けの情報

Kinesis ビデオストリーム を初めて使用する方には、次のセクションを順に読むことをお勧めします。

1. Amazon Kinesis ビデオストリーム: 仕組み (p. 5) – Kinesis ビデオストリーム の概念を説明します。2. Kinesis ビデオストリーム の使用開始 (p. 24) – アカウントをセットアップして Kinesis ビデオスト

リーム をテストします。3. Kinesis ビデオストリーム プロデューサーライブラリ (p. 47) – Kinesis ビデオストリーム プロデュー

サーアプリケーションの作成について説明します。4. Kinesis ビデオストリームパーサーライブラリ (p. 128) – Kinesis ビデオストリーム コンシューマーア

プリケーションの受信データフレーム処理について説明します。5. Amazon Kinesis ビデオストリーム 例 (p. 136) – Kinesis ビデオストリーム を使用してできるその他の

例をご覧ください。

2

Page 9: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドカメラの要件

Kinesis ビデオストリーム システム要件

以下のセクションで、Amazon Kinesis ビデオストリーム のハードウェア、ソフトウェア、ストレージの要件を説明します。

トピック• カメラの要件 (p. 3)• SDK ストレージ要件 (p. 4)

カメラの要件Kinesis ビデオストリーム プロデューサー SDK とサンプルを実行するために使用するカメラには次のメモリ要件があります。

• SDK コンテンツビューには 16 MB のメモリが必要です。• サンプルアプリケーションのデフォルト設定は 512 MB です。この値は、ネットワーク接続が良好で追

加バッファリングの必要がないプロデューサーに適しています。ネットワーク接続の状態が悪く、必要とするバッファリングが大きい場合、1 秒あたりのフレームレートをフレームメモリサイズで乗算してバッファリング 1 秒あたりに必要なメモリを計算できます。メモリの割り当ての詳細については、「StorageInfo (p. 109)」を参照してください。

H.264 を使用してデータをエンコードする USB または RTSP (Real Time Streaming Protocol) カメラを使用することをお勧めします。CPU のエンコード負荷がなくなるためです。

現在、デモアプリケーションでは RTSP ストリーミング用の User Datagram Protocol(UDP) をサポートしていません。この機能は今後追加される予定です。

プロデューサー SDK では以下のタイプのカメラがサポートされています。

• ウェブカメラ。• USB カメラ。• H.264 エンコードができるカメラ (推奨)。• H.264 エンコードではないカメラ。• Raspberry Pi カメラモジュール。Raspberry Pi デバイスでこれが推奨されるのは、ビデオデータ転送で

は GPU に接続されるため、CPU 処理のオーバーヘッドがないためです。• RTSP (ネットワーク) カメラ。これらのカメラが推奨されるのは、ビデオストリームが H.264 でエン

コードされるためです。

テスト済みカメラ以下の USB カメラが Kinesis ビデオストリーム でテスト済みです。

• Logitech 1080p• Logitech C930• Logitech C920 (H.264)

3

Page 10: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドテスト済みオペレーティングシステム

• Logitech Brio (4K)• SVPRO USB カメラ 170 度魚眼レンズ広角 1080P 2mp Sony IMX322 HD H.264 30fps ミニアルミニウ

ム USB ウェブカメラ

以下の IP カメラが Kinesis ビデオストリーム でテスト済みです。

• Vivotek FD9371 – HTV/EHTV• Vivotek IB9371 – HT• Hikvision 3MP IP カメラ DS-2CD2035FWD-I• Sricam SP012 IP• VStarcam 720P WiFi IP カメラ (TCP)• Ipccam Security Surveillance IP カメラ 1080P• AXIS P3354 固定ドーム型ネットワークカメラ

Kinesis ビデオストリーム でテストされたカメラのうち、Vivotek カメラの RTSP ストリームが最も安定しています。RTSP ストリームの一貫性が最も低いのは Sricam です。

テスト済みオペレーティングシステムウェブカメラおよび RTSP カメラは、以下のデバイスとオペレーティングシステムでテストされています。

• Mac mini• High Sierra

• MacBook Pro ノートパソコン• Sierra (10.12)• El Capitan (10.11)

• Ubuntu 16.04 を実行している HP ノートパソコン• Ubuntu 17.10 (Docker コンテナ)• Raspberry Pi 3

SDK ストレージ要件Kinesis ビデオストリーム プロデューサーライブラリ (p. 47) をインストールする場合の最小ストレージ要件は 170 MB、推奨ストレージ要件は 512 MB です。

4

Page 11: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイド

Amazon Kinesis ビデオストリーム:仕組み

トピック• Kinesis ビデオストリーム API およびプロデューサーライブラリのサポート (p. 6)• Kinesis ビデオストリーム 再生 (p. 9)• Kinesis ビデオストリーム を持つストリーミングメタデータの使用 (p. 15)• Kinesis ビデオストリーム データモデル (p. 18)

Amazon Kinesis ビデオストリーム は完全マネージド型の AWS のサービスで、ライブ動画をデバイスからAWS クラウドにストリーミングし、永続的に保存できるようにします。その後、リアルタイムで動画を処理するために独自のアプリケーションを構築するか、バッチ指向の動画分析を実行できます。

次の図は、Kinesis ビデオストリーム の機能の概要を示しています。

この図は、次のコンポーネント間のやり取りを示しています。

5

Page 12: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAPI およびプロデューサーライブラリ

• プロデューサー – データを Kinesis 動画ストリームに挿入する任意のソース。監視カメラ、身体装着型カメラ、スマートフォンカメラ、ダッシュボードカメラなど、動画を生成するあらゆるデバイスをプロデューサーにすることができます。プロデューサーは、音声フィード、イメージ、RADAR データなどの動画以外のデータも送信できます。

1 つのプロデューサーは、1 つ以上の動画ストリームを生成できます。たとえば、ビデオカメラは動画データを 1 つの Kinesis 動画ストリームにプッシュし、音声データを別のストリームにプッシュすることができます。• Kinesis ビデオストリーム プロデューサーライブラリ – デバイスにインストールして設定できる、使

いやすい一連のソフトウェアとライブラリ。これらのライブラリを使用すると、動画の安全な接続と信頼性の高い方法でのストリーミングが簡単にできるようになります。ストリーミング方法には、リアルタイム、数秒間のバッファリング後、事後メディアアップロードなどのさまざまな方法を利用できます。

• Kinesis 動画ストリーム – ライブ動画データを転送して、必要に応じて保存し、リアルタイムとバッチまたはアドホックの両方でデータを消費できるようにするリソースです。一般的な設定の場合、Kinesis 動画ストリームには、それに対してデータを発行するプロデューサーが 1 つだけ用意されています。

音声、動画のほか、奥行き感知フィードや RADAR フィードなどの、時間がエンコードされた類似のデータストリームを扱うことができます。Kinesis 動画ストリームは AWS マネジメントコンソール を使用して作成するか、AWS SDK を使用してプログラミングすることにより作成します。

複数の独立したアプリケーションでは、Kinesis 動画ストリームを並列で消費できます。• コンシューマー – フラグメントやフレームなどのデータを Kinesis 動画ストリームから取得して、表

示、処理、または分析します。一般的に、これらのコンシューマーは Kinesis ビデオストリーム アプリケーションと呼ばれます。リアルタイムで、または低レイテンシー処理が求められない場合は、データが永続的に保存されて時間インデックスが作成された後で、Kinesis 動画ストリームのデータを消費および処理するアプリケーションを作成できます。これらのコンシューマーアプリケーションを作成してAmazon EC2 インスタンス上で実行できます。• Kinesis ビデオストリームパーサーライブラリ (p. 128) – Kinesis ビデオストリーム アプリケーショ

ンが Kinesis ビデオストリームから低レイテンシーでメディアを確実に取得できるようにします。また、メディア内のフレームの境界を解析し、アプリケーションでフレーム自体の処理や分析を集中的に実行できるようにします。

Kinesis ビデオストリーム API およびプロデューサーライブラリのサポート

Kinesis ビデオストリーム には、ストリームを作成および管理し、ストリーム間でメディアデータの読み取りまたは書き込みを行うための API が用意されています。Kinesis ビデオストリーム コンソールは管理機能に加えて、ライブ再生およびビデオオンデマンドの再生もサポートしています。Kinesis ビデオストリーム は、アプリケーションコードで使用すると、データをメディアソースから抽出したり、Kinesis 動画ストリームにアップロードすることができる一連のプロデューサーライブラリも提供します。

トピック• Kinesis ビデオストリーム API (p. 6)• プロデューサーライブラリ (p. 8)

Kinesis ビデオストリーム APIKinesis ビデオストリーム には、Kinesis 動画ストリームを作成および管理するための API が用意されています。また、メディアデータをストリームから読み取ったり、ストリームに書き込むための API も用意されています。

6

Page 13: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドKinesis ビデオストリーム API

• プロデューサー API – Kinesis ビデオストリーム には、メディアデータを PutMedia 動画ストリームに書き込むための Kinesis API が用意されています。PutMedia リクエストで、プロデューサーはメディアフラグメントのストリームを送信します。フラグメントとは、自己完結型のフレームのシーケンスです。フラグメントに属するフレームは、他のフラグメントからのフレームに依存していないことが求められます。詳細については、「PutMedia (p. 255)」を参照してください。

フラグメントが届くと、Kinesis ビデオストリーム では一意のフラグメント番号を昇順で割り当てます。また、フラグメントごとにプロデューサー側とサーバー側のタイムスタンプを Kinesis ビデオストリーム 固有のメタデータとして保存します。

• コンシューマー API – コンシューマーは次の API を使用して、ストリームからデータを取得できます。• GetMedia - この API を使用するとき、コンシューマーは開始フラグメントを識別する必要がありま

す。次に、API はストリームに追加された順番 (昇順のフラグメント番号) でフラグメントを返します。フラグメント内のメディアデータは、Matroska (MKV) などの構造化された形式にまとめられています。詳細については、「GetMedia (p. 251)」を参照してください。

Note

GetMedia では、フラグメントの場所を認識します (データストア内にアーカイブされているか、リアルタイムで利用可能)。たとえば、開始フラグメントがアーカイブされていることを GetMedia が判断すると、フラグメントがデータストアから返され始めます。まだアーカイブされていない新しいフラグメントを返す必要がある場合、GetMedia ではメモリ内ストリームバッファからフラグメントを読み取るように切り替わります。

これは、ストリームによって取り込まれた順番でフラグメントを処理する継続的なコンシューマーの例です。

GetMedia では、動画処理アプリケーションが失敗したり、遅延した後でも、問題なく処理を挽回することができます。GetMedia を使用すると、アプリケーションでは、データストアにアーカイブされているデータを処理でき、アプリケーションが処理に追いついてきたところで、届いたメディアデータを GetMedia がリアルタイムで引き続き配信するようになります。

• GetMediaFromFragmentList (および ListFragments) - バッチ処理アプリケーションはオフラインコンシューマーと見なされます。オフラインコンシューマーは、ListFragments とGetMediaFromFragmentList の API を組み合わせることで、特定のメディアフラグメントまたは動画の範囲を明示的にフェッチできます。ListFragments および GetMediaFromFragmentListを使用すると、アプリケーションは、特定の時間範囲またはフラグメント範囲の動画のセグメントを識別し、これらのフラグメントを順番に、または並行して処理するためにフェッチできます。このアプローチは、大量のデータを並行して迅速に処理する必要がある MapReduce アプリケーションに適しています。

たとえば、コンシューマーが 1 日分の動画フラグメントを処理する必要があるとします。コンシューマーは次のことを行います。1. ListFragments API を呼び出し、時間範囲を指定して目的のフラグメントのコレクションを選択

することで、フラグメントのリストを取得します。

API は、指定された時間範囲内のすべてのフラグメントからメタデータを返します。メタデータは、フラグメント番号、プロデューサー側/サーバー側のタイムスタンプなどの情報を提供します。

2. フラグメントのメタデータリストを使用して、フラグメントを任意の順序で取得します。たとえば、その日のすべてのフラグメントを処理するために、コンシューマーはリストをサブリストに分割し、GetMediaFromFragmentList を使用して同時にフラグメントをフェッチして、これらを並行して処理するようにワーカー (複数の Amazon EC2 インスタンスなど) に指示することができます。

次の図は、これらの API コール中のフラグメントとチャンクのデータフローを示しています。

7

Page 14: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドプロデューサーライブラリ

プロデューサーが PutMedia リクエストを送信するときは、ペイロード内のメディアメタデータを送信してから、メディアデータフラグメントのシーケンスを送信します。Kinesis ビデオストリーム はデータを受け取ると、Kinesis ビデオストリーム チャンクとして着信メディアデータを保存します。各チャンクは以下で構成されています。

• メディアメタデータのコピー• フラグメント• フラグメント番号やサーバー側およびプロデューサー側のタイムスタンプなどの Kinesis ビデオスト

リーム 固有のメタデータ

コンシューマーがメディアメタデータをリクエストすると、Kinesis ビデオストリーム では、リクエストで指定されたフラグメント番号から始まるチャンクのストリームを返します。

ストリームのデータの永続性を有効にした場合、Kinesis ビデオストリーム はストリームでフラグメントを受け取った後に、フラグメントのコピーをデータストアに保存します。

プロデューサーライブラリKinesis 動画ストリームの作成後は、ストリームへのデータの送信を開始できます。アプリケーションコードで、これらのライブラリを使用してデータをメディアソースから抽出したり、Kinesis 動画ストリームにアップロードすることができます。使用可能なプロデューサーライブラリの詳細については、「Kinesis ビデオストリーム プロデューサーライブラリ (p. 47)」を参照してください。

8

Page 15: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイド動画再生

Kinesis ビデオストリーム 再生次の方法を使用して Kinesis ビデオストリーム を表示できます。

• GetMedia: GetMedia API を使用して、Kinesis ビデオストリームを処理する独自のアプリケーションを構築できます。GetMedia は低レイテンシーのリアルタイム API です。GetMedia を使用するプレーヤーを作成する場合は 、自分で構築する必要があります。GetMedia を使用して Kinesis ビデオストリーム を表示するアプリケーションを開発する方法については、「ストリームパーサーライブラリ (p. 128)」を参照してください。

• HLS: HTTP Live Streaming (HLS) は、業界標準の HTTP ベースのメディアストリーミング通信プロトコルです。HLS を使用して、ライブ再生またはアーカイブ済み動画の再生用に Amazon Kinesis ビデオストリーム を表示できます。

HLS はライブ再生に使用できます。通常、レイテンシーは 3〜5 秒ですが、ユースケース、プレーヤー、およびネットワーク条件に応じて 1〜10 秒になる場合もあります。サードパーティー製のプレーヤー (Video.js や Google Shaka Player など) を使用して動画ストリームを表示するには、HLS ストリーミングセッション URL をプログラムまたは手動で指定できます。動画を再生するには、Apple Safari ブラウザまたは Microsoft Edge ブラウザのロケーションバーに HLS ストリーミングセッション URL を入力することもできます。

• MPEG-DASH: Dynamic Adaptive Streaming over HTTP (DASH) (MPEG-DASH とも呼ばれる) は、従来の HTTP ウェブサーバーから配信されたインターネット経由で高品質のストリーミングを可能にする適応ビットレートストリーミングプロトコルです。

MPEG-DASH はライブ再生に使用できます。通常、レイテンシーは 3〜5 秒ですが、ユースケース、プレーヤー、およびネットワーク条件に応じて 1〜10 秒になる場合もあります。サードパーティー製のプレーヤー (dash.js や Google Shaka Player など) を使用して動画ストリームを表示するには、MPEG-DASH ストリーミングセッション URL をプログラムまたは手動で指定できます。

• GetClip API: API GetClip を使用して、指定した時間範囲において、アーカイブされたオンデマンドメディアを含むクリップ (MP4 ファイル) を、指定したビデオストリームからダウンロードできます。詳細については、GetClip API リファレンスを参照してください。

トピック• HLS を使用した動画再生 (p. 9)• MPEG-DASH を使用した動画再生 (p. 13)

HLS を使用した動画再生HLS を使用して Kinesis ビデオストリーム を表示するには、まず、GetHLSStreamingSessionURL を使用してストリーミングセッションを作成します。このアクションにより、HLS セッションにアクセスするための URL (セッショントークンを含む) が返されます。次に、この URL をメディアプレーヤーまたはスタンドアロンアプリケーションで使用してストリームを表示できます。

Amazon Kinesis ビデオストリーム では、HLS を介して動画を提供する場合、以下が要件となります。

• データの保持期間が 0 より大きい。• ストリームのトラック 1 には、コーデック ID V_MPEG/ISO/AVC が必要で、H.264 エンコードメディア

が含まれている必要があります。オーディオトラック (オプション) がある場合、トラック番号 2 である必要があり、コーデック ID A_AAC が必要です。また、AAC でエンコードされたオーディオが含まれている必要があります。

• フラグメントに、ビデオメディア用の AVC (Advanced Video Coding) のコーデックプライベートデータが H.264 形式で含まれている必要があります (MPEG-4 仕様 ISO/IEC 14496-15)。また、オーディオメディア用に ACC (AAC 仕様 ISO/IEC 13818-7) のコーデックプライベートデータが含まれてい

9

Page 16: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドHLS を使用した動画再生

る必要があります。ストリームデータを特定の形式に適応させる方法については、「NAL 適応フラグ (p. 108)」を参照してください。

例: HTML および JavaScript での HLS の使用次の例では、Kinesis ビデオストリーム の HLS ストリーミングセッションを取得して、ウェブページで再生する方法を示します。この例では、動画の再生に以下のプレーヤーを使用します。

• Video.js• Google Shaka Player• hls.js

トピック• HLS 再生用の Kinesis ビデオストリーム の設定 (p. 10)• HLS 再生用に Kinesis ビデオストリーム のアーカイブ済みコンテンツエンドポイントを取得す

る (p. 10)• HLS ストリーミングセッション URL を取得する (p. 11)• HLS 再生でストリーミングビデオを表示する (p. 11)• HLS の問題のトラブルシューティング (p. 12)• HLS 再生の完全な例 (p. 12)

HLS 再生用の Kinesis ビデオストリーム の設定HLS でストリーミング動画にアクセスするには、まず、Kinesis ビデオストリーム クライアント (サービスエンドポイントを取得するため) とアーカイブ済みメディアクライアント (HLS ストリーミングセッションを取得するため) を作成して設定します。アプリケーションは、HTML ページの入力ボックスから必要な値を取得します。

<script src="https://cdnjs.cloudflare.com/ajax/libs/aws-sdk/2.278.1/aws-sdk.min.js"></script>...

var protocol = $('#protocol').val();var streamName = $('#streamName').val();

// Step 1: Configure SDK Clientsvar options = { accessKeyId: $('#accessKeyId').val(), secretAccessKey: $('#secretAccessKey').val(), sessionToken: $('#sessionToken').val() || undefined, region: $('#region').val(), endpoint: $('#endpoint').val() || undefined}var kinesisVideo = new AWS.KinesisVideo(options);var kinesisVideoArchivedContent = new AWS.KinesisVideoArchivedMedia(options);

HLS 再生用に Kinesis ビデオストリーム のアーカイブ済みコンテンツエンドポイントを取得するクライアントの初期化後に、Kinesis ビデオストリーム のアーカイブ済みコンテンツエンドポイントを取得して、HLS ストリーミングセッション URL を取得します。

// Step 2: Get a data endpoint for the streamconsole.log('Fetching data endpoint');

10

Page 17: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドHLS を使用した動画再生

kinesisVideo.getDataEndpoint({ StreamName: streamName, APIName: "GET_HLS_STREAMING_SESSION_URL" }, function(err, response) { if (err) { return console.error(err); } console.log('Data endpoint: ' + response.DataEndpoint); kinesisVideoArchivedContent.endpoint = new AWS.Endpoint(response.DataEndpoint);

HLS ストリーミングセッション URL を取得するアーカイブ済みコンテンツエンドポイントがある場合は、GetHLSStreamingSessionURL API を呼び出して HLS ストリーミングセッション URL を取得します。

// Step 3: Get a Streaming Session URLvar consoleInfo = 'Fetching ' + protocol + ' Streaming Session URL';console.log(consoleInfo); ...

else { kinesisVideoArchivedContent.getHLSStreamingSessionURL({ StreamName: streamName, PlaybackMode: $('#playbackMode').val(), HLSFragmentSelector: { FragmentSelectorType: $('#fragmentSelectorType').val(), TimestampRange: $('#playbackMode').val() === "LIVE" ? undefined : { StartTimestamp: new Date($('#startTimestamp').val()), EndTimestamp: new Date($('#endTimestamp').val()) } }, ContainerFormat: $('#containerFormat').val(), DiscontinuityMode: $('#discontinuityMode').val(), DisplayFragmentTimestamp: $('#displayFragmentTimestamp').val(), MaxMediaPlaylistFragmentResults: parseInt($('#maxResults').val()), Expires: parseInt($('#expires').val()) }, function(err, response) { if (err) { return console.error(err); } console.log('HLS Streaming Session URL: ' + response.HLSStreamingSessionURL);

HLS 再生でストリーミングビデオを表示するHLS ストリーミングセッション URL がある場合、それをビデオプレーヤーに指定します。URL をビデオプレーヤーに指定する方法は、使用するプレーヤーごとに異なります。

次のコード例では、ストリーミングセッション URL を Video.js プレーヤーに指定する方法を示します。

// VideoJS elements<video id="videojs" class="player video-js vjs-default-skin" controls autoplay></video><link rel="stylesheet" href="https://vjs.zencdn.net/6.6.3/video-js.css"><script src="https://vjs.zencdn.net/6.6.3/video.js"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/videojs-contrib-hls/5.14.1/videojs-contrib-hls.js"></script>...

else if (playerName === 'VideoJS') {var playerElement = $('#videojs');playerElement.show();var player = videojs('videojs');console.log('Created VideoJS Player');

11

Page 18: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドHLS を使用した動画再生

player.src({ src: response.HLSStreamingSessionURL, type: 'application/x-mpegURL'});console.log('Set player source');player.play();console.log('Starting playback');

次のコード例では、ストリーミングセッション URL を Google Shaka プレーヤーに指定する方法を示します。

// Shaka Player elements<video id="shaka" class="player" controls autoplay></video><script src="https://cdnjs.cloudflare.com/ajax/libs/shaka-player/2.4.1/shaka-player.compiled.js"></script>

...

else if (playerName === 'Shaka Player') {var playerElement = $('#shaka');playerElement.show();var player = new shaka.Player(playerElement[0]);console.log('Created Shaka Player');player.load(response.HLSStreamingSessionURL).then(function() { console.log('Starting playback');});console.log('Set player source');

次のコード例では、ストリーミングセッション URL を hls.js プレーヤーに指定する方法を示します。

// HLS.js elements<video id="hlsjs" class="player" controls autoplay></video><script src="https://cdn.jsdelivr.net/npm/hls.js@latest"></script>

...

var playerName = $('#player').val();if (playerName == 'HLS.js') { var playerElement = $('#hlsjs'); playerElement.show(); var player = new Hls(); console.log('Created HLS.js Player'); player.loadSource(response.HLSStreamingSessionURL); player.attachMedia(playerElement[0]); console.log('Set player source'); player.on(Hls.Events.MANIFEST_PARSED, function() { video.play(); console.log('Starting playback'); });}

HLS の問題のトラブルシューティング動画ストリームが正常に再生されない場合は、「HLS の問題のトラブルシューティング (p. 181)」を参照してください。

HLS 再生の完全な例完全なコード例をダウンロードまたは表示できます。

12

Page 19: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドMPEG-DASH を使用した動画再生

MPEG-DASH を使用した動画再生MPEG-DASH を使用して Kinesis ビデオストリーム を表示するには、まずGetDASHStreamingSessionURL を使用してストリーミングセッションを作成します。このアクションにより、MPEG-DASH セッションにアクセスするための URL (セッショントークンを含む) が返されます。次に、この URL をメディアプレーヤーまたはスタンドアロンアプリケーションで使用してストリームを表示できます。

Amazon Kinesis ビデオストリーム では、MPEG-DASH を介して動画を提供する場合、以下が要件となります。

• メディアには、h.265 または h.264 でエンコードされた動画のほか、必要に応じて AAC または 711でエンコードされたオーディオが含まれている必要があります。具体的には、トラック 1 のコーデック IDは V_MPEG/ISO/AVC (h.264 の場合) または V_MPEGH/ISO/HEVC (H.265 の場合) にする必要があります。必要に応じて、トラック 2 のコーデック ID は A_AAC (AAC の場合) または A_MS/ACM (G.711 の場合) にする必要があります。

• データの保持期間が 0 より大きい。• 各フラグメントの動画トラックに、AVC (Advanced Video Coding) のコーデックプライベートデータが

H.264 形式で、および HEVC のコーデックプライベートデータが H.265 形式で含まれている必要があります。詳細については、「MPEG-4 仕様 ISO/IEC 14496-15」を参照してください。ストリームデータを特定の形式に適応させる方法については、「NAL 適応フラグ」を参照してください。

• 各フラグメントのオーディオトラック (存在する場合) に、コーデックプライベートデータが AAC 形式(AAC 仕様 ISO/IEC 13818-7) または MS Wave 形式 で含まれている必要があります。

例: HTML および JavaScript での MPEG-DASH の使用次の例では、Kinesis ビデオストリーム の MPEG-DASH ストリーミングセッションを取得して、ウェブページで再生する方法を示します。この例では、動画の再生に以下のプレーヤーを使用します。

• Google Shaka Player• dash.js

トピック• MPEG-DASH 再生用の Kinesis ビデオストリーム の設定 (p. 13)• MPEG-DASH 再生用に Kinesis ビデオストリーム のアーカイブ済みコンテンツエンドポイントを取得

する (p. 14)• MPEG-DASH ストリーミングセッション URL を取得する (p. 14)• MPEG-DASH 再生でストリーミングビデオを表示する (p. 14)• 完全な例 (p. 15)

MPEG-DASH 再生用の Kinesis ビデオストリーム の設定

MPEG-DASH でストリーミング動画にアクセスするには、まず、Kinesis ビデオストリーム クライアント (サービスエンドポイントを取得するため) とアーカイブ済みメディアクライアント (MPEG-DASH ストリーミングセッションを取得するため) を作成して設定します。アプリケーションは、HTML ページの入力ボックスから必要な値を取得します。

var streamName = $('#streamName').val();

// Step 1: Configure SDK Clientsvar options = {

13

Page 20: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドMPEG-DASH を使用した動画再生

accessKeyId: $('#accessKeyId').val(), secretAccessKey: $('#secretAccessKey').val(), sessionToken: $('#sessionToken').val() || undefined, region: $('#region').val(), endpoint: $('#endpoint').val() || undefined }var kinesisVideo = new AWS.KinesisVideo(options);var kinesisVideoArchivedContent = new AWS.KinesisVideoArchivedMedia(options);

MPEG-DASH 再生用に Kinesis ビデオストリーム のアーカイブ済みコンテンツエンドポイントを取得する

クライアントの初期化後に、Kinesis ビデオストリーム のアーカイブ済みコンテンツエンドポイントを取得して、次のように MPEG-DASH ストリーミングセッション URL を取得できるようにします。

// Step 2: Get a data endpoint for the streamconsole.log('Fetching data endpoint');kinesisVideo.getDataEndpoint({ StreamName: streamName, APIName: "GET_DASH_STREAMING_SESSION_URL" }, function(err, response) { if (err) { return console.error(err); } console.log('Data endpoint: ' + response.DataEndpoint); kinesisVideoArchivedContent.endpoint = new AWS.Endpoint(response.DataEndpoint);

MPEG-DASH ストリーミングセッション URL を取得する

アーカイブ済みコンテンツエンドポイントがある場合は、次のように GetHLSStreamingSessionURL APIを呼び出して MPEG-DASH ストリーミングセッション URL を取得します。

// Step 3: Get a Streaming Session URLvar consoleInfo = 'Fetching ' + protocol + ' Streaming Session URL';console.log(consoleInfo);

if (protocol === 'DASH') { kinesisVideoArchivedContent.getDASHStreamingSessionURL({ StreamName: streamName, PlaybackMode: $('#playbackMode').val(), DASHFragmentSelector: { FragmentSelectorType: $('#fragmentSelectorType').val(), TimestampRange: $('#playbackMode').val() === "LIVE" ? undefined : { StartTimestamp: new Date($('#startTimestamp').val()), EndTimestamp: new Date($('#endTimestamp').val()) } }, DisplayFragmentTimestamp: $('#displayFragmentTimestamp').val(), DisplayFragmentNumber: $('#displayFragmentNumber').val(), MaxManifestFragmentResults: parseInt($('#maxResults').val()), Expires: parseInt($('#expires').val()) }, function(err, response) { if (err) { return console.error(err); } console.log('DASH Streaming Session URL: ' + response.DASHStreamingSessionURL);

MPEG-DASH 再生でストリーミングビデオを表示する

MPEG-DASH ストリーミングセッション URL がある場合、それをビデオプレーヤーに指定します。URLをビデオプレーヤーに指定する方法は、使用するプレーヤーごとに異なります。

14

Page 21: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドストリーミングメタデータの使用

次のコード例では、ストリーミングセッション URL を Google Shaka プレーヤーに指定する方法を示します。

// Step 4: Give the URL to the video player.

//Shaka Player elements <video id="shaka" class="player" controls autoplay></video><script src="https://cdnjs.cloudflare.com/ajax/libs/shaka-player/2.4.1/shaka-player.compiled.js"></script>...

var playerName = $('#player').val();

if (playerName === 'Shaka Player') { var playerElement = $('#shaka'); playerElement.show();

var player = new shaka.Player(playerElement[0]); console.log('Created Shaka Player');

player.load(response.DASHStreamingSessionURL).then(function() { console.log('Starting playback'); }); console.log('Set player source');}

次のコード例では、ストリーミングセッション URL を dash.js プレーヤーに指定する方法を示します。

<!-- dash.js Player elements --><video id="dashjs" class="player" controls autoplay=""></video><script src="https://cdn.dashjs.org/latest/dash.all.min.js"></script>

...

var playerElement = $('#dashjs');playerElement.show();

var player = dashjs.MediaPlayer().create();console.log('Created DASH.js Player');

player.initialize(document.querySelector('#dashjs'), response.DASHStreamingSessionURL, true);console.log('Starting playback');console.log('Set player source');}

完全な例

GitHub で 完全な例のコードをダウンロードまたは表示できます。

Kinesis ビデオストリーム を持つストリーミングメタデータの使用

Amazon Kinesis ビデオストリーム プロデューサー SDK は Kinesis ビデオストリーム の個別のフラグメントレベルでメタデータを埋め込むため使用します。Kinesis ビデオストリーム 内のメタデータは、変

15

Page 22: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドKinesis ビデオストリームにメタデータを追加する

更可能なキーと値のペアです。プロデューサー SDK は、フラグメント内容の説明、実際のフラグメントと一緒に転送する必要がある関連付けられたセンサー読み取り値の埋め込み、または他の個別ニーズに合わせて使用します。メタデータは the section called “GetMedia” (p. 251) またはthe section called“GetMediaForFragmentList” (p. 281) API オペレーションの一部として使用できます。メタデータは、ストリームを保持する全期間、フラグメントと一緒に保存されます。メタデータを使用するアプリケーションは、Kinesis ビデオストリームパーサーライブラリ (p. 128)によりメタデータを読み込み、処理し、それに基づいたアクションを実行できます。

メタデータをストリーム内のフラグメントを埋め込むモードは 2 つあります。

• 非永続的: 発生した業務固有の条件に基づいて、ストリーム内のフラグメントにアドホックにメタデータを付け加えます。一例として、動きを検出して、Kinesis ビデオストリーム に送信する前にその動きを含む対応フラグメントにメタデータを追加するスマートカメラがあります。フラグメントには、以下の形式でメタデータを適用できます。Motion = true

• 永続的: 継続的な要求に基づいて、ストリーム内の連続/継続するフラグメントにメタデータを付け加えます。一例として、Kinesis ビデオストリーム に送信するすべてのフラグメントに関連付けられた現在の緯度と経度の座標を送信するスマートカメラがあります。すべてのフラグメントには、以下の形式でメタデータを適用できます。Lat = 47.608013N , Long = -122.335167W

アプリケーションのニーズに基づいて、同一のフラグメントに対して同時にこのモードの両方でメタデータを付け加えられます。埋め込まれたメタデータには、検出されたオブジェクト、トラッキングされたアクティビティ、GPS 座標、またはその他のカスタムデータで、ストリームのフラグメントと関連付けるものが含まれる場合があります。メタデータはキーと値の文字列ペアとしてエンコードされます。

トピック• Kinesis ビデオストリームにメタデータを追加する (p. 16)• Kinesis ビデオストリームに埋め込まれたメタデータを使用する (p. 17)• ストリーミングメタデータの制限事項 (p. 18)

Kinesis ビデオストリームにメタデータを追加するKinesis ビデオストリーム に追加するメタデータは MKV タグとしてモデル化され、キーと値のペアとして実装されます。

メタデータは、ストリーム内のイベントをマークするなどの一時的なもの、またはあるイベントが発生したフラグメントを識別するなどの永続的なもののいずれかです。永続的なメタデータ項目は存続し続け、キャンセルされるまで連続する各フラグメントに適用されます。

Note

プロデューサーライブラリ (p. 47) を使用して追加されたメタデータ項目は、the section called“TagStream” (p. 234)、the section called “UntagStream” (p. 239)、およびthe section called“ListTagsForStream” (p. 229)を使って実装されたストリームレベルのタグ付け API とは異なります。

ストリーミングメタデータ APIメタデータストリーミングを実装するために、プロデューサー SDK で以下のオペレーションを利用できます。

PIC

PUBLIC_API STATUS putKinesisVideoFragmentMetadata(STREAM_HANDLE streamHandle, PCHAR name, PCHAR value,

16

Page 23: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドKinesis ビデオストリームに埋め込まれたメタデータを使用する

BOOL persistent);

C++ プロデューサー SDK

/** * Appends a "tag" or metadata - a key/value string pair into the stream. */bool putFragmentMetadata(const std::string& name, const std::string& value, bool persistent = true);

Java プロデューサー SDKJava プロデューサー SDK を使用する場合、MediaSourceSink.onCodecPrivateData を使用してMediaSource をメタデータに 追加します。

void onFragmentMetadata(final @Nonnull String metadataName, final @Nonnull String metadataValue, final boolean persistent)throws KinesisVideoException;

永続的および非永続的メタデータ非永続メタデータでは、同一の名前を使ったメタデータ項目を複数追加できます。プロデューサー SDKは、次のフラグメントにメタデータ項目が先頭に追加されるまで、メタデータキュー内でメタデータ項目を収集します。メタデータキューはストリームにメタデータ項目が適用されるとクリアされます。メタデータを繰り返すには、putKinesisVideoFragmentMetadata または putFragmentMetadata を再度呼び出します。

永続的なメタデータでは、プロデューサー SDK は、非永続メタデータと同様な方法で、メタデータキュー内のメタデータ項目を収集します。ただし、メタデータ項目は、次のフラグメントの先頭に追加された時に、キューから削除されません。

putKinesisVideoFragmentMetadata または putFragmentMetadata で persistent を true に設定して呼び出すと、以下のような動作になります。

• API を呼び出すと、キューにメタデータ項目が追加されます。メタデータは、メタデータ項目がキュー内にある間に、フラグメントごとに MKV タグとして追加されます。

• 同一の名前で、以前に追加されたメタデータ項目と異なる値で API を呼び出すと、その項目は上書きされます。

• 空の値で API を呼び出すと、メタデータキューからそのメタデータ項目は削除 (キャンセル) されます。

Kinesis ビデオストリームに埋め込まれたメタデータを使用するKinesis ビデオストリーム 内のメタデータを使用するには、MkvTagProcessor の実装を使用します。

public interface MkvTagProcessor { default void process(MkvTag mkvTag, Optional<FragmentMetadata> currentFragmentMetadata) { throw new NotImplementedException("Default FragmentMetadataVisitor.MkvTagProcessor"); } default void clear() { throw new NotImplementedException("Default FragmentMetadataVisitor.MkvTagProcessor"); }

17

Page 24: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドストリーミングメタデータの制限事項

}}

このインターフェイスは、Kinesis ビデオストリームパーサーライブラリ (p. 128) のFragmentMetadataVisitor (p. 130) クラスにあります。

FragmentMetadataVisitor クラスには MkvTagProcessor の実装が含まれます。

public static final class BasicMkvTagProcessor implements FragmentMetadataVisitor.MkvTagProcessor { @Getter private List<MkvTag> tags = new ArrayList<>();

@Override public void process(MkvTag mkvTag, Optional<FragmentMetadata> currentFragmentMetadata) { tags.add(mkvTag); } @Override public void clear() { tags.clear(); }}

KinesisVideoRendererExample クラスには、BasicMkvTagProcessor の使用例があります。以下の例では、BasicMkvTagProcessor があるアプリケーションの MediaProcessingArguments に追加されます。

if (renderFragmentMetadata) { getMediaProcessingArguments = KinesisVideoRendererExample.GetMediaProcessingArguments.create( Optional.of(new FragmentMetadataVisitor.BasicMkvTagProcessor()));

BasicMkvTagProcessor.process メソッドは、フラグメントのメタデータが到着すると呼び出されます。蓄積されたメタデータは GetTags を使って取得できます。1 つのメタデータ項目を取得する場合は、最初に収集したメタデータをクリアするために clear を呼び出し、再度メタデータ項目を取得します。

ストリーミングメタデータの制限事項Kinesis ビデオストリーム へのストリーミングメタデータの追加には、以下の制限事項が適用されます。

• フラグメントの先頭には 10 個までメタデータ項目を追加できます。• フラグメントのメタデータの名前の長さは、最大 128 バイトです。• フラグメントのメタデータの値の長さは、最大 256 バイトです。• フラグメントのメタデータの名前を「AWS」で始めることはできません。そのようなメタデータ項目が

追加された場合は、PIC の putFragmentMetadata メソッドは STATUS_INVALID_METADATA_NAMEエラー (エラーコード: 0x52000077) を返します。アプリケーションは、エラーを無視する (PIC はメタデータ項目を追加しません) か、エラーに対応します。

Kinesis ビデオストリーム データモデルプロデューサーライブラリ (p. 47) および ストリームパーサーライブラリ (p. 128) は、動画データに伴う情報の埋め込みをサポートする形式で動画データを送受信します。この形式は Matroska (MKV) 仕様に基づいています。

18

Page 25: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドストリームヘッダー要素

MKV 形式は、メディアデータに対するオープン仕様です。Amazon Kinesis ビデオストリーム 開発者ガイド 内のすべてのライブラリおよびコード例は、MKV 形式でデータを送受信します。

Kinesis ビデオストリーム プロデューサーライブラリ (p. 47) は StreamDefinition および Frame タイプを使用して MKV ストリームヘッダー、フレームヘッダー、フレームデータを作成します。

MKV 仕様の詳細については「Matroska Specification」を参照してください。

以下のセクションでは、C++ プロデューサーライブラリ (p. 57) によって作成された MKV 形式データのコンポーネントについて説明します。

トピック• ストリームヘッダー要素 (p. 19)• トラックデータのストリーミング (p. 22)• フレームヘッダー要素 (p. 23)• MKV フレームデータ (p. 23)

ストリームヘッダー要素StreamDefinition では次の MKV ヘッダー要素が使用されます (StreamDefinition.h で定義)。

要素 説明 一般的な値

stream_name Kinesis ビデオストリーム の名前に対応しています。

my-stream

retention_period ストリームデータが Kinesis ビデオストリーム によって保持される期間。データを保持しないストリーム 0 を指定します。

24

タグ ユーザーデータのキーと値のコレクション。このデータは AWSマネジメントコンソール に表示され、クライアントアプリケーションにより読み取ることでストリームに関する情報をフィルタリングまたは取得できます。

 

kms_key_id 存在する場合、ストリーム上のデータの暗号化に使用されるユーザー定義の AWS KMS マスターキー。存在しない場合、データは Kinesis が提供するマスターキーで暗号化されます(aws/kinesis-video)。

01234567-89ab-cdef-0123-456789ab

streaming_type 現在、有効なストリーミングタイプはSTREAMING_TYPE_REALTIMEのみです。

STREAMING_TYPE_REALTIME

content_type ユーザー定義のコンテンツタイプ。動画データをストリーミングしてコンソールで再生する場

video/h264

19

Page 26: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドストリームヘッダー要素

要素 説明 一般的な値合、コンテンツタイプは video/h264 である必要があります。

max_latency この値は現在使用されておらず、0 に設定する必要があります。

0

fragment_duration フラグメントの継続時間 (推定)。この時間が最適化に使用されます。実際のフラグメント継続時間は、ストリーミングデータによって決定します。

2

timecode_scale フレームタイムスタンプが使用するスケールを示します。デフォルト値は 1 ミリ秒です。0を指定すると、デフォルト値の1 ミリ秒も割り当てられます。この値は 100 ナノ秒~1 秒の範囲で指定できます。

詳細については、Matroska のドキュメントの「TimecodeScale」を参照してください。

key_frame_fragmentation true の場合、ストリームはキーフレームが受信された場合に新たなクラスターを開始します。

true

frame_timecodes true の場合、Kinesis ビデオストリーム は受信された場合にフレームをスタンプします。false の場合、Kinesis ビデオストリーム は受信したフレームのデコード時間を使用します。

true

absolute_fragment_time true の場合、クラスタータイムコードは絶対時間 (プロデューサーのシステムクロックなど) を用いて解釈されます。false の場合、クラスタータイムコードはストリームの開始時刻の相対値として解釈されます。

true

fragment_acks true の場合、Kinesis ビデオストリーム がデータを受信した際に確認 (ACK)が送信されます。ACK はKinesisVideoStreamFragmentAckまたはKinesisVideoStreamParseFragmentAckコールバックを用いて受信できます。

true

20

Page 27: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドストリームヘッダー要素

要素 説明 一般的な値

restart_on_error ストリームのエラーが発生した後、ストリームが送信を再開すべきかどうかを示します。

true

nal_adaptation_flags コンテンツ内に NAL (NetworkAbstraction Layer) 適応またはコーデックプライベートデータが含まれるかどうかを示します。有効なフラグにはNAL_ADAPTATION_ANNEXB_NALSおよびNAL_ADAPTATION_ANNEXB_CPD_NALSが含まれます。

NAL_ADAPTATION_ANNEXB_NALS

frame_rate コンテンツの推定フレームレート。この値は最適化に使用され、実際のフレームレートは受信データのレートにより決定されます。0 を指定すると、デフォルトの 24 が割り当てられます。

24

avg_bandwidth_bps コンテンツの推定帯域幅。この値は最適化に使用され、実際のレートは受信データの帯域幅により決定されます。たとえば、25 FPS で動作する 720pの解像度のビデオストリームでは、平均 5 Mbps の帯域幅を期待できます。

5

buffer_duration コンテンツがプロデューサー上でバッファされる時間。ネットワークレイテンシーが低い場合はこの値を減らすことができます。ネットワークレイテンシーが高い場合は、この値を増やすことで、割り当てによりフレームをより小さいバッファに入れることができないためにフレームが送信前にドロップするのを回避できます。

replay_duration 接続が失われた場合、動画データストリームが「巻き戻し」を行う時間量。接続損失によるロストフレームが懸念されない場合はこの値を 0 に設定できます。受信側アプリケーションが冗長フレームを排除できる場合は、この値を増やすことができます。この値はバッファ期間より小さくする必要があります。それ以外の場合、バッファ期間が使用されます。

21

Page 28: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドトラックデータのストリーミング

要素 説明 一般的な値

connection_staleness データが受信されない場合に接続を維持する期間。

codec_id コンテンツで使用されるコーデック。詳細情報についてはMatroska 仕様の「CodecID」を参照してください。

V_MPEG2

track_name ユーザー定義のトラック名。 my_track

codecPrivateData 多くのダウンストリームコンシューマーにおいて必要となる、フレームデータのデコードのためにエンコーダーが提供するデータ (ピクセル単位でのフレーム幅および高さなど)。C++ プロデューサーライブラリ (p. 57)では、MkvStatics.cpp 内のgMkvTrackVideoBits 配列にはフレームのピクセル幅および高さが含まれます。

codecPrivateDataSize codecPrivateData パラメータのデータのサイズ。

track_type ストリームのトラックのタイプ。

MKV_TRACK_INFO_TYPE_AUDIOまたはMKV_TRACK_INFO_TYPE_VIDEO

segment_uuid ユーザー定義のセグメント uuid(16 バイト)。

 

default_track_id トラックの、一意のゼロ以外の数。

1

トラックデータのストリーミングStreamDefinition では次の MKV トラック要素が使用されます (StreamDefinition.h で定義)。

要素 説明 一般的な値

track_name ユーザー定義のトラック名。たとえば、オーディオトラック用の「audio」。

audio

codec_id トラック用のコーデック ID。たとえば、オーディオトラック用の「A_AAC」。

A_AAC

cpd フレームデータのデコードのためにエンコーダーが提供するデータ。このデータには、フレームの幅と高さ (ピクセル単位)を含めることができます。この

 

22

Page 29: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドフレームヘッダー要素

要素 説明 一般的な値情報は多くのダウンストリームコンシューマーで必要となります。C++ プロデューサーライブラリでは、MkvStatics.cpp 内のgMkvTrackVideoBits 配列にはフレームのピクセル幅および高さが含まれます。

cpd_size codecPrivateData パラメータのデータサイズ。

 

track_type トラックのタイプ。たとえば、オーディオ用のMKV_TRACK_INFO_TYPE_AUDIOの列挙値を使用できます。

MKV_TRACK_INFO_TYPE_AUDIO

フレームヘッダー要素Frame では次の MKV ヘッダー要素が使用されます (mkvgen/Include.h の KinesisVideoPic パッケージで定義)。

• Frame Index: 一定間隔で増加する値.• Flags: フレームのタイプ。有効な値には次のようなものがあります。

• FRAME_FLAGS_NONE

• FRAME_FLAG_KEY_FRAME: key_frame_fragmentation がストリーム上で設定されている場合、キーフレームは新たなフラグメントを開始します。

• FRAME_FLAG_DISCARDABLE_FRAME: デコーダーに対し、デコーディングが遅い場合はこのフレームを破棄できることを通知します。

• FRAME_FLAG_INVISIBLE_FRAME: このブロックの時間は 0 です。• Decoding Timestamp: このフレームがデコードされたときのタイムスタンプ。以前のフレームのデコー

ディングがこのフレームに依存している場合、このタイムスタンプは以前のフレームよりも前に設定できます。この値はフラグメントの開始の相対値です。

• Presentation Timestamp: このフレームが表示されたときのタイムスタンプ。この値はフラグメントの開始の相対値です。

• Duration: フレームの再生時間。• Size: フレームデータのサイズ (バイト単位)

MKV フレームデータframe.frameData 内のデータには、使用されるエンコーディングスキーマに応じ、フレームのメディアデータのみが含まれている場合、あるいはさらにネスト化されたヘッダー情報が含まれている場合があります。AWS マネジメントコンソール に表示させるには、H.264 コーデックでデータをエンコードする必要がありますが、Kinesis ビデオストリーム は時間に応じてシリアル化したあらゆる形式のデータストリームを受信できます。

23

Page 30: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドステップ 1: アカウントを設定する

Kinesis ビデオストリーム の使用開始このセクションでは、Amazon Kinesis ビデオストリーム で次のタスクを実行する方法を説明します。

• まだ完了していない場合に、AWS アカウントをセットアップし、管理者を作成します。• Kinesis ビデオストリーム を作成します。• カメラから Kinesis ビデオストリーム にデータを送信し、コンソールでそのメディアを表示します。

Amazon Kinesis ビデオストリーム を初めて使用する場合は、まず「Amazon Kinesis ビデオストリーム:仕組み (p. 5)」を読むことをお勧めします。

Note

以下の使用開始の例に従っても、AWS アカウントに料金は発生しません。ご使用のリージョンのデータコストについては、「Amazon Kinesis ビデオストリーム 料金表」を参照してください。

トピック• ステップ 1: AWS アカウントを設定して管理者を作成する (p. 24)• ステップ 2: Kinesis ビデオストリームを作成する (p. 25)• ステップ 3: Kinesis ビデオストリームにデータを送信する (p. 26)• 次のステップ (p. 29)

ステップ 1: AWS アカウントを設定して管理者を作成する

Kinesis ビデオストリーム を初めて使用する場合は、事前に以下のタスクをすべて実行してください。

1. AWS へのサインアップ (p. 24) (アカウントをすでにお持ちでない場合)2. IAM ユーザー管理者の作成 (p. 25)3. AWS アカウントキーを作成する (p. 25)

AWS へのサインアップAWS アカウントが既にある場合、このステップは省略できます。

Amazon Web Services (AWS) にサインアップすると、AWS アカウントは自動的に Kinesis ビデオストリーム など AWS のすべてのサービスにサインアップします。Kinesis ビデオストリーム を使用すると、このサービスに取り込まれ、保存され、消費されたデータ量に基づいて課金されます。AWS の新規のお客様の場合、Kinesis ビデオストリーム を無料で使い始めることができます。詳細については、「AWS 無料利用枠」を参照してください。

AWS アカウントを作成するには

1. https://portal.aws.amazon.com/billing/signup を開きます。2. オンラインの手順に従います。

サインアップ手順の一環として、通話呼び出しを受け取り、電話のキーパッドを用いて確認コードを入力することが求められます。

AWS アカウント ID を書き留めてください。次のタスクで必要となります。

24

Page 31: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドIAM ユーザー管理者の作成

IAM ユーザー管理者の作成AWS にサインアップするときには、AWS アカウントに関連付けられた E メールアドレスとパスワードを提供します。これは AWS アカウントのルートユーザーです。この認証情報はすべての AWS リソースに対する完全なアクセスを提供します。

Note

セキュリティ上の理由から、AWS アカウントへの完全なアクセス権限を持つ管理者 (IAM ユーザー) を作成するためにのみ、ルートユーザーを使用することをお勧めします。その後、この管理者を使用して、制限されたアクセス権限を持つ他の IAM ユーザーとロールを作成できます。詳細については、IAM ユーザーガイドで「IAM ベストプラクティス」および「管理者のユーザーおよびグループの作成」を参照してください。

管理者を作成し、コンソールにサインインするには

1. AWS アカウントで管理者を作成します。手順については、IAM ユーザーガイドの「初めての IAMユーザーと管理者グループの作成」を参照してください。

2. 管理者として、特別 URL を使用してコンソールにサインインできます。詳細については、IAM ユーザーガイドの「ユーザーがアカウントにサインインする方法」を参照してください。

管理者はこのアカウントに他のユーザーを作成できます。IAM ユーザーはデフォルトでアクセス権限を持ちません。管理者は、ユーザーを作成してそのアクセス権限を管理できます。詳細については、「最初のIAM ユーザーと管理者グループの作成」を参照してください。

IAM の詳細については、以下を参照してください。

• AWS Identity and Access Management (IAM)• はじめに• IAM ユーザーガイド

AWS アカウントキーを作成するKinesis ビデオストリーム にプログラムでアクセスするには、AWS アカウントキーが必要です。

AWS アカウントキーを作成するには、以下の操作を行います。

1. AWS マネジメントコンソール にサインインし、IAM コンソール(https://console.aws.amazon.com/iam/)を開きます。

2. ナビゲーションバーの [ユーザー] を選択後、[管理者] ユーザーを選択します。3. [セキュリティ認証情報] タブを選択し、[アクセスキーの作成] を選択します。4. [アクセスキー ID] を記録します。[シークレットアクセスキー] の [表示] を選択します。[シークレット

アクセスキー] を記録します。

次のステップステップ 2: Kinesis ビデオストリームを作成する (p. 25)

ステップ 2: Kinesis ビデオストリームを作成するこのセクションでは、Kinesis ビデオストリームの作成方法について説明します。

このセクションでは、次の手順を紹介します。

25

Page 32: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドコンソールを使用してビデオストリームを作成するには

• the section called “コンソールを使用してビデオストリームを作成するには” (p. 26)• the section called “AWS CLI を使用したビデオストリームの作成” (p. 26)

コンソールを使用してビデオストリームを作成するには1. AWS マネジメントコンソールにサインインして、https://console.aws.amazon.com/kinesis で Kinesis

コンソールを開きます。2. [Video streams (ビデオストリーム)] ページで、[Create video stream (ビデオストリームの作成)] を選

択します。3. [Create a new video stream (新しいビデオストリームの作成)] ページで、ストリーム名として

ExampleStream を入力します。[デフォルト設定] ラジオボタンは選択したままにします。4. [Create video stream (ビデオストリームの作成)] を選択します。5. Kinesis ビデオストリーム でストリームを作成した後、[ExampleStream] ページで詳細を確認しま

す。

AWS CLI を使用したビデオストリームの作成1. AWS CLI がインストールされ、設定されていることを確認します。詳細については、AWS コマンド

ラインインターフェイスドキュメントを参照してください。2. AWS CLI で、次の Create-Stream コマンドを実行します。

$ aws kinesisvideo create-stream --stream-name "MyKVStream" --data-retention-in-hours "24"

レスポンスは次のようになります。

{ "StreamARN": "arn:aws:kinesisvideo:us-west-2:123456789012:stream/MyKVSStream/123456789012"}

次のステップステップ 3: Kinesis ビデオストリームにデータを送信する (p. 26)

ステップ 3: Kinesis ビデオストリームにデータを送信する

このセクションでは、カメラから、以前のステップで作成した Kinesis ビデオストリーム にメディアデータを送信する方法について説明します。このセクションでは、C++ プロデューサーライブラリ (p. 57)を GStreamer (p. 137) プラグインとして使用します。

各オペレーティングシステムの各デバイスからメディアを簡単に送信するために、このチュートリアルでは、カメラなどのメディアソースへのアクセスを標準化するオープンソースのメディアフレームワークである、GStreamer を使用します。

26

Page 33: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドC++ プロデューサー SDK をダウンロードする

GStreamer のサンプルアプリケーションは次のオペレーティングシステムでサポートされています。

• Ubuntu• macOS• Microsoft Windows• Raspbian (Raspberry Pi)

GStreamer プラグインを使用した、ファイルからのビデオのストリーミング、またはカメラの RTSPストリームについては、「例: Kinesis ビデオストリーム プロデューサー SDK GStreamer プラグイン (p. 137)」を参照してください。

C++ プロデューサー SDK をダウンロードするGStreamer のサンプルは、C++ プロデューサー SDK に同梱されています。C++ Producer SDK は、次のGit コマンドを使用して Github からダウンロードできます。

$ git clone https://github.com/awslabs/amazon-kinesis-video-streams-producer-sdk-cpp

SDK の前提条件およびダウンロードの詳細については、「ステップ 1: C++ プロデューサーライブラリコードをダウンロードして設定する (p. 60)」を参照してください。

GStreamer サンプルのコンパイルGStreamer サンプルをコンパイルし、 kinesis-video-native-build ディレクトリにインストールするには、次のコマンドを使用します。

• macOS:• Homebrew をインストールします• brew install pkg-config openssl cmake gstreamer gst-plugins-base gst-plugins-good gst-plugins-bad gst-plugins-ugly log4cplus を実行します

• kinesis-video-native-build ディレクトリに移動し、./min-install-script を実行します• Ubuntu および Raspbian:

• 下記を実行します。• $ sudo apt-get update

• $ sudo apt-get install libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev gstreamer1.0-plugins-base-apps

• $ sudo apt-get install gstreamer1.0-plugins-bad gstreamer1.0-plugins-goodgstreamer1.0-plugins-ugly gstreamer1.0-tools

• Raspbian の場合、上記コマンドの実行後に $ sudo apt-get install gstreamer1.0-omx を実行します。

• kinesis-video-native-build ディレクトリに移動し、./min-install-script を実行します• Windows:

• mingw32 または mingw64 シェル内で kinesis-video-native-build ディレクトリに移動し、./min-install-script を実行します

GStreamer サンプルの実行メディアは、GStreamer アプリケーションによって、カメラから Kinesis ビデオストリーム サービスに送信されます。GStreamer サンプルアプリケーションは、お使いのオペレーティングシステムで次のコマンドを使用して実行できます。kinesis-video-native-build/downloads/local/bin ディレクトリのサンプルアプリケーションを実行します。コマンドで、以下のパラメータを使用します。

27

Page 34: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドメディアデータの使用

• アクセスキー: このチュートリアルの最初のステップで記録した AWS アクセスキー。• シークレットキー: このチュートリアルの最初のステップで記録した AWS シークレットキー。• AWS リージョン: Kinesis ビデオストリーム をサポートするリージョン。サポートされているリージョ

ンについては、「Amazon Kinesis Video Streams のリージョン」を参照してください。

Ubuntu での GStreamer サンプルの実行Ubuntu 上の GStreamer サンプルアプリケーションを実行するには、次のコマンドを使用します。deviceパラメータを使用してカメラデバイスを指定します。

$ gst-launch-1.0 v4l2src device=/dev/video0 ! videoconvert ! video/x-raw,format=I420,width=640,height=480 ! x264enc bframes=0 key-int-max=45 bitrate=512 tune=zerolatency ! h264parse ! video/x-h264,stream-format=avc,alignment=au,profile=baseline ! kvssink stream-name="MyKinesisVideoStream" storage-size=512 access-key="YourAccessKey" secret-key="YourSecretKey" aws-region="YourAWSRegion"

macOS での GStreamer サンプルの実行MacOS 上の GStreamer サンプルアプリケーションを実行するには、次のコマンドを使用します。

$ gst-launch-1.0 autovideosrc ! videoconvert ! video/x-raw,format=I420,width=1280,height=720 ! vtenc_h264_hw allow-frame-reordering=FALSE realtime=TRUE max-keyframe-interval=45 bitrate=512 ! h264parse ! video/x-h264,stream-format=avc,alignment=au,profile=baseline ! kvssink stream-name=MyKinesisVideoStream storage-size=512 access-key="YourAccessKey" secret-key="YourSecretKey" aws-region="YourAWSRegion"

Windows での GStreamer サンプルの実行Windows 上の GStreamer サンプルアプリケーションを実行するには、次のコマンドを使用します。

$ gst-launch-1.0 ksvideosrc ! videoconvert ! video/x-raw,format=I420,width=640,height=480 ! x264enc bframes=0 key-int-max=45 bitrate=512 tune=zerolatency ! h264parse ! video/x-h264,stream-format=avc,alignment=au,profile=baseline ! kvssink stream-name="MyKinesisVideoStream" storage-size=512 access-key="YourAccessKey" secret-key="YourSecretKey" aws-region="YourAWSRegion"

Raspbian (Raspberry Pi) での GStreamer サンプルの実行Raspbian 上の GStreamer サンプルアプリケーションを実行するには、次のコマンドを使用します。device パラメータを使用してカメラデバイスを指定します。

$ gst-launch-1.0 v4l2src device=/dev/video0 ! videoconvert ! video/x-raw,format=I420,width=640,height=480 ! omxh264enc control-rate=2 target-bitrate=512000 periodicity-idr=45 inline-header=FALSE ! h264parse ! video/x-h264,stream-format=avc,alignment=au,profile=baseline ! kvssink stream-name="MyKinesisVideoStream" access-key="YourAccessKey" secret-key="YourSecretKey" aws-region="YourAWSRegion"

メディアデータの使用メディアデータを使用するには、コンソールでそのデータを表示するか、HLS を使用してストリームからメディアデータを読み込むアプリケーションを作成します。

28

Page 35: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイド次のステップ

コンソールでメディアデータを表示するカメラから送信されたメディアデータを Kinesis ビデオストリーム コンソールで表示するには、https://console.aws.amazon.com/kinesisvideo/ で Kinesis Video Streams コンソールを開き、「ストリームの管理」ページの [MyKinesisVideoStream] を選択します。動画が [Video Preview] ペインで再生されます。

HLS を使用したメディアデータの消費Kinesis ビデオストリーム からデータを使用するクライアントアプリケーションを作成するには、Hypertext Live Streaming (HLS) を使用します。HLS でメディアデータを使用するアプリケーションの作成方法については、「the section called “動画再生” (p. 9)」を参照してください。

次のステップ次のステップ (p. 29)

次のステップKinesis Video Streams に関する詳細については、次のトピックを参照してください。

• プロデューサーライブラリ (p. 47): Kinesis ビデオストリーム サービスへのメディアデータの送信に使用するクラスおよびメソッドについて説明します。

• ストリームパーサーライブラリ (p. 128): Kinesis ビデオストリーム からメディアデータを読み込み表示するアプリケーションの作成方法を説明します。

• RTSP および Docker (p. 149): ネットワーク (RTSP) カメラから Kinesis ビデオストリーム サービスにビデオをストリーミングする方法について説明します。

29

Page 36: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドデータ保護

Amazon Kinesis ビデオストリーム でのセキュリティ

AWS では、クラウドのセキュリティが最優先事項です。AWS のお客様は、セキュリティを最も重視する組織の要件を満たすよう構築されたデータセンターとネットワークアーキテクチャを利用できます。

セキュリティは、AWS とお客様の間の共有責任です。共有責任モデルでは、これをクラウドのセキュリティおよびクラウド内のセキュリティとして説明しています。

• クラウドのセキュリティ – AWS は、AWS クラウド内で AWS サービスを実行するインフラストラクチャを保護する責任を担います。また、AWS は、使用するサービスを安全に提供します。セキュリティの有効性は、AWS コンプライアンスプログラムの一環として、サードパーティーの監査が定期的にテストおよび検証されています。Kinesis ビデオストリーム に適用するコンプライアンスプログラムの詳細については、コンプライアンスプログラムによる AWS 対象範囲内のサービスを参照してください。

• クラウド内のセキュリティ – お客様の責任はお客様が使用する AWS のサービスによって決まります。また、お客様は、お客様のデータの機密性、組織の要件、および適用可能な法律および規制などの他の要因についても責任を担います。

このドキュメントは、Kinesis ビデオストリーム を使用する際に共有責任モデルを適用する方法を理解するのに役立ちます。以下のトピックでは、セキュリティおよびコンプライアンスの目的を達成するためにKinesis ビデオストリーム を設定する方法を示します。また、Kinesis ビデオストリーム リソースのモニタリングや保護に役立つ他の AWS サービスの用法についても説明します。

トピック• Kinesis ビデオストリーム でのデータ保護 (p. 30)• IAM により Kinesis ビデオストリーム リソースへのアクセスを制御する (p. 34)• AWS IoT により Kinesis ビデオストリーム リソースへのアクセスを制御する (p. 37)• Amazon Kinesis ビデオストリーム のモニタリング (p. 44)• Amazon Kinesis ビデオストリーム のコンプライアンス検証 (p. 44)• Amazon Kinesis ビデオストリーム の耐障害性 (p. 45)• Kinesis ビデオストリーム のインフラストラクチャセキュリティ (p. 45)• Kinesis ビデオストリーム のセキュリティベストプラクティス (p. 45)

Kinesis ビデオストリーム でのデータ保護AWS Key Management Service (AWS KMS) キーを使用してサーバー側の暗号化を行うことで、AmazonKinesis ビデオストリーム 内で保管中のデータを暗号化して、厳密なデータ管理要件を簡単に満たすことができます。

トピック• Kinesis ビデオストリーム 用のサーバー側の暗号化とは (p. 31)• コスト、リージョン、およびパフォーマンスに関する考慮事項 (p. 31)• サーバー側の暗号化の使用を開始する方法 (p. 32)• ユーザー生成 AWS KMS マスターキーの作成と使用 (p. 32)

30

Page 37: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドKinesis ビデオストリーム 用のサーバー側の暗号化とは

• ユーザー生成 AWS KMS マスターキーを使用するためのアクセス許可 (p. 32)

Kinesis ビデオストリーム 用のサーバー側の暗号化とはサーバー側の暗号化は、ユーザーが指定する AWS KMS カスタマーマスターキー (CMK) を使用して、保管中になる前にデータを自動的に暗号化する Kinesis ビデオストリーム の機能です。データは Kinesis ビデオストリーム ストリームストレージレイヤーに書き込まれる前に暗号化され、ストレージから取得された後で復号されます。その結果、Kinesis ビデオストリーム サービス内で保管中のデータは常に暗号化されます。

サーバー側の暗号化を使用すると、Kinesis ビデオストリーム プロデューサーとコンシューマーがマスターキーや暗号化オペレーションを管理する必要はありません。データ保持を有効にすると、データは Kinesis ビデオストリーム に出入りするときに自動的に暗号化されるため、保管中のデータは暗号化されます。AWS KMS では、サーバー側の暗号化機能で使用されるすべてのマスターキーが提供されます。AWS KMS により、AWS で管理される Kinesis ビデオストリーム 用の CMK、ユーザーが指定したAWS KMS CMK、または AWS KMS サービスにインポートされるマスターキーを簡単に使用できます。

コスト、リージョン、およびパフォーマンスに関する考慮事項サーバー側の暗号化を適用すると、AWS KMS API の使用状況とキーのコストが適用されます。カスタムAWS KMS マスターキーとは異なり、(Default) aws/kinesis-video カスタマーマスターキー (CMK)は無料で提供されています。ただし、引き続きユーザーに代わって Kinesis ビデオストリーム によって発生する API の使用料を支払う必要があります。

API 使用料は、カスタムのものを含めて、すべての CMK に適用されます。各ユーザー認証情報には AWSKMS に対する独自の API コールが必要なため、KMS のコストは、ユーザーのデータプロデューサーおよびコンシューマーに対して使用するユーザー認証情報の数で増大します。

以下にリソース別の料金を示します。

キー

• AWS で管理される Kinesis ビデオストリーム 用の CMK (エイリアス =aws/kinesis-video) は無料です。

• ユーザーが生成した AWS KMS キーは、AWS KMS キー料金の対象となります。詳細については、「AWS Key Management Service の料金」を参照してください。

AWS KMS API の使用新しいデータ暗号化キーを生成する API リクエスト、または既存の暗号化キーを取得する API リクエストは、トラフィックと共に増加します。またこれらのリクエストは AWS KMS 使用料の対象となります。詳細については、「AWS Key Management Service の料金: 使用量」を参照してください。

Kinesis ビデオストリーム は、保持期間が「0」(保持期間なし) に設定されている場合でもキーリクエストを生成します。

リージョン別のサーバー側の暗号化の可用性Kinesis ビデオストリーム のサーバー側の暗号化は、Kinesis ビデオストリーム が使用可能な全 AWS リージョンで利用できます。

31

Page 38: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドサーバー側の暗号化の使用を開始する方法

サーバー側の暗号化の使用を開始する方法サーバー側の暗号化は Kinesis ビデオストリーム で常に有効化されています。ユーザー提供のキーが指定されていない場合は、ストリームが作成されると、Kinesis ビデオストリーム によって提供されるデフォルトのキーが使用されます。

ユーザーが提供する AWS KMS マスターキーは、作成時に Kinesis ビデオストリーム に割り当てる必要があります。後に UpdateStream API を使用して別のキーをストリームに割り当てることはできません。

ユーザー提供の AWS KMS マスターキーを Kinesis ビデオストリーム に割り当てるには、次の 2 つの方法を使用できます。

• Kinesis ビデオストリーム を AWS マネジメントコンソール で作成する際に、[Create a new videostream (新しいストリームの作成)] ページの [暗号化] タブで AWS KMS マスターキーを指定します。

• CreateStream API を使用して Kinesis ビデオストリーム を作成する際に、KmsKeyId パラメータでキーID を指定します。

ユーザー生成 AWS KMS マスターキーの作成と使用このセクションでは、Amazon Kinesis ビデオストリーム によって管理されるマスターキーを使用する代わりに、ユーザー独自の AWS KMS マスターキーを作成して使用する方法について説明します。

ユーザー生成 AWS KMS マスターキーの作成独自のマスターキーの作成方法の詳細については、AWS Key Management Service Developer Guideの「キーの作成」を参照してください。アカウントのキーを作成すると、Kinesis ビデオストリーム サービスは [KMS master key] リストにそれらのキーを返します。

ユーザー生成 AWS KMS マスターキーの使用正しいアクセス許可がコンシューマー、プロデューサー、および管理者に適用されたら、自分の AWS アカウントまたは他の AWS アカウントでカスタム AWS KMS マスターキーを使用できます。アカウントのすべての AWS KMS マスターキーは、コンソール内の [KMS Master Key] リストに表示されます。

別のアカウントにあるカスタム AWS KMS マスターキーを使用するには、それらのキーを使用するためのアクセス許可が必要です。また、CreateStream API を使用してストリームを作成する必要もあります。コンソールで作成されたストリームで、別のアカウントの AWS KMS マスターキーを使用することはできません。

Note

PutMedia または GetMedia オペレーションが実行されるまで、AWS KMS キーへのアクセスは行われません。その結果、次のことが起こります。

• 指定されたキーが存在しない場合、CreateStream オペレーションは成功しますが、ストリーム上の PutMedia および GetMedia オペレーションは失敗します。

• 提供されたマスターキー (aws/kinesis-video) を使用する場合、最初の PutMedia またはGetMedia オペレーションを実行するまでキーはアカウントに表示されません、

ユーザー生成 AWS KMS マスターキーを使用するためのアクセス許可ユーザー生成 AWS KMS マスターキーを使ってサーバー側の暗号化を使用する前に、ストリームの暗号化、およびストリームレコードの暗号化と復号を許可するように AWS KMS キーポリシーを設定する必要

32

Page 39: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドユーザー生成 AWS KMS マスターキーを使用するためのアクセス許可

があります。AWS KMS アクセス許可の例と詳細については、「AWS KMS API のアクセス権限: アクションとリソースのリファレンス」を参照してください。

Note

暗号化のためのデフォルトサービスキーの使用では、カスタム IAM アクセス許可の適用は必要ありません。

ユーザー生成 AWS KMS マスターキーを使用する前に、Kinesis ビデオストリーム プロデューサーおよびコンシューマー (IAM プリンシパル) が、AWS KMS マスターキーポリシーのユーザーであることを確認します。それ以外の場合、ストリームに対する読み取りと書き込みは失敗します。最終的は、データの損失、処理の遅延、またはアプリケーションのハングにつながる可能性があります。IAM ポリシーを使用して AWS KMS キーのアクセス許可を管理できます。詳細については、「AWS KMS での IAM ポリシーの使用」を参照してください。

プロデューサーのアクセス許可の例Kinesis ビデオストリーム プロデューサーには kms:GenerateDataKey アクセス許可が必要です。

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "kms:GenerateDataKey" ], "Resource": "arn:aws:kms:us-west-2:123456789012:key/1234abcd-12ab-34cd-56ef-1234567890ab" }, { "Effect": "Allow", "Action": [ "kinesis-video:PutMedia", ], "Resource": "arn:aws:kinesis-video:*:123456789012:MyStream" } ]}

コンシューマーのアクセス許可の例Kinesis ビデオストリーム コンシューマーには kms:Decrypt アクセス許可が必要です。

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "kms:Decrypt" ], "Resource": "arn:aws:kms:us-west-2:123456789012:key/1234abcd-12ab-34cd-56ef-1234567890ab" }, { "Effect": "Allow", "Action": [ "kinesis-video:GetMedia", ], "Resource": "arn:aws:kinesis-video:*:123456789012:MyStream"

33

Page 40: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドIAM により Kinesis ビデオストリーム リソースへのアクセスを制御する

} ]}

IAM により Kinesis ビデオストリーム リソースへのアクセスを制御する

AWS Identity and Access Management (IAM) と組み合わせて Amazon Kinesis ビデオストリーム を使用することにより、組織のユーザーが特定の Kinesis ビデオストリーム API オペレーションを使用してタスクを実行できるかどうか、また、特定の AWS リソースを使用できるかどうかを制御できます。

IAM の詳細については、以下を参照してください。

• AWS Identity and Access Management (IAM)• はじめに• IAM ユーザーガイド

内容• ポリシー構文 (p. 34)• Kinesis ビデオストリーム のアクション (p. 35)• Kinesis ビデオストリーム 用の Amazon リソースネーム(ARN) (p. 35)• 他の IAM アカウントに Kinesis ビデオストリームに対するアクセス許可を付与する (p. 35)• Kinesis ビデオストリーム のポリシー例 (p. 36)

ポリシー構文IAM ポリシーは 1 つ以上のステートメントで構成される JSON ドキュメントです。各ステートメントは次のように構成されます。

{ "Statement":[{ "Effect":"effect", "Action":"action", "Resource":"arn", "Condition":{ "condition":{ "key":"value" } } } ]}

ステートメントはさまざまなエレメントで構成されます。

• [Effect]: effect は、Allow または Deny にすることができます。デフォルトでは、IAM ユーザーはリソースおよび API アクションを使用するアクセス許可がないため、リクエストはすべて拒否されます。明示的な許可はデフォルトに優先します。明示的な拒否はすべての許可に優先します。

• [Action]: action は、アクセス許可を付与または拒否する対象とする、特定の API アクションです。• [Resource]: アクションによって影響を及ぼされるリソースです。ステートメント内でリソースを指定す

るには、Amazon リソースネーム(ARN)を使用する必要があります。

34

Page 41: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドKinesis ビデオストリーム のアクション

• [Condition]: condition はオプションです。ポリシーの発効条件を指定するために使用します。

IAM のポリシーを作成および管理するときは、IAM Policy Generator と IAM Policy Simulator を使用することもできます。

Kinesis ビデオストリーム のアクションIAM ポリシーステートメントで、IAM をサポートするすべてのサービスから任意の API アクションを指定できます。Kinesis ビデオストリーム の場合、API アクションの名前にプレフィックスとして kinesisvideo: を使用します。例:kinesisvideo:CreateStream、kinesisvideo:ListStreams、およびkinesisvideo:DescribeStream。

単一のステートメントに複数のアクションを指定するには、次のようにコンマで区切ります。

"Action": ["kinesisvideo:action1", "kinesisvideo:action2"]

ワイルドカードを使用して複数のアクションを指定することもできます。たとえば、「Get」という単語で始まる名前のすべてのアクションは、以下のように指定できます。

"Action": "kinesisvideo:Get*"

すべての Kinesis ビデオストリーム オペレーションを指定するには、次のようにアスタリスク (*) ワイルドカードを使用します。

"Action": "kinesisvideo:*"

Kinesis ビデオストリーム API の全アクションの一覧については、Kinesis ビデオストリーム API リファレンスを参照してください。

Kinesis ビデオストリーム 用の Amazon リソースネーム(ARN)各 IAM ポリシーステートメントは、ARN を使用して指定したリソースに適用されます。

Kinesis ビデオストリーム には、次の ARN リソース形式を使用します。

arn:aws:kinesisvideo:region:account-id:stream/stream-name/code

例:

"Resource": arn:aws:kinesisvideo::*:111122223333:stream/my-stream/0123456789012

ストリームの ARN は DescribeStream を使用することで取得できます。

他の IAM アカウントに Kinesis ビデオストリームに対するアクセス許可を付与するKinesis ビデオストリーム で操作を実行できるように、他の IAM アカウントにアクセス許可を付与する必要が生じる場合があります。次の概要では、アカウント間でビデオストリームへのアクセス許可を付与するための一般的なステップを説明します。

35

Page 42: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドポリシーの例

1. ストリームで操作を実行する権限を付与するアカウントの 12 桁の ID (例: 111111111111) を取得します。

2. 付与するアクセスレベルを許可するストリームを所有しているアカウントでマネージド型ポリシーを作成します。Kinesis ビデオストリーム リソースのポリシーの例については、次のセクションの「ポリシーの例 (p. 36)」を参照してください。

3. アクセス許可を付与するアカウントを指定してロールを作成し、前のステップで作成したポリシーをアタッチします。

4. AssumeRole アクションを許可するマネージド型ポリシーを前のステップで作成したロールに対して作成します。たとえば、ロールは次のようになります。

{ "Version": "2012-10-17", "Statement": { "Effect": "Allow", "Action": "sts:AssumeRole", "Resource": "arn:aws:iam::123456789012:role/CustomRole" }}

クロスアカウントのアクセス許可を付与する手順については、「AWS アカウント間の IAM ロールを使用したアクセスの委任」を参照してください。

Kinesis ビデオストリーム のポリシー例次のポリシーの例は、Kinesis ビデオストリーム へのユーザーアクセスの制御方法について説明しています。

Example 1: ユーザーが Kinesis ビデオストリーム からデータを取得できるようにする

このポリシーにより、ユーザーまたはグループは任意の Kinesis ビデオストリーム に対してDescribeStream、GetDataEndpoint、GetMedia、ListStreams、および ListTagsForStream の操作を実行できます。このポリシーは、任意のビデオストリームからデータを取得できるユーザーに適しています。

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "kinesisvideo:Describe*", "kinesisvideo:Get*", "kinesisvideo:List*" ], "Resource": "*" } ]}

Example 2: ユーザーに Kinesis ビデオストリーム の作成とデータの書き込みを許可する

このポリシーにより、ユーザーまたはグループは CreateStream および PutMedia の操作を実行できます。このポリシーは、ビデオストリームを作成し、それにデータを送信できる監視カメラに適しています。

{

36

Page 43: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAWS IoT により Kinesis ビデオスト

リーム リソースへのアクセスを制御する

"Statement": [ { "Effect": "Allow", "Action": [ "kinesisvideo:CreateStream", "kinesisvideo:PutMedia" ], "Resource": "*" } ]}

Example 3: すべての Kinesis ビデオストリーム リソースへのフルアクセスをユーザーに許可する

このポリシーにより、ユーザーまたはグループは任意のリソースに対して任意の Kinesis ビデオストリーム 操作を実行できます。このポリシーは、管理者に適しています。

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": "kinesisvideo:*", "Resource": "*" } ]}

Example 4: ユーザーに特定の Kinesis ビデオストリーム へのデータの書き込みを許可する

このポリシーにより、ユーザーまたはグループは特定のビデオストリームにデータを書き込むことができます。このポリシーは、1 つのストリームにデータを送信できるデバイスに適してします。

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": "kinesisvideo:PutMedia", "Resource": "arn:aws:kinesisvideo:us-west-2:123456789012:stream/your_stream/0123456789012" } ]}

AWS IoT により Kinesis ビデオストリーム リソースへのアクセスを制御する

このセクションでは、デバイス (カメラなど) が 1 つの特定の Kinesis 動画ストリームにのみ音声/動画データを送信できるようにする方法について説明します。これを行うには、AWS IoT 認証情報プロバイダーとAWS Identity and Access Management (IAM) ロールを使用します。

デバイスは、TLS 相互認証プロトコルを使用して AWS IoT に接続するために X.509 証明書を使用することができます。他の AWS のサービス (Kinesis Video Streams など) は証明書ベースの認証をサポートしていませんが、AWS 署名バージョン 4 形式の AWS 認証情報を使用して呼び出すことができます。証明書

37

Page 44: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドストリーム名としての IoT ThingName

バージョン 4 アルゴリズムは通常、発信者がアクセスキー ID およびシークレットアクセスキーを所持していることを要求します。AWS IoT には、ビルドインの X.509 証明書を一意のデバイス ID として AWSリクエスト (Kinesis Video Streams へのリクエストなど) を認証するために使用することを許可する認証情報プロバイダーがあります。これによって、デバイスにアクセスキー ID およびシークレットアクセスキーを保存する必要がなくなります。

認証情報プロバイダーは、X.509 証明書を使用してクライアント (この場合は、動画ストリームにデータを送信するカメラで実行されている Kinesis Video Streams SDK) を認証し、権限が制限された一時的なセキュリティトークンを発行します。トークンは、任意の AWS リクエスト (この場合は Kinesis VideoStreams への呼び出し) の署名と認証に使用できます。詳細については、「AWS サービスの直接呼び出しの承認」を参照してください。

Kinesis Video Streams に対するカメラのリクエストを認証するこの方法では、IAM ロールを作成して設定し、ロールに適切な IAM ポリシーをアタッチすることが必要となります。これによって、IoT 認証情報プロバイダーは、ユーザーに代わってロールを引き受けることができます。

AWS IoT の詳細については、AWS IoT Core のドキュメントを参照してください。IAM の詳細については、「AWS Identity and Access Management (IAM)」を参照してください。

トピック• ストリーム名としての IoT ThingName (p. 38)• ストリーム名としての IoT CertificateId (p. 43)

ストリーム名としての IoT ThingNameトピック

• ステップ 1: IoT モノのタイプと IoT モノを作成する (p. 38)• ステップ 2: IoT が引き受ける IAM ロールを作成する (p. 39)• ステップ 3: X.509 証明書を作成して設定する (p. 41)• ステップ 4: Kinesis 動画ストリームを使用して IoT 認証情報をテストする (p. 41)• ステップ 5: カメラのファイルシステムに IoT 証明書と認証情報をデプロイし、データを動画トリーム

にストリーミングする (p. 41)

ステップ 1: IoT モノのタイプと IoT モノを作成するIoT では、"モノ" とは特定のデバイスまたは論理エンティティを表します。この場合、IoT モノは、リソースレベルのアクセスコントロールを設定する Kinesis 動画ストリームを表します。モノを作成するには、まず IoT モノのタイプを作成する必要があります。IoT モノのタイプを使用すると、同じタイプに関連付けられているすべてのモノに共通した説明および設定情報を格納できます。

1. 次のコマンド例では、モノのタイプ kvs_example_camera が作成されます。

aws --profile default iot create-thing-type --thing-type-name kvs_example_camera > iot-thing-type.json

2. このコマンド例では、モノのタイプ kvs_example_camera のモノ kvs_example_camera_streamが作成されます。

aws --profile default iot create-thing --thing-name kvs_example_camera_stream --thing-type-name kvs_example_camera > iot-thing.json

38

Page 45: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドストリーム名としての IoT ThingName

ステップ 2: IoT が引き受ける IAM ロールを作成するIAM ロールは、ID が AWS でできることとできないことを決定するアクセス権限ポリシーを伴う AWS IDがロールであるという点で IAM ユーザーと似ています。ロールは、そのロールを必要とするどのユーザーでも引き受けることができます。ロールを引き受けると、ロールセッション用の一時的なセキュリティ認証情報が提供されます。

このステップで作成したロールは、クライアントから認証情報認証リクエストを実行するときにセキュリティトークンサービス (STS) から一時的な認証情報を取得するために IoT が引き受けることができます。この場合、クライアントは、カメラで実行されている Kinesis Video Streams SDK です。

この IAM ロールを作成して設定するには、以下のステップを実行します。

1. IAM ロールを作成します。

次のコマンド例では、 KVSCameraCertificateBasedIAMRoleという IAM ロールが作成されます。

aws --profile default iam create-role --role-name KVSCameraCertificateBasedIAMRole --assume-role-policy-document 'file://iam-policy-document.json' > iam-role.json

iam-policy-document.json には、次の信頼ポリシー JSON を使用できます。

{ "Version":"2012-10-17", "Statement":[ { "Effect":"Allow", "Principal":{ "Service":"credentials.iot.amazonaws.com" }, "Action":"sts:AssumeRole" } ]}

2. 次に、上記で作成した IAM ロールにアクセス権限ポリシーをアタッチする必要があります。このアクセス権限ポリシーにより、AWS リソースに対する選択的なアクセスコントロール (サポートされているオペレーションのサブセット) が可能になります。この場合、AWS リソースは、カメラによるデータの送信先とする動画ストリームです。つまり、すべての設定ステップが完了すると、このカメラはこの動画ストリームにのみデータを送信できるようになります。

aws --profile default iam put-role-policy --role-name KVSCameraCertificateBasedIAMRole --policy-name KVSCameraIAMPolicy --policy-document 'file://iam-permission-document.json'

iam-permission-document.json には、次の IAM ポリシー JSON を使用できます。

{ "Version": "2012-10-17", "Statement": [

39

Page 46: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドストリーム名としての IoT ThingName

{ "Effect": "Allow", "Action": [ "kinesisvideo:DescribeStream", "kinesisvideo:PutMedia", "kinesisvideo:TagStream", "kinesisvideo:GetDataEndpoint" ], "Resource": "arn:aws:kinesisvideo:*:*:stream/${credentials-iot:ThingName}/*" } ]}

このポリシーは、プレースホルダー (${credentials-iot:ThingName}) によって指定された動画ストリーム (AWS リソース) でのみ指定されたアクションを許可することに注意してください。このプレースホルダーには、IoT 認証情報プロバイダーがリクエストで動画ストリーム名を送信するときに、IoT モノ属性の値 ThingName が適用されます。

3. 次に、IAM ロールのロールエイリアスを作成します。ロールエイリアスは、IAM ロールをポイントする代替データモデルです。IoT 認証情報プロバイダーリクエストには、STS から一時的な認証情報を取得するために引き受ける IAM ロールを示すロールエイリアスを含める必要があります。

次のサンプルコマンドでは、KvsCameraIoTRoleAlias というロールエイリアスが作成されます。

aws --profile default iot create-role-alias --role-alias KvsCameraIoTRoleAlias --role-arn $(jq --raw-output '.Role.Arn' iam-role.json) --credential-duration-seconds 3600 > iot-role-alias.json

4. これで、IoT がロールエイリアスを使用して、証明書を持つ (アタッチされている場合) ロールを引き受けることができるようにするポリシーを作成できます。

次のサンプルコマンドでは、KvsCameraIoTPolicy という IoT のポリシーが作成されます。

aws --profile default iot create-policy --policy-name KvsCameraIoTPolicy --policy-document 'file://iot-policy-document.json'

次のコマンドを使用して、iot-policy-document.json ドキュメント JSON を作成できます。

cat > iot-policy-document.json <<EOF{ "Version":"2012-10-17", "Statement":[ { "Effect":"Allow", "Action":[ "iot:Connect" ], "Resource":"$(jq --raw-output '.roleAliasArn' iot-role-alias.json)" }, { "Effect":"Allow", "Action":[ "iot:AssumeRoleWithCertificate" ], "Resource":"$(jq --raw-output '.roleAliasArn' iot-role-alias.json)" } ]

40

Page 47: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドストリーム名としての IoT ThingName

}EOF

ステップ 3: X.509 証明書を作成して設定するデバイス (動画ストリーム) と AWS IoT との通信は X.509 証明書を使用して保護されます。

1. 上記で作成した IoT のポリシーをアタッチする必要がある証明書を作成します。

aws --profile default iot create-keys-and-certificate --set-as-active --certificate-pem-outfile certificate.pem --public-key-outfile public.pem.key --private-key-outfile private.pem.key > certificate

2. IoT のポリシー (上記で作成した KvsCameraIoTPolicy) をこの証明書にアタッチします。

aws --profile default iot attach-policy --policy-name KvsCameraIoTPolicy --target $(jq --raw-output '.certificateArn' certificate)

3. ここで作成した証明書に IoT モノ (kvs_example_camera_stream) をアタッチします。

aws --profile default iot attach-thing-principal --thing-name kvs_example_camera_stream --principal $(jq --raw-output '.certificateArn' certificate)

4. IoT 認証情報プロバイダーを通じてリクエストを承認するには、AWS アカウント ID に固有の IoT 認証情報エンドポイントが必要です。次のコマンドを使用して、IoT 認証情報エンドポイントを取得できます。

aws --profile default iot describe-endpoint --endpoint-type iot:CredentialProvider --output text > iot-credential-provider.txt

5. 上記で作成した X.509 証明書に加えて、TLS を通じてバックエンドサービスとの信頼を確立するための CA 証明書も必要です。CA 証明書は、次のコマンドを使用して取得できます。

curl --silent 'https://www.amazontrust.com/repository/SFSRootCAG2.pem' --output cacert.pem

ステップ 4: Kinesis 動画ストリームを使用して IoT 認証情報をテストするこれまでセットアップした IoT 認証情報をテストする準備ができました。

1. まず、この設定のテストに使用する Kinesis 動画ストリームを作成します。

41

Page 48: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドストリーム名としての IoT ThingName

Important

前のステップで作成した IoT モノの名前 (kvs_example_camera_stream) と同じ名前で動画ストリームを作成します。

aws kinesisvideo create-stream --data-retention-in-hours 24 --stream-name kvs_example_camera_stream

2. 次に、IoT 認証情報プロバイダーを呼び出して、一時的な認証情報を取得します。

curl --silent -H "x-amzn-iot-thingname:kvs_example_camera_stream" --cert certificate.pem --key private.pem.key https://IOT_GET_CREDENTIAL_ENDPOINT/role-aliases/KvsCameraIoTRoleAlias/credentials --cacert ./cacert.pem > token.json

Note

次のコマンドを使用して IOT_GET_CRENDETIAL_ENDPOINT を取得できます。

IOT_GET_CREDENTIAL_ENDPOINT=`cat iot-credential-provider.txt`

出力 JSON には、accessKey、secretKey、および sessionToken が含まれており、これらを使用してKinesis Video Streams にアクセスできます。

3. ここで、テスト用に、これらの認証情報を使用して、サンプル kvs_example_camera_stream 動画ストリームの Kinesis Video Streams DescribeStream API を呼び出すことができます。

AWS_ACCESS_KEY_ID=$(jq --raw-output '.credentials.accessKeyId' token.json) AWS_SECRET_ACCESS_KEY=$(jq --raw-output '.credentials.secretAccessKey' token.json) AWS_SESSION_TOKEN=$(jq --raw-output '.credentials.sessionToken' token.json) aws kinesisvideo describe-stream --stream-name kvs_example_camera_stream

ステップ 5: カメラのファイルシステムに IoT 証明書と認証情報をデプロイし、データを動画トリームにストリーミングする

Note

このセクションのステップでは、C++ プロデューサーライブラリを使用しているカメラからKinesis 動画ストリームにメディアを送信する方法について説明します。

1. X.509 証明書、プライベートキー、および上記のステップで生成された CA 証明書を、カメラのファイルシステムにコピーします。これらのファイルが保存される場所のパス、ロールエイリアス名、gst-launch-1.0 コマンドまたはサンプルアプリケーションを実行するための IOT 認証情報エンドポイントを指定する必要があります。

2. 以下のサンプルコマンドでは、IoT 証明書認証を使用して Kinesis Video Streams に動画を送信します。

42

Page 49: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドストリーム名としての IoT CertificateId

$ gst-launch-1.0 rtspsrc location=rtsp://YourCameraRtspUrl short-header=TRUE ! rtph264depay ! video/x-h264, format=avc,alignment=au ! h264parse ! kvssink stream-name="kvs_example_camera_stream" iot-certificate="iot-certificate,endpoint=iot-credential-endpoint-host-name,cert-path=/path/to/certificate.pem,key-path=/path/to/private.pem.key,ca-path=/path/to/cacert.pem,role-aliases=KvsCameraIoTRoleAlias"

ストリーム名としての IoT CertificateIdデバイス (カメラなど) を IoT のモノで表現する必要があるが、別のストリーム名を承認する必要がある場合は、ストリーム名として certifiacateId 属性を使用し、Kinesis Video Streams に IoT によるストリームに対するアクセス許可を付与できます。そのための手順は、上記で概説した手順と似ていますが、いくつかの変更があります。

• IAM ロール (iam-permission-document.json) のアクセス許可ポリシーを以下のように変更します。

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "kinesisvideo:DescribeStream", "kinesisvideo:PutMedia", "kinesisvideo:TagStream", "kinesisvideo:GetDataEndpoint" ], "Resource": "arn:aws:kinesisvideo:*:*:stream/${credentials-iot:AwsCertificateId}/*" } ]}

Note

リソース ARN では、ストリーム ID のプレースホルダーとして証明書 ID を使用します。ストリーム名として証明書 ID を使用すると、IAM のアクセス許可が機能します。証明書から証明書ID を取得し、以下の describe-stream API コールでストリーム名として使用します。

export CERTIFICATE_ID=`cat certificate | jq --raw-output '.certificateId'jq --raw-output '.certificateId'`

• Kinesis Video Streams の describe-stream CLI コマンドを使用して、この変更を確認します。

AWS_ACCESS_KEY_ID=$(jq --raw-output '.credentials.accessKeyId' token.json) AWS_SECRET_ACCESS_KEY=$(jq --raw-output '.credentials.secretAccessKey' token.json) AWS_SESSION_TOKEN=$(jq --raw-output '.credentials.sessionToken' token.json) aws kinesisvideo describe-stream --stream-name ${CERTIFICATE_ID}

• Kinesis Video Streams C++ SDK のサンプルアプリケーションで certificatId を IoT 認証情報プロバイダーに渡します。

43

Page 50: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドモニタリング

credential_provider = make_unique<IotCertCredentialProvider>(iot_get_credential_endpoint, cert_path, private_key_path, role_alias, ca_cert_path, certificateId);

Note

ThingName を IoT 認証情報プロバイダーに渡していることに注意してください。getenv を使用して、他の IoT 属性と同様に ThingName をデモアプリケーションに渡すことができます。サンプルアプリケーションを実行するときに、コマンドラインパラメータでストリーム名として証明書 ID を使用します。

Amazon Kinesis ビデオストリーム のモニタリングKinesis ビデオストリーム は、配信ストリームのモニタリング機能を備えています。詳細については、モニタリング (p. 159)を参照してください。

Amazon Kinesis ビデオストリーム のコンプライアンス検証

サードパーティーの監査者は、複数の Amazon Kinesis ビデオストリーム コンプライアンスプログラムの一環として AWS のセキュリティとコンプライアンスを評価します。このプログラムには、SOC、PCI、HIPAA などがあります。

特定のコンプライアンスプログラムの範囲内の AWS サービスのリストについては、「コンプライアンスプログラムによる AWS 対象範囲内のサービス」を参照してください。一般的な情報については、「AWSコンプライアンスプログラム」を参照してください。

サードパーティーの監査レポートをダウンロードするには、AWS Artifact を使用します。詳細については、「AWS Artifact のレポートのダウンロード」を参照してください。

Kinesis ビデオストリーム を使用する際のお客様のコンプライアンス責任は、お客様のデータの機密性や貴社のコンプライアンス目的、適用可能な法律および規制によって決定されます。Kinesis ビデオストリーム の使用が、HIPAA または PCI などの規格との適合を条件とする場合、AWS では、次の支援リソースを提供しています。

• セキュリティおよびコンプライアンスのクイックスタートガイド – これらのデプロイメントガイドでは、アーキテクチャ上の考慮事項について説明し、セキュリティとコンプライアンスに重点を置いたベースライン環境を AWS にデプロイするための手順を説明します。

• HIPAA のセキュリティとコンプライアンスに関するホワイトペーパーを作成する – このホワイトペーパーでは、企業が AWS を使用して HIPAA 準拠のアプリケーションを作成する方法について説明します。

• AWS コンプライアンスのリソース – お客様の業界や地域に当てはまる可能性のあるワークブックやガイドのコレクションです。

• AWS Config – お客様のリソース設定が、社内慣行、業界のガイドラインおよび各種規制にどの程度準拠しているか評価する AWS のサービスです。

• AWS Security Hub – この AWS のサービスは、AWS 内でのお客様のセキュリティ状態を総合的に把握するためのもので、セキュリティ業界における標準やベストプラクティスを遵守できているか確認するのに役立ちます。

44

Page 51: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイド耐障害性

Amazon Kinesis ビデオストリーム の耐障害性AWS のグローバルインフラストラクチャは AWS リージョンとアベイラビリティーゾーンを中心として構築されます。AWS リージョンには、低レイテンシー、高いスループット、そして高度の冗長ネットワークで接続されている複数の物理的に独立・隔離されたアベイラビリティーゾーンがあります。アベイラビリティーゾーンでは、アベイラビリティーゾーン間で中断することなく自動的にフェイルオーバーするアプリケーションとデータベースを設計および運用することができます。アベイラビリティーゾーンは、従来の単一または複数のデータセンターインフラストラクチャよりも可用性、耐障害性、および拡張性が優れています。

AWS リージョンとアベイラビリティーゾーンの詳細については、「AWS グローバルインフラストラクチャ」を参照してください。

Kinesis ビデオストリーム のインフラストラクチャセキュリティ

マネージド型サービスとして、Amazon Kinesis ビデオストリーム は、ホワイトペーパー「Amazon WebServices: AWS セキュリティプロセスの概要」に記載されているAWS グローバルネットワークセキュリティの手順で保護されています。

AWS が公開した API コールを使用して、ネットワーク経由で Kinesis ビデオストリーム にアクセスします。クライアントは、Transport Layer Security (TLS) 1.0 をサポートしていなければなりません。TLS1.2 以降が推奨されています。また、Ephemeral Diffie-Hellman (DHE) や Elliptic Curve Ephemeral Diffie-Hellman (ECDHE) などの Perfect Forward Secrecy (PFS) を使用した暗号スイートもクライアントでサポートされている必要があります。これらのモードは、Java 7 以降など、最近のほとんどのシステムでサポートされています。

また、リクエストは、アクセスキー ID と、IAM プリンシパルに関連付けられているシークレットのアクセスキーを使用して署名する必要があります。または、AWS Security Token Service (AWS STS) を使用して、一時的なセキュリティ認証情報を生成し、リクエストに署名することもできます。

Kinesis ビデオストリーム のセキュリティベストプラクティス

Amazon Kinesis ビデオストリーム では、お客様が独自のセキュリティポリシーを開発および実装するにあたって検討すべき数多くのセキュリティ機能を提供しています。以下のベストプラクティスは一般的なガイドラインであり、完全なセキュリティソリューションに相当するものではありません。下記のベストプラクティスは、お客様の環境に適切または十分でない場合もあるため、規範としてではなく、検討に役立つ情報としてご活用ください。

お客様のリモートデバイスのセキュリティベストプラクティスについては、デバイスエージェントのセキュリティベストプラクティスを参照してください。

最小特権アクセスの実装アクセス権限を付与する場合、どのユーザーにどの Kinesis ビデオストリーム リソースへのアクセス権限を付与するかは、お客様が決定します。つまり、該当リソースに対して許可する特定のアクションを有効にするということです。このため、タスクの実行に必要なアクセス許可のみを付与する必要があります。最小特権アクセスの実装は、セキュリティリスクはもちろん、エラーや悪意ある行動によってもたらされる可能性のある影響を減らすうえでの基本となります。

45

Page 52: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドIAM ロールの使用

たとえば、Kinesis ビデオストリーム にデータを送るプロデューサーに必要なのは、PutMedia、GetStreamingEndpoint および DescribeStream のみです。このため、すべてのアクション (*) や GetMedia などの他のアクションに必要なアクセス権限を、プロデューサーアプリケーションに付与しないでください。

詳細については、What Is Least Privilege & Why Do You Need It?を参照してください。

IAM ロールの使用プロデューサーおよびクライアントアプリケーションが Kinesis ビデオストリームにアクセスするには、有効な認証情報が必要です。AWS 認証情報を、クライアントアプリケーションまたは Amazon S3 バケットに直接保存しないでください。AWS 認証情報は、自動更新されない長期認証情報のため、漏洩すると業務に深刻な悪影響が及ぶ可能性があります。

このため、プロデューサーおよびクライアントアプリケーションが Kinesis ビデオストリームにアクセスするために必要となる一時的な認証情報は、IAM ロールを使用して管理してください。ロールを使用すれば、他のリソースにアクセスするために長期認証情報 (ユーザー名とパスワード、またはアクセスキーなど) を使わずに済みます。

詳細については、IAM ユーザーガイドにある下記のトピックを参照してください。

• IAM ロール• ロールの一般的なシナリオ: ユーザー、アプリケーション、およびサービス

CloudTrail を使った API コールのモニタリングKinesis ビデオストリーム は、ユーザー、ロールまたは Kinesis ビデオストリーム の AWS のサービスが実行したアクションを記録するサービスである AWS CloudTrail と統合されています。

CloudTrail が収集した情報を使用すると、Kinesis ビデオストリーム に対するリクエストの内容、リクエスト元の IP アドレス、リクエスト者、リクエスト日時および他の詳細を確認できます。

詳細については、「the section called “CloudTrail を使用した API コールのログ作成” (p. 170)」を参照してください。

46

Page 53: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドKinesis ビデオストリーム プロデューサークライアント

Kinesis ビデオストリーム プロデューサーライブラリ

Amazon Kinesis ビデオストリーム プロデューサーライブラリは、Kinesis ビデオストリーム プロデューサー SDK の一部である一連の使いやすいライブラリです。クライアントはこのライブラリと SDK を使用して、Kinesis ビデオストリーム に安全に接続してコンソールやクライアントアプリケーションでリアルタイムで視聴できるビデオなどのメディアデータをストリーミングするためのアプリケーションをデバイス上に構築します。

メディアデータは次の方法でストリーミングできます。

• リアルタイムのメディアデータストリーミング• 数秒間バッファ後のメディアデータのストリーミング• 事後メディアアップロードのストリーミング

Kinesis ビデオストリーム ストリームの作成後、ストリームにデータの送信を開始できます。SDK を使用してメディアソースからビデオデータ (フレーム) を抽出するアプリケーションコードを作成し、それをKinesis ビデオストリーム にアップロードできます。これらのアプリケーションは プロデューサーアプリケーションとも呼ばれます。

プロデューサーライブラリには以下のコンポーネントが含まれています。

• Kinesis ビデオストリーム プロデューサークライアント (p. 47)• Kinesis ビデオストリーム Producer Library (p. 48)

Kinesis ビデオストリーム プロデューサークライアント

Kinesis ビデオストリーム プロデューサークライアントには、単一の KinesisVideoClient クラスが含まれています。このクラスは、メディアソースの管理、ソースからのデータの受信、メディアソースから Kinesis ビデオストリーム へのデータフローとしてのストリーミングのライフサイクルの管理を行います。また、Kinesis ビデオストリーム とユーザーのハードウェアおよびソフトウェア間の相互関係を定義するための MediaSource インターフェイスも提供します。

メディアソースはほぼすべてが対象となります。たとえば、カメラのメディアソースまたはマイクのメディアソースを使用できます。メディアソースはオーディオやビデオソースのみには限定されません。たとえば、データログがテキストファイルの場合でも、データのストリームとして送信できます。また、スマートフォンで複数のカメラから同時にデータをストリームすることもできます。

そのほかのソースからデータを取得するには、MediaSource インターフェイスを実装できます。このインターフェイスでは追加のシナリオが可能ですが、ビルトインサポートは提供されません。たとえば、次のようなものを Kinesis ビデオストリーム に送信する選択ができます。

• 診断データストリーム (アプリケーションログとイベントなど)

47

Page 54: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドKinesis ビデオストリーム Producer Library

• 赤外線カメラ、RADAR あるいは深度カメラからのデータ

Kinesis ビデオストリーム はカメラなどのメディアを生成するデバイスにビルトイン実装を提供しません。このようなデバイスからデータを摘出するには、カスタムのメディアソース実装によるコードを実装する必要があります。これで、データを Kinesis ビデオストリーム にアップロードするKinesisVideoClient を使用してカスタムメディアソースを明示的に登録できます。

現在、Kinesis ビデオストリーム プロデューサークライアントは、Java および Android アプリケーションで利用できます。詳細については、「Java プロデューサーライブラリを使用する (p. 48)」および「Android プロデューサーライブラリを使用する (p. 52)」を参照してください。

Kinesis ビデオストリーム Producer LibraryKinesis ビデオストリーム プロデューサーライブラリは、Kinesis ビデオストリーム プロデューサークライアントに含まれています。このライブラリは、Kinesis ビデオストリーム と密接に統合することを希望するユーザーが直接使用するためにも利用できます。これにより、独自のオペレーティングシステム、ネットワークスタックや制限されたデバイスリソースのデバイスから統合ができるようになります。

Kinesis ビデオストリーム プロデューサーライブラリは、Kinesis ビデオストリーム にストリーミングするためのステートマシンを実装します。これは、独自のトランスポート実装を提供して、各メッセージがこのサービスに行き来するように明示的に指示することが必要なコールバックフックを提供します。

次のような理由から、Kinesis ビデオストリーム プロデューサーライブラリを直接使用することが推奨されます。

• アプリケーションを実行するデバイスに Java 仮想マシンがない場合。• Java 以外の言語でアプリケーションコードを記述する場合。• デバイスに Java が存在が、メモリや処理能力の制限より、コードのオーバーヘッド量を減少して抽象

化最低限レベル値までに限定したい場合。

現在、Kinesis ビデオストリーム プロデューサーライブラリは、C++ アプリケーションで利用できます。詳細については、「C++ プロデューサーライブラリの使用 (p. 57)」を参照してください。

関連トピックJava プロデューサーライブラリを使用する (p. 48)

Android プロデューサーライブラリを使用する (p. 52)

C++ プロデューサーライブラリの使用 (p. 57)

??? (p. 75)

Java プロデューサーライブラリを使用するAmazon Kinesis ビデオストリーム は Java プロデューサーライブラリを提供します。このライブラリを使用すると、最小限の設定でアプリケーションコードを記述し、デバイスから Kinesis ビデオストリーム にメディアデータを送信できます。

48

Page 55: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイド手順: Java プロデューサー SDK を使用する

次のステップを実行してコードを Kinesis ビデオストリーム に統合する必要があります。これで、アプリケーションが Kinesis ビデオストリーム にデータのストリーミングを開始できます。

1. KinesisVideoClient オブジェクトのインスタンスを作成します。2. メディアソース情報を指定して MediaSource オブジェクトを作成します。たとえば、カメラのメディ

アソースを作成する場合、カメラを識別しカメラ使用のエンコードを指定するなどの情報を提供します。

ストリーミングを開始するには、カスタムのメディアソースを作成する必要があります。3. KinesisVideoClient を使用してメディアソースを登録します。

KinesisVideoClient を使用してメディアソースを登録後、メディアソースでデータが利用可能になると、KinesisVideoClient とデータが呼び出されます。

手順: Java プロデューサー SDK を使用するこの手順では、Java アプリケーションで Kinesis ビデオストリーム Java プロデューサークライアントを使用してデータを Kinesis ビデオストリーム に送信する方法を説明します。

このステップでは、カメラやマイクなどのメディアソースは必要ありません。代わりに、テスト目的により、このコードは一連のバイトで構成されるサンプルフレームを生成します。カメラやマイクなどの実際のソースからメディアデータを送信する場合に、この同じコードパターンを使用できます。

この手順には、以下のステップが含まれます。

• コードをダウンロードして設定する• コードを作成してテストする• コードを実行して検証する

前提条件• サンプルコードで、AWS 認証情報プロファイルファイルで設定したプロファイルを指定して、認証情

報を提供します。まず、認証情報プロファイルを設定します (まだ設定していない場合)。詳細については、AWS SDK for Javaの「開発用の AWS 認証情報とリージョンのセットアップ」を参照してください。

Note

この Java の例では SystemPropertiesCredentialsProvider オブジェクトを使用してAWS 認証情報を取得します。プロバイダは aws.accessKeyId および aws.secretKey Javaシステムプロパティから、この認証情報を取得します。このシステムプロパティを Java 開発環境に設定します。Java システムプロパティを設定する方法についての詳細は、お使いの統合開発環境 (IDE) のドキュメントを参照してください。

• NativeLibraryPath には KinesisVideoProducerJNI ファイル (https://github.com/awslabs/amazon-kinesis-video-streams-producer-sdk-cpp から入手可能) が含まれている必要があります。このファイルのファイル名拡張子は、オペレーティングシステムによって以下のように変化します。• KinesisVideoProducerJNI.so: Linux• KinesisVideoProducerJNI.dylib: macOS• KinesisVideoProducerJNI.dll: Windows

Note

macOS、Ubuntu、Windows、および Raspbian 用の事前構築済みのライブラリは、src/main/resources/lib (https://github.com/awslabs/amazon-kinesis-video-streams-producer-

49

Page 56: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドステップ 1: コードをダウンロードして設定する

sdk-java) で入手できます。他の環境では、C++ プロデューサーライブラリ (p. 57) をコンパイルします。

ステップ 1: Java プロデューサーライブラリコードをダウンロードおよび設定するJava プロデューサーライブラリ手順のこのセクションでは、Java のコード例をダウンロードしてプロジェクトを Java IDE にインポートし、ライブラリの場所を設定します。

この例の前提条件その他の詳細については、「Java プロデューサーライブラリを使用する」を参照してください。

1. ディレクトリを作成して、GitHub リポジトリのソースコード例からクローンを作成します。

$ git clone https://github.com/awslabs/amazon-kinesis-video-streams-producer-sdk-java

2. 使用する Java 統合開発環境 (IDE) (Eclipse や JetBrains IntelliJ IDEA など) を開き、ダウンロードしたApache Maven プロジェクトをインポートします。

• IntelliJ IDEA では: [インポート] を選択します。ダウンロードしたパッケージのルートに含まれるpom.xml ファイルに移動します。

• Eclipse では: [ファイル]、[インポート]、[Maven]、[Existing Maven Projects] を選択します。続いて、kinesis-video-java-demo ディレクトリに移動します。

詳細については、IDE のドキュメントを参照してください。3. この Java コード例では、現在の AWS 認証情報を使用します。別の認証情報プロファイルを使用する

には、次のコードを DemoAppMain.java で見つけます。

final KinesisVideoClient kinesisVideoClient = KinesisVideoJavaClientFactory .createKinesisVideoClient( Regions.US_WEST_2, AuthHelper.getSystemPropertiesCredentialsProvider());

コードを次に変更します。

final KinesisVideoClient kinesisVideoClient = KinesisVideoJavaClientFactory .createKinesisVideoClient( Regions.US_WEST_2, new ProfileCredentialsProvider("credentials-profile-name"));

詳細については、AWS SDK for Java リファレンスで「ProfileCredentialsProvider」を参照してください。

次のステップthe section called “ステップ 2: コードを作成してテストする” (p. 50)

ステップ 2: コードを作成してテストするJava プロデューサーライブラリ手順のこのセクションでは、前のセクションでダウンロードした Javaコード例を作成して確認します。

50

Page 57: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドステップ 2: コードを作成してテストする

Java テストアプリケーション (DemoAppMain) は、次のコードパターンを示します。

• KinesisVideoClient のインスタンスを作成します。• MediaSource のインスタンスを作成します。• MediaSource をクライアントと登録します。• ストリーミングを開始します。つまり、MediaSource を開始すると、クライアントへのデータ送信が

始まります。

詳細については次のセクションで説明します。

KinesisVideoClient のインスタンスの作成createKinesisVideoClient オペレーションを呼び出す KinesisVideoClient オブジェクトを作成します。

final KinesisVideoClient kinesisVideoClient = KinesisVideoJavaClientFactory .createKinesisVideoClient( Regions.US_WEST_2, AuthHelper.getSystemPropertiesCredentialsProvider());

KinesisVideoClient がネットワーク呼び出しを行うには、認証のために認証情報が必要です。SystemPropertiesCredentialsProvider のインスタンスを渡すと、認証情報のデフォルトプロフィールの AWSCredentials を読み込みます。

[default]aws_access_key_id = ABCDEFGHIJKLMOPQRSTUaws_secret_access_key = AbCd1234EfGh5678IjKl9012MnOp3456QrSt7890

MediaSource のインスタンスを作成するKinesis ビデオストリーム にバイトを送信するには、データを生成する必要があります。Amazon Kinesisビデオストリーム は、データソースを示す MediaSource インターフェイスを提供します。

たとえば、Kinesis ビデオストリーム Java ライブラリは、MediaSource インターフェイスのImageFileMediaSource 実装を提供します。このクラスが読み込むのは、Kinesis ビデオストリーム ではなく一連のメディアファイルのデータだけですが、コードのテストに使用することは可能です。

final MediaSource bytesMediaSource = createImageFileMediaSource();

MediaSource をクライアントで再登録するKinesisVideoClient で作成したメディアソースを再登録すると、クライアントを認識するようになります (そして、クライアントにデータを送信できます)。

kinesisVideoClient.registerMediaSource(STREAM_NAME, bytesMediaSource);

メディアソースを開始するメディアソースを開始して、データを生成し、それをクライアントに送信できるようにします。

bytesMediaSource.start();

51

Page 58: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドステップ 3: コードを実行して検証する

次のステップthe section called “ステップ 3: コードを実行して検証する” (p. 52)

ステップ 3: コードを実行して検証するJava プロデューサーライブラリ用のコードの Java テストハーネスを実行するには、次の操作を行います。

1. [DemoAppMain] を選択します。2. [実行]、[Run 'DemoAppMain'] の順に選択します。3. アプリケーションの JVM 引数に認証情報を追加します。

• 一時的ではない AWS 認証情報の場合: "-Daws.accessKeyId={YourAwsAccessKey} -Daws.secretKey={YourAwsSecretKey} -Djava.library.path={NativeLibraryPath}"

• 一時的な AWS 認証情報の場合: "-Daws.accessKeyId={YourAwsAccessKey} -Daws.secretKey={YourAwsSecretKey} -Daws.sessionToken={YourAwsSessionToken}-Djava.library.path={NativeLibraryPath}"

4. AWS マネジメントコンソール にサインインして、Kinesis ビデオストリーム コンソールを開きます。

[Manage Streams] ページでストリームを選択します。5. 埋め込みプレーヤーでサンプルビデオが再生されます。フレームが蓄積されビデオが表示されるまで

に少し時間がかかることがあります (一般的な帯域幅やプロセッサの状態で最長 10 秒)。

このコード例は、ストリームを作成します。MediaSource としてコードが開始すると、KinesisVideoClient にサンプルフレームの送信を開始します。続いて、クライアントは Kinesisビデオストリーム にデータを送信します。

Android プロデューサーライブラリを使用するAmazon Kinesis ビデオストリーム は Android プロデューサーライブラリを提供します。このライブラリを使用すると、最小限の設定でアプリケーションコードを記述し、Android デバイスから Kinesis ビデオストリーム にメディアデータを送信できます。

次のステップを実行してコードを Kinesis ビデオストリーム に統合する必要があります。これで、アプリケーションが Kinesis ビデオストリーム にデータのストリーミングを開始できます。

1. KinesisVideoClient オブジェクトのインスタンスを作成します。2. メディアソース情報を指定して MediaSource オブジェクトを作成します。たとえば、カメラのメディ

アソースを作成する場合、カメラを識別しカメラ使用のエンコードを指定するなどの情報を提供します。

ストリーミングを開始するには、カスタムのメディアソースを作成する必要があります。

手順: Android プロデューサー SDK を使用するこの手順では、Android アプリケーションで Kinesis ビデオストリーム Android プロデューサークライアントを使用して、データを Kinesis ビデオストリーム に送信する方法を説明します。

この手順には、以下のステップが含まれます。

52

Page 59: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイド手順: Android プロデューサー SDK を使用する

• コードをダウンロードして設定する• コードを検証する• コードを実行して検証する

前提条件• アプリケーションコードの検査、編集、および実行には、Android Studio をお勧めします。2017 年 10

月にリリースされた、バージョン 3.0.0 以上をお勧めします。• サンプルコードでは、Amazon Cognito 認証情報を入力します。Amazon Cognito ユーザープールと ID

プールをセットアップするには、次の手順に従ってください。

ユーザープールをセットアップ

1. Amazon Cognito コンソールにサインインします。2. [Manage your User Pools] を選択します。3. [Create a user pool] を選択します。4. [Pool name] に値 (<username>_android_user_pool など) を入力します。5. [Review defaults] を選択します。6. [Create pool] を選択します。7. [Pool Id] の値をコピーし、保存します。例を設定するときに、この値が必要になります。8. プールのページで、[App clients] をクリックします。9. [Add an app client] を選択します。10. [App client name] に値 (<username>_android_app_client など) を入力します。11. [Create app client] を選択します。12. [Show Details] を選択し、[App client ID] と [App client secret] をコピーして保存します。サンプル

アプリケーションを設定するときは、これらの値が必要になります。

ID プールをセットアップ

1. Amazon Cognito コンソールを開きます。2. [Manage Identity Pools (ID プールの管理)] を選択します。3. [Create new identity pool] を選択します。4. [Identity pool name] に値 (<username>_android_identity_pool など) を入力します。5. [Authentication providers] セクションを展開します。[Cognito] タブで、前の手順の [User Pool ID] と

[App Client ID] の値を追加します。6. [Create pool] を選択します。7. 次のページで、[Show Details] セクションを展開します。8. [Role name] の値が [Auth_Role] で終わるセクションで、[View Policy Document] を選択します。9. [Edit] を選択し、表示される [Edit Policy] ダイアログボックスを確認します。次に、次の JSON をコ

ピーしてエディタに貼り付けます。

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "cognito-identity:*", "kinesisvideo:*" ], "Resource": [

53

Page 60: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドステップ 1: コードをダウンロードして設定する

"*" ] } ]}

10. [Allow] を選択します。11. 次のページで、[Get AWS Credentials] コードスニペットから、[Identity pool ID] の値をコピーして

保存します。例を設定するときに、この値が必要になります。

ステップ 1: Android プロデューサーライブラリコードをダウンロードおよび設定するAndroid プロデューサーライブラリのこのセクションでは、Android サンプルコードをダウンロードし、Android Studio でプロジェクトを開きます。

この例の前提条件その他の詳細については、「Android プロデューサーライブラリを使用する」を参照してください。

1. ディレクトリを作成して、GitHub リポジトリから AWS Android SDK をクローンします。

$ git clone https://github.com/awslabs/aws-sdk-android-samples

2. Android Studio を開きます。3. [開く] 画面で、[Open an existing Android Studio project] を選択します。4. aws-sdk-android-samples/AmazonKinesisVideoDemoApp ディレクトリに移動し、[OK] を開

始します。5. AmazonKinesisVideoDemoApp/src/main/res/raw/awsconfiguration.json ファイルを開き

ます。

CredentialsProvider ノードで、「前提条件」セクションの [ID プールをセットアップ] の手順からアイデンティティプール ID を入力し、AWS リージョンを入力します (例: us-west-2)。

CognitoUserPool ノードで、「前提条件」セクションの [ユーザープールをセットアップ] の手順からアプリのクライアントシークレット、アプリクライアント ID、プール ID を入力し、AWS リージョンを入力します (例: us-west-2)。

6. awsconfiguration.json ファイルは次のようになります。

{ "Version": "1.0", "CredentialsProvider": { "CognitoIdentity": { "Default": { "PoolId": "us-west-2:01234567-89ab-cdef-0123-456789abcdef", "Region": "us-west-2" } } }, "IdentityManager": { "Default": {} }, "CognitoUserPool": { "Default": { "AppClientSecret": "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmno", "AppClientId": "0123456789abcdefghijklmnop", "PoolId": "us-west-2_qRsTuVwXy", "Region": "us-west-2"

54

Page 61: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドステップ 2: コードを検証する

} }}

7. AmazonKinesisVideoDemoApp/src/main/java/com/amazonaws/kinesisvideo/demoapp/KinesisVideoDemoApp.java を該当リージョンに更新します (以下のサンプルでは、US_WEST_2に設定されています)。

public class KinesisVideoDemoApp extends Application { public static final String TAG = KinesisVideoDemoApp.class.getSimpleName(); public static Regions KINESIS_VIDEO_REGION = Regions.US_WEST_2;

AWS リージョンの定数については、「リージョン」を参照してください。

次のステップthe section called “ステップ 2: コードを検証する” (p. 55)

ステップ 2: コードを検証するAndroid プロデューサーライブラリ手順のこのセクションでは、コード例を確認します。

Android テストアプリケーション (AmazonKinesisVideoDemoApp) は、次のコードパターンを示します。

• KinesisVideoClient のインスタンスを作成します。• MediaSource のインスタンスを作成します。• Start streaming— つまり、MediaSource を開始すると、クライアントへのデータ送信が始まります。

詳細については次のセクションで説明します。

KinesisVideoClient のインスタンスの作成createKinesisVideoClient オペレーションを呼び出す KinesisVideoClient オブジェクトを作成します。

mKinesisVideoClient = KinesisVideoAndroidClientFactory.createKinesisVideoClient( getActivity(), KinesisVideoDemoApp.KINESIS_VIDEO_REGION, KinesisVideoDemoApp.getCredentialsProvider());

KinesisVideoClient がネットワーク呼び出しを行うには、認証のために認証情報が必要です。AWSCredentialsProvider のインスタンスを渡します。これは、前のセクションで変更したawsconfiguration.json ファイルから Amazon Cognito 認証情報を読み込みます。

MediaSource のインスタンスを作成するKinesis ビデオストリーム にバイトを送信するには、データを生成する必要があります。Amazon Kinesisビデオストリーム は、データソースを示す MediaSource インターフェイスを提供します。

たとえば、Kinesis ビデオストリーム Android ライブラリは、MediaSource インターフェイスのAndroidCameraMediaSource 実装を提供します。このクラスは、デバイスのカメラの 1 つからデータを読み取ります。

55

Page 62: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドステップ 3: コードを実行して検証する

次のコード例 (「fragment/StreamConfigurationFragment.java」ファイルから) では、メディアソースの設定が作成されます。

private AndroidCameraMediaSourceConfiguration getCurrentConfiguration() {return new AndroidCameraMediaSourceConfiguration( AndroidCameraMediaSourceConfiguration.builder() .withCameraId(mCamerasDropdown.getSelectedItem().getCameraId()) .withEncodingMimeType(mMimeTypeDropdown.getSelectedItem().getMimeType()) .withHorizontalResolution(mResolutionDropdown.getSelectedItem().getWidth()) .withVerticalResolution(mResolutionDropdown.getSelectedItem().getHeight()) .withCameraFacing(mCamerasDropdown.getSelectedItem().getCameraFacing()) .withIsEncoderHardwareAccelerated( mCamerasDropdown.getSelectedItem().isEndcoderHardwareAccelerated()) .withFrameRate(FRAMERATE_20) .withRetentionPeriodInHours(RETENTION_PERIOD_48_HOURS) .withEncodingBitRate(BITRATE_384_KBPS) .withCameraOrientation(-mCamerasDropdown.getSelectedItem().getCameraOrientation()) .withNalAdaptationFlags(StreamInfo.NalAdaptationFlags.NAL_ADAPTATION_ANNEXB_CPD_AND_FRAME_NALS) .withIsAbsoluteTimecode(false));}

次のコード例 (「fragment/StreamingFragment.java」ファイルから) では、メディアソースの設定が作成されます。

mCameraMediaSource = (AndroidCameraMediaSource) mKinesisVideoClient .createMediaSource(mStreamName, mConfiguration);

メディアソースを開始するメディアソースを開始して、データを生成し、それをクライアントに送信できるようにします。次のコード例は fragment/StreamingFragment.java ファイルからのものです。

mCameraMediaSource.start();

次のステップthe section called “ステップ 3: コードを実行して検証する” (p. 56)

ステップ 3: コードを実行して検証するAndroid プロデューサーライブラリの Android サンプルアプリケーションを実行するには、以下の操作を実行します。

1. Android デバイスに接続します。2. [Run]、[Run]、[Edit configurations...] をクリックし ます。3. [+]、[Android App] を選択します。[名前] フィールドに AmazonKinesisVideoDemoApp を入力しま

す。[Module] プルダウンから、[AmazonKinesisVideoDemoApp] を選択します。[OK] を選択します。4. [Run]、[Run] を選択します。5. [Select a Deployment Target] 画面で、接続されているデバイスを選択し、[OK] を選択します。6. デバイスの [AWSKinesisVideoDemoApp] アプリケーションで、[Create new account] を選択します。7. [«1»USERNAME]、[Password]、[Given name]、[Email address]、[Phone number] の値を入力し、

[Sign up] を選択します。

56

Page 63: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドC++ プロデューサーライブラリ

Note

これらの値には以下の制約があります。

• パスワード: 大文字と小文字、数字、特殊文字を含む必要があります。これらの制約は、Amazon Cognito コンソールのユーザープールページで変更できます。

• E メールアドレス: 確認コードを受け取れるように有効なアドレスでなければなりません。• 電話番号: 次の形式にする必要があります。+<Country code><Number> (例:+12065551212)。

8. E メールで受信したコードを入力し、[Confirm] を選択します。[Ok] を選択します。9. 次のページでは、デフォルト値のままにし、[Stream] を選択します。10. AWS マネジメントコンソール にサインインし、米国西部 (オレゴン) リージョン の https://

console.aws.amazon.com/kinesisvideo/ で Kinesis Video Streams コンソールを開きます。

[Manage Streams] ページで [demo-stream] を選択します。11. 埋め込みプレーヤーでストリーミングビデオが再生されます。フレームが蓄積されビデオが表示され

るまでに少し時間がかかることがあります (一般的な帯域幅やプロセッサの状態で最長 10 秒)。Note

デバイスの画面が回転された場合 (縦向きから横向きへなど)、アプリケーションはビデオのストリーミングを停止します。

このコード例は、ストリームを作成します。MediaSource としてコードが開始すると、カメラからKinesisVideoClient にフレームが送信を開始します。クライアントは、データを [demo-stream] という名前の Kinesis ビデオストリーム に送信します。

C++ プロデューサーライブラリの使用Amazon Kinesis ビデオストリーム は C++ プロデューサーライブラリを提供します。このライブラリを使用すると、アプリケーションコードを記述して、デバイスから Kinesis ビデオストリーム にメディアデータを送信できます。

オブジェクトモデルC++ ライブラリには、Kinesis ビデオストリーム へのデータ送信を管理するために次のオブジェクトが用意されています。

• KinesisVideoProducer: メディアソースと AWS 認証情報に関する情報が含まれ、Kinesis ビデオストリーム イベントに関する報告を行うためのコールバックを管理します。

• KinesisVideoStream: Kinesis ビデオストリーム を表します。名前、データ保持期間、メディアコンテンツタイプなど、ビデオストリームのパラメータに関する情報が含まれています。

ストリームへのメディアの挿入C++ ライブラリには、データを KinesisVideoStream オブジェクトに挿入するために使用できるメソッド (PutFrame など) が用意されています。ライブラリは、データの内部状態も管理します。タスクには以下が含まれる場合があります。

• 認証を実行する。• ネットワークレイテンシーを監視する。レイテンシーが長すぎると、フレームが停止される場合があり

ます。

57

Page 64: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドコールバックインターフェイス

• 進行中のストリーミングのステータスを追跡する。

コールバックインターフェイスこのレイヤーでは、一連のコールバックインターフェイスを表示し、アプリケーションレイヤーとやり取りできるようにします。これらのコールバックインターフェイスには以下が含まれます。

• サービスコールバックインターフェイス (CallbackProvider): ライブラリは、ストリームの作成、ストリームの説明の取得、ストリームの削除などを行う際にこのインターフェイスで取得したイベントを呼び出します。

• クライアントの準備が整った状態または低ストレージイベントインターフェイス(ClientCallbackProvider): ライブラリは、クライアントの準備が完了するか、使用可能なストレージまたはメモリが不足する可能性があることを検出すると、イベントを呼び出します。

• ストリームイベントコールバックインターフェイス (StreamCallbackProvider): ライブラリは、ストリームが準備完了状態になるか、フレームを停止するか、ストリームエラーなどのストリームイベントの発生時にこのインターフェイスでイベントを呼び出します。

Kinesis ビデオストリーム には、これらのインターフェイス用のデフォルト実装が用意されています。独自のカスタム実装を提供することもできます。たとえば、カスタムネットワーキングロジックが必要な場合や、低ストレージ状態をユーザーインターフェイスに表示する場合などです。

プロデューサーライブラリのコールバックの詳細については、「プロデューサー SDK コールバック (p. 122)」を参照してください。

手順: C++ プロデューサー SDK を使用するこの手順では、C++ アプリケーションで Kinesis ビデオストリーム クライアントおよびメディアソースを使用してデータを Kinesis ビデオストリーム に送信する方法について説明します。

Note

C++ ライブラリには macOS 用のサンプルビルドスクリプトが含まれています。MicrosoftWindows で C++ プロデューサーライブラリを使用するには、「Windows で C++ プロデューサーSDK を使用する (p. 67)」を参照してください。Raspberry Pi デバイスで C++ プロデューサーライブラリを使用するには、「 Raspberry Pi で C++ プロデューサー SDK を使用する (p. 69)」を参照してください。

この手順には、以下のステップが含まれます。

• ステップ 1: コードをダウンロードして設定する• ステップ 2: コードを作成してテストする• ステップ 3: コードを実行して検証する

前提条件• 認証情報: サンプルコードで、AWS 認証情報プロファイルファイルで設定したプロファイルを指定し

て、認証情報を提供します。まず、認証情報プロファイルを設定します (まだ設定していない場合)。

詳細については、「開発用の AWS 認証情報とリージョンのセットアップ」を参照してください。• 証明書ストアの統合: Kinesis ビデオストリーム プロデューサーライブラリが、呼び出し対象のサービス

と信頼を確立する必要があります。この信頼は、正式な証明書ストアで証明機関 (CA) を検証することで確立されます。Linux ベースのモデルの場合、このストアは /etc/ssl/ ディレクトリにあります。

58

Page 65: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイド手順: C++ プロデューサー SDK を使用する

以下の場所から証明書ストアに、証明書をダウンロードしてください。

https://www.amazontrust.com/repository/SFSRootCAG2.pem• macOS 用の次のビルド依存関係をインストールします。

• Autoconf 2.69 (ライセンス GPLv3+/Autoconf: GNU GPL バージョン 3 以降)• CMake 3.または 3.8• Pkg-Config• Flex 2.5.35 Apple (flex-31) 以降• Bison 2.4 (GNU ライセンス)• Automake 1.15.1 (GNU ライセンス)• GNU Libtool (Apple Inc. バージョン cctools-898)• xCode (macOS) / clang / gcc (xcode-select バージョン 2347)• Java Development Kit (JDK) (Java JNI コンパイル用)• Lib-Pkg

• Ubuntu 用の次のビルド依存関係をインストールします (バージョンコマンドへの応答は切り捨てられます)。• Git をインストールします: sudo apt-get install git

$ git --versiongit version 2.14.1

• CMake をインストールします: sudo apt-get install cmake

$ cmake --versioncmake version 3.9.1

• Libtool をインストールします: sudo apt-get install libtool

2.4.6-2

• libtool-bin をインストールします: sudo apt-get install libtool-bin

$ libtool --versionlibtool (GNU libtool) 2.4.6Written by Gordon Matzigkeit, 1996

• GNU Automake をインストールします: sudo apt-get install automake

$ automake --versionautomake (GNU automake) 1.15

• GNU Bison をインストールします: sudo apt-get install bison

$ bison -Vbison (GNU Bison) 3.0.4

• G++ をインストールします: sudo apt-get install g++

g++ --versiong++ (Ubuntu 7.2.0-8ubuntu3) 7.2.0

• curl をインストールします: sudo apt-get install curl

$ curl --version

59

Page 66: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドステップ 1: コードをダウンロードして設定する

curl 7.55.1 (x86_64-pc-linux-gnu) libcurl/7.55.1 OpenSSL/1.0.2g zlib/1.2.11 libidn2/2.0.2 libpsl/0.18.0 (+libidn2/2.0.2) librtmp/2.3

• pkg-config をインストールします: sudo apt-get install pkg-config

$ pkg-config --version0.29.1

• Flex をインストールします: sudo apt-get install flex

$ flex --versionflex 2.6.1

• OpenJDK をインストールします: sudo apt-get install openjdk-8-jdk

$ java -versionopenjdk version "1.8.0_171"

• JAVA_HOME 環境変数を設定します: export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/

• ビルドスクリプトを実行します: ./install-script

次のステップステップ 1: C++ プロデューサーライブラリコードをダウンロードして設定する

ステップ 1: C++ プロデューサーライブラリコードをダウンロードして設定するこのセクションでは、低レベルのライブラリをダウンロードして、アプリケーションを設定し、AWS 認証情報を使用できるようにします。

この例の前提条件その他の詳細については、「C++ プロデューサーライブラリの使用」を参照してください。

1. ディレクトリを作成して、GitHub リポジトリのソースコード例からクローンを作成します。

git clone --recursive https://github.com/awslabs/amazon-kinesis-video-streams-producer-sdk-cpp.git

Note

--recursive を使用して Git クローンを実行しない場合は、amazon-kinesis-video-streams-producer-sdk-cpp/open-source ディレクトリで git submodule update--init を実行してください。また、pkg-config、CMake、およびビルド環境をインストールする必要があります。GStreamer プラグインを構築する場合は、ローカルにインストールする必要があります。詳細については、https://github.com/awslabs/amazon-kinesis-video-streams-producer-sdk-cpp の README.md を参照してください。

2. 任意の統合開発環境 (IDE) (Eclipse など) でコードを開きます。

次のステップステップ 2: コードを作成してテストする (p. 61)

60

Page 67: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドステップ 2: コードを作成してテストする

ステップ 2: コードを作成してテストするC++ プロデューサーライブラリ手順のこのセクションでは、C++ テストハーネス (tst/ProducerTestFixture.h および他のファイル) でコードを検証します。このコードは前のセクションでダウンロードしたものです。

プラットフォームに依存しない C++ 例では、次のコーディングパターンを示します。

• Kinesis ビデオストリーム にアクセスするための KinesisVideoProducer のインスタンスを作成します。

• KinesisVideoStream のインスタンスを作成します。これにより、同じ名前の Kinesis ビデオストリーム がまだ存在しない場合には、そのストリームが AWS アカウントに作成されます。

• データのフレームをストリームに送信する準備ができたら、そのたびに putFrame をKinesisVideoStream で呼び出します。

詳細については次のセクションで説明します。

KinesisVideoProducer のインスタンスの作成KinesisVideoProducer::createSync メソッドを呼び出して、KinesisVideoProducer オブジェクトを作成します。次の例では、KinesisVideoProducer を ProducerTestFixture.hファイルに作成します。

kinesis_video_producer_ = KinesisVideoProducer::createSync(move(device_provider_), move(client_callback_provider_), move(stream_callback_provider_), move(credential_provider_), defaultRegion_);

createSync メソッドは以下のパラメータを使用します。

• DeviceInfoProvider オブジェクト。デバイスまたはストレージ設定に関する情報を含むDeviceInfo オブジェクトを返します。

Note

deviceInfo.storageInfo.storageSize パラメータを使用してコンテンツストアのサイズを設定します。コンテンツストリームは、コンテンツストアを共有します。ストレージサイズの要件を確認するには、平均フレームサイズに、すべてのストリームの最大継続時間に格納されたフレーム数を乗算します。次に、1.2 を掛けてデフラグメンテーションに合わせます。たとえば、アプリケーションの設定が次のとおりであるとします。• 3 つのストリーム• 3 分の最大継続時間• 各ストリームは 30 フレーム/秒 (FPS)• 各フレームのサイズは 10,000 KBこのアプリケーションのコンテンツストアの要件は、3 (ストリーム) * 3 (分) * 60 (1 分の秒数) *10000 (kb) * 1.2 (デフラグメンテーションの上限) = 194.4 Mb ~ 200Mb です。

• ClientCallbackProvider オブジェクト。クライアント固有のイベントを報告する関数ポインタを返します。

• StreamCallbackProvider オブジェクト。ストリーム固有のイベントが発生したときにコールバックされる関数ポインタを返します。

• CredentialProvider オブジェクト。AWS 認証情報環境変数へのアクセスを提供します。• AWS リージョン ("us-west-2")。サービスエンドポイントはリージョンから決定されます。

61

Page 68: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドステップ 2: コードを作成してテストする

KinesisVideoStream のインスタンスの作成StreamDefinition パラメータを指定して KinesisVideoProducer::CreateStream メソッドを呼び出すことで、KinesisVideoStream オブジェクトを作成します。この例では、トラックタイプをビデオ、トラック ID を 1 として、ProducerTestFixture.h ファイルで KinesisVideoStream を作成します。

auto stream_definition = make_unique<StreamDefinition>(stream_name, hours(2), tags, "", STREAMING_TYPE_REALTIME, "video/h264", milliseconds::zero(), seconds(2), milliseconds(1), true, true, true);return kinesis_video_producer_->createStream(move(stream_definition));

StreamDefinition オブジェクトには以下のフィールドがあります。

• ストリーム名。• データ保持期間。• ストリーム用タグ。コンシューマーアプリケーションでこれらのタグを使用すると、適切なストリーム

の検索や、ストリームに関する詳細情報を取得できます。タグは、AWS マネジメントコンソール で表示することもできます。

• ストリーム用 AWS KMS 暗号化キー。詳細については、「 Kinesis ビデオストリーム でのサーバー側の暗号化の使用」を参照してください。

• ストリーミングタイプ。現在、有効な値は STREAMING_TYPE_REALTIME のみです。• メディアコンテンツタイプ。• メディアレイテンシー。この値は現在使用されておらず、0 に設定する必要があります。• 各フラグメントの再生時間。• メディアのタイムコードスケール。• メディアがキーフレームを使用して断片化するかどうか。• メディアがタイムコードを使用するかどうか。• メディアが絶対フラグメントタイムを使用するかどうか。

Kinesis ビデオストリームへのオーディオトラックの追加StreamDefinition の addTrack メソッドを使用して、オーディオトラックの詳細をビデオトラックストリーム定義に追加できます。

stream_definition->addTrack(DEFAULT_AUDIO_TRACKID, DEFAULT_AUDIO_TRACK_NAME, DEFAULT_AUDIO_CODEC_ID, MKV_TRACK_INFO_TYPE_AUDIO);

addTrack メソッドでは、以下のパラメータが必要です。

• トラック ID (オーディオ用には 1)。これは一意であり、ゼロ以外の値である必要があります。• ユーザー定義のトラック名 (オーディオトラック用の「audio」など)。• このトラックのコーデック ID (オーディオトラック用の「A_AAC」など)。• トラックタイプ (オーディオ用の MKV_TRACK_INFO_TYPE_AUDIO の列挙値を使用するなど)。

62

Page 69: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドステップ 2: コードを作成してテストする

オーディオトラック用のコーデックプライベートデータがある場合は、addTrack 関数を呼び出すときに、このデータを渡すことができます。KinesisVideoStream で start メソッドを呼び出し中に、KinesisVideoStream オブジェクトの作成後、コーデックプライベートデータを送信することもできます。

フレームを Kinesis ビデオストリームに挿入するKinesisVideoStream::putFrame を使用してメディアを Kinesis ビデオストリーム に挿入し、ヘッダーとメディアデータを含む Frame オブジェクトに渡します。この例では、ProducerApiTest.cppファイル内の putFrame を呼び出します。

frame.duration = FRAME_DURATION_IN_MICROS * HUNDREDS_OF_NANOS_IN_A_MICROSECOND; frame.size = SIZEOF(frameBuffer_); frame.frameData = frameBuffer_; MEMSET(frame.frameData, 0x55, frame.size);

while (!stop_producer_) { // Produce frames timestamp = std::chrono::duration_cast<std::chrono::nanoseconds>( std::chrono::system_clock::now().time_since_epoch()).count() / DEFAULT_TIME_UNIT_IN_NANOS; frame.index = index++; frame.decodingTs = timestamp; frame.presentationTs = timestamp;

// Key frame every 50th frame.flags = (frame.index % 50 == 0) ? FRAME_FLAG_KEY_FRAME : FRAME_FLAG_NONE; ...

EXPECT_TRUE(kinesis_video_stream->putFrame(frame));

Note

前述の C++ プロデューサーの例では、テストデータのバッファが送信されます。実際のアプリケーションでは、フレームバッファとフレームのサイズはメディアソース (カメラなど) のフレームデータから取得してください。

Frame オブジェクトには以下のフィールドがあります。

• フレームインデックス。これは一定間隔で増加する値にする必要があります。• フレームに関連付けられているフラグ。たとえば、エンコーダーがキーフレームを生成するように設定

されている場合、このフレームは FRAME_FLAG_KEY_FRAME フラグに割り当てられます。• デコードタイムスタンプ。• プレゼンテーションタイムスタンプ。• フレームの時間 (100 ns 単位)。• フレームのサイズ (バイト単位)。• フレームデータ。

フレームの形式の詳細については、「 Kinesis ビデオストリーム データモデル」を参照してください。

KinesisVideoStream の特定のトラックへの KinesisVideoFrameの配置PutFrameHelper クラスを使用して、特定のトラックにフレームデータを配置できます。まず、getFrameDataBuffer を呼び出して、事前に割り当てられたいずれかのバッファへのポインタを取得し、KinesisVideoFrame データに入力します。次に、putFrameMultiTrack を呼び出して、ブール値ととも

63

Page 70: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドステップ 2: コードを作成してテストする

に KinesisVideoFrame を送信し、フレームデータのタイプを指定できます。ビデオデータの場合は true、フレームにオーディオデータが含まれている場合は false を使用します。putFrameMultiTrack メソッドは、キューメカニズムを使用して、一定間隔で増加するフレームのタイムスタンプが MKV フラグメントで維持され、2 つのフラグメントが重複しないようにします。たとえば、フラグメントの最初のフレームの MKV タイムスタンプは、前のフラグメントの最後のフレームの MKV タイムスタンプよりも常に大きい必要があります。

PutFrameHelper には、以下のフィールドがあります。

• キュー内のオーディオフレームの最大数• キュー内のビデオフレームの最大数• 1 つのオーディオフレームに割り当てるサイズ• 1 つのビデオフレームに割り当てるサイズ

メトリクスおよびメトリクスのログ記録C++ プロデューサー SDK には、メトリクスおよびメトリクスのログ記録のための機能があります。

getKinesisVideoMetrics および getKinesisVideoStreamMetrics API オペレーションを使用すると、Kinesis ビデオストリーム とアクティブなストリームに関する情報を取得できます。

以下は kinesis-video-pic/src/client/include/com/amazonaws/kinesis/video/client/Include.h ファイルにあるコードです。

/*** Gets information about the storage availability.** @param 1 CLIENT_HANDLE - the client object handle.* @param 2 PKinesisVideoMetrics - OUT - Kinesis Video metrics to be filled.** @return Status of the function call.*/PUBLIC_API STATUS getKinesisVideoMetrics(CLIENT_HANDLE, PKinesisVideoMetrics);

/*** Gets information about the stream content view.** @param 1 STREAM_HANDLE - the stream object handle.* @param 2 PStreamMetrics - Stream metrics to fill.** @return Status of the function call.*/PUBLIC_API STATUS getKinesisVideoStreamMetrics(STREAM_HANDLE, PStreamMetrics);

getKinesisVideoMetrics によって入力される PClientMetrics オブジェクトには、以下の情報が含まれています。

• contentStoreSize: コンテンツストア (ストリーミングデータの保存に使用されるメモリ) 全体のサイズ(バイト単位)。

• contentStoreAvailableSize: コンテンツストアの空きメモリ (バイト単位)。• contentStoreAllocatedSize: コンテンツストアに割り当てられたメモリ。• totalContentViewsSize: コンテンツビューに使用される合計メモリ。(コンテンツビューとは、コンテン

ツストア内の一連の情報インデックスのことです)。• totalFrameRate: 1 秒あたりのフレーム数を、すべてのアクティブなストリームで集計した数。• totalTransferRate: すべてのストリームで送信される合計ビット数/秒 (bps)。

64

Page 71: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドステップ 3: コードを実行して検証する

getKinesisVideoStreamMetrics によって入力される PStreamMetrics オブジェクトには、以下の情報が含まれています。

• currentViewDuration: コンテンツビューの先頭 (フレームがエンコードされた時点) と現在の位置 (フレームデータが Kinesis ビデオストリーム に送信される時点) の差異 (100 ns 単位)。

• overallViewDuration: コンテンツビューの先頭 (フレームのエンコード時) と末尾 (コンテンツビューに割り当てられた合計容量を超過したこと、または Kinesis ビデオストリーム から PersistedAck メッセージを受信し、既知の永続的なフレームがフラッシュされたことが原因で、フレームがメモリからフラッシュされた時点) の差異 (100 ns 単位)。

• currentViewSize: コンテンツビューの先頭 (フレームがエンコードされた時点) から、現在の位置 (フレームデータが Kinesis ビデオストリーム に送信される時点) までのサイズ (バイト単位)。

• overallViewSize: コンテンツビューの合計サイズ (バイト単位)。• currentFrameRate: 最後に測定されたストリームのレート (fps 単位)。• currentTransferRate: 最後に測定されたストリームのレート (bps 単位)。

Teardown:バッファ内の残りのバイトを送信し、ACK を待機する場合、stopSync を使用できます。

kinesis_video_stream->stopSync();

または、stop を呼び出してストリーミングを終了できます。

kinesis_video_stream->stop();

ストリームを停止したら、次の API を呼び出すことでストリームを解放できます。

kinesis_video_producer_->freeStream(kinesis_video_stream);

次のステップthe section called “ステップ 3: コードを実行して検証する” (p. 65)

ステップ 3: コードを実行して検証するC++ プロデューサーライブラリ手順用のコードを実行して検証するには、次の操作を行います。

1. 次のコマンドを実行して、ダウンロードした SDK に build ディレクトリを作成し、そこから cmakeを実行します。

mkdir -p amazon-kinesis-video-streams-producer-c/build; cd amazon-kinesis-video-streams-producer-c/build; cmake ..

次のオプションを cmake .. に渡すことができます。

65

Page 72: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドC++ プロデューサー SDK を

GStreamer プラグインとして使用する

• -DBUILD_DEPENDENCIES - ソースから依存ライブラリを構築するかどうか• -DBUILD_TEST=TRUE - ユニット/統合テストを構築します。お使いのデバイスのサポートを確認す

るのに役立ちます。

./tst/webrtc_client_test

• -DCODE_COVERAGE - カバレッジレポートを有効にします• -DCOMPILER_WARNINGS - すべてのコンパイラの警告を有効にします• -DADDRESS_SANITIZER - AddressSanitizer を使用して構築します• -DMEMORY_SANITIZER - MemorySanitizer を使用して構築します• -DTHREAD_SANITIZER - ThreadSanitizer を使用して構築します• -DUNDEFINED_BEHAVIOR_SANITIZER - UndefinedBehaviorSanitizer を使用して構築します• -DALIGNED_MEMORY_MODEL - アライメントされたメモリモデルのみのデバイス用に構築します。

デフォルトは OFF です。2. 上記のステップで作成した build ディレクトリに移動し、make を実行して WebRTC C++ SDK とそ

の提供サンプルを構築します。

make

3. 詳細なログを有効にするには、CMakeList.txt の適切な行をコメント解除し、HEAP_DEBUG およびLOG_STREAMING の C-定義を定義します。

テストスイートの進行状況は、IDE のデバッグ出力で監視できます。ストリームに関連付けられている、PutMedia.IncomingBytes などのメトリクスを Amazon CloudWatch コンソールで監視することで、ストリームのトラフィックを監視することもできます。

Note

テストハーネスでは空のバイトのフレームのみを送信するため、コンソールには動画ストリームとしてのデータは表示されません。

C++ プロデューサー SDK を GStreamer プラグインとして使用するGStreamer は、多数のカメラやビデオソースで使用される一般的なメディアフレームワークです。モジュラープラグインを組み合わせてカスタムのメディアパイプラインを作成できます。Kinesis ビデオストリーム GStreamer プラグインは、既存の GStreamer メディアパイプラインの Kinesis ビデオストリーム への統合を大幅に簡易化します。

C++ プロデューサー SDK を GStreamer プラグインとして使用する方法については、「例: Kinesis ビデオストリーム プロデューサー SDK GStreamer プラグイン (p. 137)」を参照してください。

Docker コンテナで C++ プロデューサー SDK をGStreamer プラグインとして使用するGStreamer は、多数のカメラやビデオソースで使用される一般的なメディアフレームワークです。モジュラープラグインを組み合わせてカスタムのメディアパイプラインを作成できます。Kinesis ビデオストリーム GStreamer プラグインは、既存の GStreamer メディアパイプラインの Kinesis ビデオストリーム への統合を大幅に簡易化します。

さらに、Docker を使用して GStreamer パイプラインを作成することで Kinesis ビデオストリーム のオペレーティング環境が標準化され、アプリケーションの構築と実行を大幅に簡素化できます。

66

Page 73: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドWindows で C++ プロデューサー SDK を使用する

Docker コンテナで C++ プロデューサー SDK を GStreamer プラグインとして使用する方法については、「Docker コンテナで GStreamer エレメントを実行します。 (p. 141)」を参照してください。

Windows で C++ プロデューサー SDK を使用するこのチュートリアルでは、Microsoft Windows で プロデューサーライブラリ (p. 47) をビルドおよび実行する方法について説明します。その後、ウェブカメラ、USB カメラ、または RTSP (Real TimeStreaming Protocol) カメラなどのソースから Kinesis ビデオストリーム へビデオをストリーミングすることができます。メディアソースから Kinesis ビデオストリーム へストリーミングを開始する際、Kinesis ビデオストリーム コンソールでビデオを表示できます。また、Kinesis ビデオストリーム で使用可能なストリーミングビデオで動作するアプリケーションを構築することができます。

トピック• プロデューサー SDK のビルドと実行: Minimalist GNU for Windows (MinGW) (p. 67)

プロデューサー SDK のビルドと実行: Minimalist GNU forWindows (MinGW)Minimalist GNU for Windows (MinGW) はネイティブ Windows アプリケーションを開発するためのオープンソースのプログラミングツールチェーンです。MinGW を使用して Windows 用 Kinesis ビデオストリーム プロデューサー SDK をビルドすることができます。次に、ストリーミングビデオを開始するサンプルアプリケーションのいずれかを実行します。

このセクションでは、MinGW コンパイラを使用して Amazon Kinesis ビデオストリーム プロデューサーSDK をビルドするために必要な前提条件とステップについて説明します。

前提条件

作業を開始する前に、次の項目が揃っていることを確認してください。

• 指定の Windows プラットフォームにあわせた MSYS2 バージョンをダウンロードしてインストールします。MSYS2 は MinGW ツールチェーンを使用して、ネイティブ Windows アプリケーションをビルドするために必要なすべてのツールを提供します。

MinGW を使用したプロデューサー SDK のビルド

Windows で Kinesis ビデオストリーム プロデューサー SDK をコンパイルするための MinGW ランタイム環境を使用するには、以下のステップを実行します。

1. C:\msys32 または C:\msys64 ディレクトリから MinGW シェル (mingw64.exe) を起動します。MSYS2 アプリケーションではなく、プラットフォームに基づき mingw64.exe またはmingw32.exe が開かれていることを確認します。MSYS2 アプリケーションは、MSYS2 のインストール終了後に、デフォルトで開かれるアプリケーションです。

2. MinGW シェルで次のコマンドを実行して Git をインストールします。

pacman -S git

3. GitHub から Kinesis ビデオストリーム プロデューサー SDK をダウンロードします。

git clone --recursive https://github.com/awslabs/amazon-kinesis-video-streams-producer-sdk-cpp.git

4. 次のコマンドを実行して、ダウンロードした SDK に build ディレクトリを作成し、そこから cmakeを実行します。

67

Page 74: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドWindows で C++ プロデューサー SDK を使用する

mkdir -p amazon-kinesis-video-streams-producer-c/build; cd amazon-kinesis-video-streams-producer-c/build; cmake ..

次のオプションを cmake .. に渡すことができます。

• -DBUILD_DEPENDENCIES - ソースから依存ライブラリを構築するかどうか• -DBUILD_TEST=TRUE - ユニット/統合テストを構築します。お使いのデバイスのサポートを確認す

るのに役立ちます。

./tst/webrtc_client_test

• -DCODE_COVERAGE - カバレッジレポートを有効にします• -DCOMPILER_WARNINGS - すべてのコンパイラの警告を有効にします• -DADDRESS_SANITIZER - AddressSanitizer を使用して構築します• -DMEMORY_SANITIZER - MemorySanitizer を使用して構築します• -DTHREAD_SANITIZER - ThreadSanitizer を使用して構築します• -DUNDEFINED_BEHAVIOR_SANITIZER - UndefinedBehaviorSanitizer を使用して構築します• -DALIGNED_MEMORY_MODEL - アライメントされたメモリモデルのみのデバイス用に構築します。

デフォルトは OFF です。5. 上記のステップで作成した build ディレクトリに移動し、nmake を実行して SDK とその提供サンプ

ルを構築します。

nmake

プロデューサー SDK を実行して Kinesis ビデオストリーム にビデオを送信する

MinGW を使用して Kinesis ビデオストリーム プロデューサー SDK をコンパイルしたら、次のステップに従って実行します。

ステップ 1: 環境変数を設定する

• MinGW シェルで次の環境変数を設定します。

export AWS_ACCESS_KEY_ID=YOUR_ACCESS_KEYexport AWS_SECRET_ACCESS_KEY=YOUR_SECRET_ACCESS_KEYexport GST_PLUGIN_PATH=$PWD

Note

YOUR_ACCESS_KEY および YOUR_SECRET_ACCESS_KEY は AWS アカウントのアクセスキーで、AWS へのプログラムによるリクエストの署名に使用されます。詳細については、「IAM ユーザーのアクセスキーの管理」を参照してください。

ステップ 2: メディアソースのサンプルアプリケーションを実行する

1. PC ウェブカメラからビデオをストリーミングするには、次のコマンドを使用して samples フォルダからサンプルアプリケーションを実行します。

kinesis_video_gstreamer_sample_app.exe my-stream-name

68

Page 75: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドRaspberry Pi で C++ プロデューサー SDK を使用する

2. 特定のビットレートや解像度など、カスタム設定を使用して PC ウェブカメラからビデオをストリーミングするには、次の gst-launch-1.0 コマンドを使用して Kinesis ビデオストリーム プロデューサー SDK GStreamer プラグインを実行します。

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

gst-launch-1.0 コマンドのパラメータの詳細については、「GStreamer エレメントパラメータのリファレンス (p. 143)」 を参照してください。

Note

アクセスキーおよびシークレットキーの代わりに IoT 認証情報を認証に使用している場合は、gst-launch-1.0 コマンドに IoT 認証情報をパラメータとして渡すことができます。次の例では、IoT パラメータを使用して RTSP カメラからビデオをストリーミングする方法が示されています。

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. RTSP (ネットワーク) カメラからビデオをストリーミングするには、次のコマンドを使用してsamples フォルダからサンプルアプリケーションを実行します。

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

Raspberry Pi で C++ プロデューサー SDK を使用するRaspberry Pi は、基本的なコンピュータプログラミングスキルを説明して学習するために使用される小さく安価なコンピュータです。このチュートリアルでは、Raspberry Pi デバイスで Amazon Kinesis ビデオストリーム C++ プロデューサー SDK をセットアップして使用する方法を説明します。この手順には、GStreamer デモアプリケーションを使用してインストールを検証する方法も含まれています。

トピック• 前提条件 (p. 69)• Kinesis ビデオストリーム に書き込むアクセス権限がある IAM ユーザーを作成する (p. 70)• Raspberry Pi を Wi-Fi ネットワークに接続する (p. 71)• Raspberry Pi をリモート接続する (p. 71)• Raspberry Pi カメラを設定する (p. 72)• 前提条件となるソフトウェアをインストールする (p. 72)• Kinesis ビデオストリーム C++ プロデューサー SDK をダウンロードして構築する (p. 73)• Kinesis 動画ストリームで動画をストリームし、ライブストリームを表示する (p. 74)

前提条件Raspberry Pi で C++ プロデューサー SDK をセットアップする前に、次の前提条件が完備されていることを確認してください。

69

Page 76: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドRaspberry Pi で C++ プロデューサー SDK を使用する

• 以下の設定の Raspberry Pi デバイス• Board バージョン: 3 Model B 以降。• 接続されたカメラモジュール。• 少なくとも 8 GB の容量がある SD カード。• Raspbian オペレーティングシステム (カーネルバージョン 4.9 以降) がインストールされている。

最新の Raspbian イメージは、Raspberry Pi Foundation ウェブサイト からダウンロードできます。Raspberry Pi ガイドの「SD カードにダウンロードしたイメージをインストールする」に従います。

• Kinesis ビデオストリーム がある AWS アカウント。詳細については、「Kinesis ビデオストリーム の使用開始」を参照してください。

Note

C++ Producer SDK では、デフォルトで 米国西部 (オレゴン) (us-west-2) リージョンが使用されます。デフォルトの AWS リージョンを使用するには、米国西部 (オレゴン) リージョンでKinesis ビデオストリーム を作成します。Kinesis ビデオストリーム で別のリージョンを使用するには、以下のいずれかの操作を行います。• 次の環境変数を該当リージョンに設定します (例: us-east-1)。

export AWS_DEFAULT_REGION=us-east-1

Kinesis ビデオストリーム に書き込むアクセス権限がある IAMユーザーを作成するまだ実行していない場合には、Kinesis ビデオストリーム に書き込むアクセス権限がある AWS Identityand Access Management (IAM) ユーザーを設定します。

1. AWS マネジメントコンソール にサインインし、IAM コンソール(https://console.aws.amazon.com/iam/)を開きます。

2. 左側のナビゲーションメニューで [ユーザー] を選択します。3. 新規ユーザーを作成するには、[ユーザーを追加] を選択します。4. ユーザーにわかりやすい [ユーザー名] を提供します (kinesis-video-raspberry-pi-producer

など)。5. [アクセスの種類] で、[プログラムによるアクセス] を選択します。6. [Next: Permissions (次へ: アクセス許可)] を選択します。7. [Set permissions for kinesis-video-raspberry-pi-producer (kinesis-video-raspberry-pi-producer にアクセ

ス許可を設定する)] で [既存のポリシーを直接アタッチ] を選択します。8. [Create policy] を選択します。[ポリシーの作成] ページが新しいウェブブラウザタブで開きます。9. [JSON] タブを選択します。10. 次の JSON ポリシーをコピーし、テキスト欄に貼り付けます。このポリシーでは、Kinesis ビデオス

トリームにデータを作成して書き込むアクセス許可をユーザーに付与します。

{ "Version": "2012-10-17", "Statement": [{ "Effect": "Allow", "Action": [ "kinesisvideo:DescribeStream", "kinesisvideo:CreateStream", "kinesisvideo:GetDataEndpoint", "kinesisvideo:PutMedia" ],

70

Page 77: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドRaspberry Pi で C++ プロデューサー SDK を使用する

"Resource": [ "*" ] }]}

11. [ポリシーの確認] を選択します。12. kinesis-video-stream-write-policy など、ポリシーに [Name (名前)] をつけます。13. [Create policy] を選択します。14. ブラウザで [ユーザーを追加] タブに戻り、[Refresh (更新)] を選択します。15. 検索ボックスに作成したポリシーの名前を入力します。16. リストの作成した新しいポリシーの横のチェックボックスを選択します。17. [Next: Review] を選択します。18. [Create user] を選択します。19. コンソールには、新規ユーザーの [アクセスキー ID] が表示されます。[表示] を選択して、[シークレッ

トアクセスキー] を表示します。この値を記録します。アプリケーションを設定するときに、この値が必要となります。

Raspberry Pi を Wi-Fi ネットワークに接続するRaspberry Pi をヘッドレスモードで使用できます。これは、アタッチされたキーボード、モニターあるいはネットワークケーブルがないモードです。アタッチされたモニターおよびキーボードを使用する場合には、「Raspberry Pi カメラを設定する (p. 72)」に進みます。

1. コンピュータに wpa_supplicant.conf という名前のファイルを作成します。2. 以下のテキストをコピーし、wpa_supplicant.conf ファイルにペーストしてください。

country=USctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdevupdate_config=1

network={ssid="<YOUR_WIFI_SSID>"scan_ssid=1key_mgmt=WPA-PSKpsk="<YOUR_WIFI_PASSWORD>"}

ssid と psk 値を使用する Wi-Fi ネットワークの情報に置き換えます。3. wpa_supplicant.conf ファイルを SD カードにコピーします。boot ボリュームのルートにコピー

する必要があります。4. Raspberry Pi に SD カードを挿入し、デバイスの電源を入れます。Wi-Fi ネットワークに接続

し、SSH が有効になります。

Raspberry Pi をリモート接続するRaspberry Pi をヘッドレスモードでリモート接続できます。Raspberry Pi にモニターおよびキーボードを接続して使用する場合は、「Raspberry Pi カメラを設定する (p. 72)」に進みます。

1. Raspberry Pi デバイスにリモートで接続する前に、IP アドレスを確認するために次のいずれかを実行します。

• ネットワークの Wi-Fi ルーターにアクセスできる場合には、接続した Wi-Fi デバイスを探します。Raspberry Pi という名前のデバイスを検索して、デバイスの IP アドレスを探します。

71

Page 78: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドRaspberry Pi で C++ プロデューサー SDK を使用する

• ネットワークの Wi-Fi ルーターにアクセスできない場合には、ネットワーク上のデバイスを検索する他のソフトウェアを使用できます。Fing は、Android と iOS デバイスのどちらでも利用できる広く使用されているアプリケーションです。このアプリケーションの無償バージョンを使用して、ネットワーク上のデバイスの IP アドレスを見つけることができます。

2. Raspberry Pi デバイスの IP アドレスがわかっている場合には、任意のターミナルアプリケーションを使用して接続できます。

• macOS や Linux では、ssh を使用します。

$ ssh pi@<IP address>

• Windows では、Windows 向けの無料の SSH クライアントである PuTTY を使用します。

新規にインストールした Raspbian では、ユーザー名は pi、パスワードは raspberry です。このデフォルトパスワードを変更することが推奨されます。

Raspberry Pi カメラを設定する以下のステップを実行して Raspberry Pi カメラを設定し、デバイスから Kinesis ビデオストリーム に動画を送信します。

1. エディタを開き、modules ファイルを次のコマンドで更新します。

$ sudo nano /etc/modules

2. ファイルの末尾に次の行を追加します (既存しない場合)。

bcm2835-v4l2

3. ファイルを保存し、エディタを終了します (Ctrl-X)。4. Raspberry Pi の再起動。

$ sudo reboot

5. デバイスが再起動したら、リモート接続の場合には、ターミナルアプリケーションから再度接続します。

6. オープン raspi-config:

$ sudo raspi-config

7. [Interfacing Options (インターフェイスオプション)]、[カメラ] を選択します。カメラを有効にしていない場合は有効にし、プロンプトされる場合には再起動します。

8. 次のコマンドを入力して、カメラが正常に機能することを確認します。

$ raspistill -v -o test.jpg

画面にはカメラの 5 秒間のプレビューが表示され、写真が保存され (test.jpg に保存)、情報メッセージが表示されます。

前提条件となるソフトウェアをインストールするC++ プロデューサー SDK では、Raspberry Pi に次の前提条件ソフトウェアがインストールされていることが必要となります。

72

Page 79: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドRaspberry Pi で C++ プロデューサー SDK を使用する

1. Git をインストールします:

$ sudo apt-get update$ sudo apt-get install git

2. Yacc、Lex、OpenJDK (Open Java Development Kit) のインストール。

$ sudo apt-get install byacc flex$ sudo apt-get install openjdk-8-jdk

3. JAVA_HOME 環境変数を設定します:

$ export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-armhf/

Note

SDK を構築する前にデバイスを再起動する場合には、このステップを繰り返す必要があります。また、~/.profile ファイルでこの環境変数を設定することもできます。

4. CMake は SDK の構築に使用されます。次のコマンドを使用して CMake をインストールします。

$ sudo apt-get install cmake

5. 次の PEM ファイルを /etc/ssl/cert.pem にコピーします。

https://www.amazontrust.com/repository/SFSRootCAG2.pem

Kinesis ビデオストリーム C++ プロデューサー SDK をダウンロードして構築する下記の手順に従って Kinesis Video Streams C++ Producer SDK をダウンロードおよび構築することもできます。ネットワーク接続やプロセッサの速度によっては、この方法の方が構築時間が長くなる場合があります。

1. 次のコマンドを実行して、ダウンロードした SDK に build ディレクトリを作成し、そこから cmakeを実行します。

mkdir -p amazon-kinesis-video-streams-producer-c/build; cd amazon-kinesis-video-streams-producer-c/build; cmake ..

次のオプションを cmake .. に渡すことができます。

• -DBUILD_DEPENDENCIES - ソースから依存ライブラリを構築するかどうか• -DBUILD_TEST=TRUE - ユニット/統合テストを構築します。お使いのデバイスのサポートを確認す

るのに役立ちます。

./tst/webrtc_client_test

• -DCODE_COVERAGE - カバレッジレポートを有効にします• -DCOMPILER_WARNINGS - すべてのコンパイラの警告を有効にします• -DADDRESS_SANITIZER - AddressSanitizer を使用して構築します• -DMEMORY_SANITIZER - MemorySanitizer を使用して構築します• -DTHREAD_SANITIZER - ThreadSanitizer を使用して構築します

73

Page 80: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドRaspberry Pi で C++ プロデューサー SDK を使用する

• -DUNDEFINED_BEHAVIOR_SANITIZER - UndefinedBehaviorSanitizer を使用して構築します• -DALIGNED_MEMORY_MODEL - アライメントされたメモリモデルのみのデバイス用に構築します。

デフォルトは OFF です。2. 上記のステップで作成した build ディレクトリに移動し、make を実行して SDK とその提供サンプ

ルを構築します。

make

3. インストールスクリプトを実行可能にする。

$ chmod +x install-script

4. インストールスクリプトを実行します。このスクリプトは、ソースをダウンロードして、複数のオープンソースプロジェクトを構築します。初めて実行する場合には、実行に数時間要する場合があります。

./install-script

5. Y と入力して確認します。構築スクリプトが実行されます。

Kinesis 動画ストリームで動画をストリームし、ライブストリームを表示する1. サンプルアプリケーションを実行するには、次の情報が必要です。

• 「前提条件 (p. 69)」セクションで作成したストリームの名前。• 「Kinesis ビデオストリーム に書き込むアクセス権限がある IAM ユーザーを作成する (p. 70)」

で作成したアカウントの認証情報 (アクセスキー ID およびシークレットアクセスキー)。2. 次のコマンドを使用してサンプルアプリケーションを実行します。

$ export AWS_ACCESS_KEY_ID=<Access Key ID> export AWS_SECRET_ACCESS_KEY=<Secret Access Key> ./kinesis_video_gstreamer_sample_app Stream Name

3. 次のように、画像サイズ、フレームレート、ビットレートを指定できます。

$ export AWS_ACCESS_KEY_ID=<Access Key ID> export AWS_SECRET_ACCESS_KEY=<Secret Access Key> ./kinesis_video_gstreamer_sample_app -w <width> -h <height> -f <framerate> -b <bitrateInKBPS> Stream Name

4. サンプルアプリケーションが library not found エラーで終了した場合、次のコマンドを入力して、プロジェクトがオープンソース依存関係に正しくリンクされていることを確認します。

$ rm -rf ./build/CMakeCache.txt ./build/CMakeFiles$ ./build/install-script

5. Kinesis ビデオストリーム コンソール (https://console.aws.amazon.com/kinesisvideo/)を開きます。6. 作成したストリームの [ストリーム名] を選択します。

Raspberry Pi から送信された動画ストリームがコンソールに表示されます。

74

Page 81: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドログ記録の使用

ストリームを再生するときに、Kinesis ビデオストリーム コンソールの次の機能を試すことができます。

• [ビデオのプレビュー] セクションから、ナビゲーションコントロールを使用しストリームの巻き戻しまたは早送りを行います。

• [ストリーム情報] セクションで、ストリームのコーデック、解像度、ビットレートに注目してます。このチュートリアルの帯域幅の使用量を最小限に抑えるために、Raspberry Pi の解像度とビットレート値は意図的に低く設定されています。ストリーム用に作成された Amazon CloudWatch メトリクスを表示するには、[CloudWatch でのストリームメトリクスの表示] を選択します。

• [データ保持期間] で、ビデオストリームが 1 日間保持されることに注目します。この値を編集して [Nodata retention (データを保持しない)] 設定、あるいは 1 日から数年までの値に設定できます。

サーバー側の暗号化で、AWS Key Management Service (AWS KMS) によって維持されるキーを使用してデータが保管時に暗号化されることに注目します。

C++ プロデューサー SDK でのログ記録の使用C++ プロデューサー SDK アプリケーションのログ記録は、kvs_log_configuration フォルダのkinesis-video-native-build ファイルで設定します。

次の例は、デフォルト設定ファイルの最初の行を示しています。この行で、DEBUG レベルのログエントリを AWS マネジメントコンソール に書き込むようにアプリケーションを設定します。

log4cplus.rootLogger=DEBUG, KvsConsoleAppender

詳細度が低いログ記録の場合は、ログ記録レベルを INFO に設定できます。

ログエントリをログファイルにも書き込むようにアプリケーションを設定するには、ファイルの最初の行を次のように更新します。

log4cplus.rootLogger=DEBUG, KvsConsoleAppender, KvsFileAppender

これにより、kvs.log フォルダの kinesis-video-native-build/log にログエントリを書き込むようにアプリケーションが設定されます。

ログファイルの場所を変更するには、次の行を新しいパスで更新します。

log4cplus.appender.KvsFileAppender.File=./log/kvs.log

Note

DEBUG レベルのログ記録をファイルに書き込むと、ログファイルはデバイスの使用可能なストレージスペースをすぐに消費してしまう場合があります。

C プロデューサーライブラリの使用Amazon Kinesis ビデオストリーム は C プロデューサーライブラリを提供します。このライブラリを使用すると、アプリケーションコードを記述して、デバイスから Kinesis ビデオストリーム にメディアデータを送信できます。

オブジェクトモデルKinesis ビデオストリーム C プロデューサーライブラリは、プラットフォームに依存しないコードベース (PIC) と呼ばれる共通コンポーネントに基づきます。このコードベースは、GitHub (https://github.com/awslabs/amazon-kinesis-video-streams-producer-sdk-cpp/tree/master/kinesis-video-pic) で入手できま

75

Page 82: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドストリームへのメディアの挿入

す。PIC には、低レベル用のプラットフォームに依存しないビジネスロジックが含まれています。Kinesisビデオストリーム の C プロデューサーライブラリは、シナリオ固有およびプラットフォーム固有のコールバックとイベントシナリオを許可する API の追加レイヤーで PIC をラップします。Kinesis ビデオストリーム の C プロデューサーライブラリには、PIC 上に構築された以下のコンポーネントがあります。

• デバイス情報プロバイダー – PIC API に直接提供できる DeviceInfo 構造を公開します。アプリケーションが処理するストリームの数およびタイプに基づいたコンテンツストアと利用可能な RAM の量に基づいて設定された必要なバッファリングの量を最適化できるアプリケーションシナリオに最適化されたプロバイダーなど、一連の設定しやすいプロバイダーがあります。

• ストリーム情報プロバイダー – PIC API に直接提供できる StreamInfo 構造を公開します。アプリケーションタイプおよびストリーミングシナリオの一般的なタイプに固有の設定しやすい一連のプロバイダーがあります。これらには、動画、音声、音声/動画のマルチトラックなどのプロバイダーが含まれています。これらの各シナリオには、アプリケーションの要件に応じてカスタマイズできるデフォルト設定があります。

• コールバックプロバイダー – PIC API に直接提供できる ClientCallbacks 構造を公開します。これには、ネットワーキング (CURL ベースの API コールバック)、認証 (AWS 認証情報 API)、エラーのコールバックでのストリーミングの再試行などに設定しやすい一連のコールバックプロバイダーが含まれています。コールバックプロバイダー API は、AWS リージョンと認証情報 (IoT 証明書を介した、またはAWS AccessKeyId、SecretKey、SessionToken を通じた) など、設定する数多くの引数を取ります。アプリケーションでアプリケーション固有のロジックを実現するために特定のコールバックをさらに処理する必要がある場合、カスタムコールバックでコールバックプロバイダーを拡張することができます。

• FrameOrderCoordinator – マルチトラックのシナリオ用に音声と動画の同期の処理に役立ちます。これには、アプリケーションの特定のロジックを処理するためにカスタマイズできるデフォルトの動作があります。また、フレームメタデータパッケージングを下位レイヤーの PIC API に送信する前に、PIC フレーム構造でそのパッケージングを簡素化します。マルチトラック以外のシナリオの場合、このコンポーネントは PIC putFrame API へのパススルーです。

C ライブラリには、Kinesis ストリームへのデータ送信を管理するために次のオブジェクトが用意されています。

• KinesisVideoClient – デバイス情報に関する情報が含まれ、Kinesis ビデオストリーム イベントに関する報告を行うためのコールバックを管理します。

• KinesisVideoStream – 名前、データ保持期間、メディアコンテンツタイプなど、ビデオストリームのパラメータに関する情報を表します。

ストリームへのメディアの挿入C ライブラリには、データを KinesisVideoStream オブジェクトに挿入するために使用できるメソッド(PutKinesisVideoFrame など) が用意されています。ライブラリは、データの内部状態も管理します。タスクには以下が含まれる場合があります。

• 認証を実行する。• ネットワークレイテンシーを監視する。レイテンシーが長すぎると、フレームが停止される場合があり

ます。• 進行中のストリーミングのステータスを追跡する。

手順: C プロデューサー SDK を使用するこの手順では、C アプリケーションで Kinesis ビデオストリーム クライアントおよびメディアソースを使用して H.264 でエンコードされた動画フレームを Kinesis ビデオストリーム に送信する方法について説明します。

この手順には、以下のステップが含まれます。

76

Page 83: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイド手順: C プロデューサー SDK を使用する

• ステップ 1: C プロデューサーライブラリコードをダウンロードする (p. 78)• ステップ 2: コードを作成してテストする (p. 79)• ステップ 3: コードを実行して検証する (p. 81)

前提条件• 認証情報 – サンプルコードで、AWS 認証情報プロファイルファイルで設定したプロファイルを指定し

て、認証情報を提供します。まず、認証情報プロファイルを設定します (まだ設定していない場合)。

詳細については、「開発用の AWS 認証情報とリージョンのセットアップ」を参照してください。• 証明書ストアの統合 – Kinesis ビデオストリーム プロデューサーライブラリが、呼び出し対象のサービ

スと信頼を確立する必要があります。この信頼は、正式な証明書ストアで証明機関 (CA) を検証することで確立されます。Linux ベースのモデルの場合、このストアは /etc/ssl/ ディレクトリにあります。

以下の場所から証明書ストアに、証明書をダウンロードしてください。

https://www.amazontrust.com/repository/SFSRootCAG2.pem• macOS 用の次のビルド依存関係をインストールします。

• Autoconf 2.69 (ライセンス GPLv3+/Autoconf: GNU GPL バージョン 3 以降)• CMake 3.または 3.8• Pkg-Config• Flex 2.5.35 Apple (flex-31) 以降• Bison 2.4 (GNU ライセンス)• Automake 1.15.1 (GNU ライセンス)• GNU Libtool (Apple Inc. バージョン cctools-898)• xCode (macOS) / clang / gcc (xcode-select バージョン 2347)• Java Development Kit (JDK) (Java JNI コンパイル用)• Lib-Pkg

• Ubuntu 用の次のビルド依存関係をインストールします (バージョンコマンドへの応答は切り捨てられます)。• Git をインストールします: sudo apt-get install git

$ git --versiongit version 2.14.1

• CMake をインストールします: sudo apt-get install cmake

$ cmake --versioncmake version 3.9.1

• Libtool をインストールします: sudo apt-get install libtool

2.4.6-2

• libtool-bin をインストールします: sudo apt-get install libtool-bin

$ libtool --versionlibtool (GNU libtool) 2.4.6Written by Gordon Matzigkeit, 1996

• GNU Automake をインストールします: sudo apt-get install automake

$ automake --version

77

Page 84: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドステップ 1: コードをダウンロードする

automake (GNU automake) 1.15

• GNU Bison をインストールします: sudo apt-get install bison

$ bison -Vbison (GNU Bison) 3.0.4

• G++ をインストールします: sudo apt-get install g++

g++ --versiong++ (Ubuntu 7.2.0-8ubuntu3) 7.2.0

• curl をインストールします: sudo apt-get install curl

$ curl --versioncurl 7.55.1 (x86_64-pc-linux-gnu) libcurl/7.55.1 OpenSSL/1.0.2g zlib/1.2.11 libidn2/2.0.2 libpsl/0.18.0 (+libidn2/2.0.2) librtmp/2.3

• pkg-config をインストールします: sudo apt-get install pkg-config

$ pkg-config --version0.29.1

• Flex をインストールします: sudo apt-get install flex

$ flex --versionflex 2.6.1

• OpenJDK をインストールします: sudo apt-get install openjdk-8-jdk

$ java -versionopenjdk version "1.8.0_171"

• JAVA_HOME 環境変数を設定します: export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/

• ビルドスクリプトを実行します: ./install-script

次のステップステップ 1: C プロデューサーライブラリコードをダウンロードする (p. 78)

ステップ 1: C プロデューサーライブラリコードをダウンロードするこのセクションでは、低レベルのライブラリをダウンロードします。この例の前提条件その他の詳細については、「C プロデューサーライブラリの使用」を参照してください。

1. ディレクトリを作成して、GitHub リポジトリのソースコード例からクローンを作成します。

git clone --recursive https://github.com/awslabs/amazon-kinesis-video-streams-producer-c.git

78

Page 85: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドステップ 2: コードを作成してテストする

Note

--recursive を使用して Git クローンを実行しなかった場合は、amazon-kinesis-video-streams-producer-c/open-source ディレクトリで git submodule update--init を実行してください。また、pkg-config、automake、CMake、およびビルド環境をインストールする必要があります。詳細については、https://github.com/awslabs/amazon-kinesis-video-streams-producer-c.git のREADME.md を参照してください。

2. 任意の統合開発環境 (IDE) (Eclipse など) でコードを開きます。

次のステップステップ 2: コードを作成してテストする (p. 79)

ステップ 2: コードを作成してテストするこのセクションでは、GitHub の https://github.com/awslabs/amazon-kinesis-video-streams-producer-c リポジトリの samples フォルダにあるサンプルアプリケーション KvsVideoOnlyStreamingSample.cのコードを検証します。このコードは前のステップでダウンロードしたものです。このサンプルでは、Cプロデューサーライブラリを使用してフォルダ samples/h264SampleFrames 内の H.264 エンコードされた動画フレームを Kinesis ビデオストリーム に送信する方法を示します。

このサンプルアプリケーションは次の 3 つのセクションで構成されています。

• 初期化と設定:• プラットフォーム固有のメディアパイプラインの初期化および設定。• パイプラインの KinesisVideoClient および KinesisVideoStream の初期化および設定、コールバックの

設定、シナリオ固有の認証の統合、コーデックプライベートデータの抽出および送信、ストリームの準備完了状態。

• メインループ:• タイムスタンプおよびフラグによるメディアパイプラインからのフレームの取得。• KinesisVideoStream へのフレームの送信。

• Teardown:• KinesisVideoStream の停止 (同期)、KinesisVideoStream の解放、KinesisVideoClient の解放。

このサンプルアプリケーションは以下のタスクを実行します。

• createDefaultDeviceInfo API を呼び出して、デバイスまたはストレージ設定に関する情報が含まれる deviceInfo オブジェクトを作成します。

// default storage size is 128MB. Use setDeviceInfoStorageSize after create to change storage size.CHK_STATUS(createDefaultDeviceInfo(&pDeviceInfo));// adjust members of pDeviceInfo here if needed pDeviceInfo->clientInfo.loggerLogLevel = LOG_LEVEL_DEBUG;

• createRealtimeVideoStreamInfoProvider API を呼び出して、StreamInfo オブジェクトを作成します。

79

Page 86: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドステップ 2: コードを作成してテストする

CHK_STATUS(createRealtimeVideoStreamInfoProvider(streamName, DEFAULT_RETENTION_PERIOD, DEFAULT_BUFFER_DURATION, &pStreamInfo));// adjust members of pStreamInfo here if needed

• createDefaultCallbacksProviderWithAwsCredentials API を呼び出して、静的な AWS 認証情報に基づいてデフォルトのコールバックプロバイダーを作成します。

CHK_STATUS(createDefaultCallbacksProviderWithAwsCredentials(accessKey, secretKey, sessionToken, MAX_UINT64, region, cacertPath, NULL, NULL, FALSE, &pClientCallbacks));

• createKinesisVideoClient API を呼び出して、デバイスに関する情報を格納して Kinesis ビデオストリーム イベントに関する報告を行うためのコールバックを管理する KinesisVideoClient オブジェクトを作成します。

CHK_STATUS(createKinesisVideoClient(pDeviceInfo, pClientCallbacks, &clientHandle));

• createKinesisVideoStreamSync API を呼び出して、KinesisVideoStream オブジェクトを作成します。

CHK_STATUS(createKinesisVideoStreamSync(clientHandle, pStreamInfo, &streamHandle));

• サンプルフレームを設定し、PutKinesisVideoFrame API を呼び出してそのフレームをKinesisVideoStream オブジェクトに送信します。

// setup sample frame MEMSET(frameBuffer, 0x00, frameSize); frame.frameData = frameBuffer; frame.version = FRAME_CURRENT_VERSION; frame.trackId = DEFAULT_VIDEO_TRACK_ID; frame.duration = HUNDREDS_OF_NANOS_IN_A_SECOND / DEFAULT_FPS_VALUE; frame.decodingTs = defaultGetTime(); // current time frame.presentationTs = frame.decodingTs;

while(defaultGetTime() > streamStopTime) { frame.index = frameIndex; frame.flags = fileIndex % DEFAULT_KEY_FRAME_INTERVAL == 0 ? FRAME_FLAG_KEY_FRAME : FRAME_FLAG_NONE; frame.size = SIZEOF(frameBuffer);

CHK_STATUS(readFrameData(&frame, frameFilePath));

CHK_STATUS(putKinesisVideoFrame(streamHandle, &frame)); defaultThreadSleep(frame.duration);

frame.decodingTs += frame.duration; frame.presentationTs = frame.decodingTs;

80

Page 87: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドステップ 3: コードを実行して検証する

frameIndex++; fileIndex++; fileIndex = fileIndex % NUMBER_OF_FRAME_FILES; }

• Teardown:

CHK_STATUS(stopKinesisVideoStreamSync(streamHandle));CHK_STATUS(freeKinesisVideoStream(&streamHandle));CHK_STATUS(freeKinesisVideoClient(&clientHandle));

次のステップステップ 3: コードを実行して検証する (p. 81)

ステップ 3: コードを実行して検証するプロデューサーライブラリ手順用のコードを実行して検証するには、次の操作を行います。

1. 次のコマンドを実行して、ダウンロードした C SDK に build ディレクトリを作成し、そこからcmake を実行します。

mkdir -p amazon-kinesis-video-streams-producer-c/build; cd amazon-kinesis-video-streams-producer-c/build; cmake ..

次のオプションを cmake .. に渡すことができます。

• -DBUILD_DEPENDENCIES - ソースから依存ライブラリを構築するかどうか• -DBUILD_TEST=TRUE - ユニット/統合テストを構築します。お使いのデバイスのサポートを確認す

るのに役立ちます。

./tst/webrtc_client_test

• -DCODE_COVERAGE - カバレッジレポートを有効にします• -DCOMPILER_WARNINGS - すべてのコンパイラの警告を有効にします• -DADDRESS_SANITIZER - AddressSanitizer を使用して構築します• -DMEMORY_SANITIZER - MemorySanitizer を使用して構築します• -DTHREAD_SANITIZER - ThreadSanitizer を使用して構築します• -DUNDEFINED_BEHAVIOR_SANITIZER - UndefinedBehaviorSanitizer を使用して構築します• -DALIGNED_MEMORY_MODEL - アライメントされたメモリモデルのみのデバイス用に構築します。

デフォルトは OFF です。2. 上記のステップで作成した build ディレクトリに移動し、make を実行して WebRTC C SDK とその

提供サンプルを構築します。

make

3. サンプルアプリケーション kinesis_video_cproducer_video_only_sample は、フォルダsamples/h264SampleFrames 内の H.264 でエンコードされた動画フレームを Kinesis ビデオスト

81

Page 88: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドリファレンス

リーム に送信します。次のコマンドは、10 秒ループの動画フレームを Kinesis ビデオストリーム に送信します。

./kinesis_video_cproducer_video_only_sample YourStreamName 10

別のフォルダ (たとえば、MyH264FramesFolder) から H.264 でエンコードされたフレームを送信する場合、以下の引数を指定してサンプルを実行できます。

./kinesis_video_cproducer_video_only_sample YourStreamName 10 MyH264FramesFolder

4. 詳細なログを有効にするには、CMakeList.txt の適切な行をコメント解除し、HEAP_DEBUG およびLOG_STREAMING の C-定義を定義します。

テストスイートの進行状況は、IDE のデバッグ出力で監視できます。ストリームに関連付けられている、PutMedia.IncomingBytes などのメトリクスを Amazon CloudWatch コンソールで監視することで、ストリームのトラフィックを監視することもできます。

Note

テストハーネスでは空のバイトのフレームのみを送信するため、コンソールには動画ストリームとしてのデータは表示されません。

プロデューサー SDK リファレンスこのセクションには、Kinesis ビデオストリーム プロデューサーライブラリ (p. 47) に関する制限、エラーコードやその他の関連情報が含まれています。

トピック• プロデューサー SDK の制限 (p. 82)• エラーコードのリファレンス (p. 84)• Network Abstraction Layer (NAL) 適応フラグを参照 (p. 108)• プロデューサー SDK の構造 (p. 109)• Kinesis ビデオストリームの構造 (p. 110)• プロデューサー SDK コールバック (p. 122)

プロデューサー SDK の制限次の表では、プロデューサーライブラリ (p. 47) における現在の制限値を示しています。

Note

これらの値を設定する前に、入力値を検証する必要があります。SDK ではこれらの制限は検証されません。制限を超えた場合はランタイムエラーが表示されます。

値 制限 コメント

最大ストリームカウント 128 プロデューサーオブジェクトが作成できるストリームの最大数です。これはソフト制限です (増

82

Page 89: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドプロデューサー SDK の制限

値 制限 コメント加をリクエストできます)。これによって、プロデューサーが誤って再帰的にストリームを作成することを防ぎます。

デバイス名の最大の長さ 128 文字  

最大タグカウント ストリームあたり 50  

ストリーム名の最大の長さ 256 文字  

最小ストレージサイズ 10 MiB = 10 x 1024 x 1024 バイト

 

最大ストレージサイズ 10 GiB = 10 x 1024 x 1024 x1024 バイト

 

最大のルートディレクトリの長さ

4,096 文字  

最大の auth info の長さ 10,000 バイト  

最大の URI 文字列の長さ 10,000 文字  

タグ名の最大の長さ 128 文字  

タグ値の最大の長さ 1,024 文字  

最小のセキュリティトークン期間

30 秒  

セキュリティトークン猶予期間 40 分 指定する期間がより長い場合には、この値に制限されます。

保持期間 0 または 1 時間以上 0 は保持なしを示します。

最小クラスター期間 1 秒 この値は、100 NS ユニットに指定されます (SDK 標準)。

最大クラスター期間 30 秒 この値は、100 NS ユニットに指定されます (SDK 標準)。バックエンド API では、より短いクラスター期間が適用される場合があります。

ラグメントの最大サイズ 50 MB 詳細については、「Kinesis ビデオストリーム の制限 (p. 174)」を参照してください。

最大フラグメント期間 10 秒 詳細については、「Kinesis ビデオストリーム の制限 (p. 174)」を参照してください。

最大接続時間 45 分 この時間後にバックエンドは接続を終了します。SDK はトークンをローテーションして、この時間内で新しい接続を確立します。

83

Page 90: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドエラーコードのリファレンス

値 制限 コメント

ACK セグメントの最大の長さ 1,024 文字 ACK パーサー関数に送信される確認セグメントの最大の長さ。

コンテンツタイプ文字列の最大の長さ

128 文字  

コーデック ID 文字列の最大の長さ

32 文字  

トラック名文字列の最大の長さ 32 文字  

コーデックプライベートデータの最大の長さ

1 MiB = 1 x 1024 x 1024 バイト

 

タイムコードスケール値の最小の長さ

100 ns 生成した MKV クラスターのフレームタイムスタンプを表す最小のタイムコードスケール値です。この値は、100 NS 増加して指定されます (SDK 標準)。

タイムコードスケール値の最大の長さ

1 秒 生成した MKV クラスターのフレームタイムスタンプを表す最大のタイムコードスケール値です。この値は、100 NS 増加して指定されます (SDK 標準)。

コンテンツビュー項目の最小数 10  

最小のバッファ時間 20 秒 この値は、100 NS 増加して指定されます (SDK 標準)。

アップデートバージョンの最大の長さ

128 文字  

ARN の最大の長さ 1024 文字  

フラグメントシーケンスの最大の長さ

128 文字  

最大保持期間 10 年  

エラーコードのリファレンスこのセクションには、プロデューサーライブラリ (p. 47) のエラーおよびステータスコード情報が含まれています。

一般的な問題のソリューションについては、「Kinesis ビデオストリーム のトラブルシューティング (p. 179)」を参照してください。

トピック• PutFrame コールバックによって返されるエラーおよびステータスコード - プラットフォームに依存し

ないコード (PIT) (p. 85)• PutFrame コールバックによって返されるエラーおよびステータスコード - C プロデューサーライブラ

リ (p. 106)

84

Page 91: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドエラーコードのリファレンス

PutFrame コールバックによって返されるエラーおよびステータスコード - プラットフォームに依存しないコード (PIT)以下のセクションには、プラットフォームに依存しないコードベース (PIT) 内の PutFrame 操作のコールバックによって返されるエラーおよびステータス情報が含まれています。

トピック• クライアントライブラリによって返されるエラーおよびステータスコード (p. 85)• Duration ライブラリによって返されるエラーおよびステータスコード (p. 98)• Common ライブラリによって返されるエラーおよびステータスコード (p. 98)• Heap ライブラリによって返されるエラーおよびステータスコード (p. 99)• MKVGen ライブラリによって返されるエラーおよびステータスコード (p. 101)• Trace ライブラリによって返されるエラーおよびステータスコード (p. 104)• Utils ライブラリによって返されるエラーおよびステータスコード (p. 105)• View ライブラリによって返されるエラーおよびステータスコード (p. 105)

クライアントライブラリによって返されるエラーおよびステータスコード次の表では、Kinesis ビデオストリーム Client ライブラリのメソッドによって返されるエラーと状態の情報を示しています。

コード メッセージ 説明 推奨されるアクション

0x52000001 STATUS_MAX_STREAM_COUNTストリームの最大数に達しました。

「プロデューサー SDK の制限 (p. 82)」で説明するように、DeviceInfo で最大のストリーム数を指定します。

0x52000002 STATUS_MIN_STREAM_COUNT最小ストリーム数エラー。

DeviceInfo で、ストリームの最大数を 0 以上で指定します。

0x52000003 STATUS_INVALID_DEVICE_NAME_LENGTH無効なデバイス名の長さ。

プロデューサー SDK の制限 (p. 82) で指定される最大のデバイス名の文字の長さを参照します。

0x52000004 STATUS_INVALID_DEVICE_INFO_VERSION無効な DeviceInfo構造バージョン。

構造体の正しいバージョンを指定します。

0x52000005 STATUS_MAX_TAG_COUNT タグの最大数に達しました。

プロデューサー SDK の制限 (p. 82) に指定される最大タグ数を参照します。

0x52000006 STATUS_DEVICE_FINGERPRINT_LENGTH

0x52000007 STATUS_INVALID_CALLBACKS_VERSION無効な Callbacks 構造バージョン。

構造体の正しいバージョンを指定します。

0x52000008 STATUS_INVALID_STREAM_INFO_VERSION無効な StreamInfo構造バージョン。

構造体の正しいバージョンを指定します。

0x52000009 STATUS_INVALID_STREAM_NAME_LENGTH無効なストリーム名の長さ。

プロデューサー SDK の制限 (p. 82) で指定される最

85

Page 92: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドエラーコードのリファレンス

コード メッセージ 説明 推奨されるアクション大のストリーム名の文字の長さを参照します。

0x5200000a STATUS_INVALID_STORAGE_SIZE無効なストレージサイズが指定されました。

バイト単位のストレージサイズは、プロデューサー SDKの制限 (p. 82) で指定される制限内である必要があります。

0x5200000b STATUS_INVALID_ROOT_DIRECTORY_LENGTHルートディレクトリの文字列の長さが無効です。

プロデューサー SDK の制限 (p. 82) で指定される最大のルートディレクトリのパスの長さを参照します。

0x5200000c STATUS_INVALID_SPILL_RATIO無効なスピル比率。 スピル比率を 0 ~ 100 までのパーセント表示で示します。

0x5200000d STATUS_INVALID_STORAGE_INFO_VERSION無効な StorageInfo構造バージョン。

構造体の正しいバージョンを指定します。

0x5200000e STATUS_INVALID_STREAM_STATEストリームが現在のオペレーションを許可しない状態にあります。

通常の場合、このエラーは SDK がリクエストされたオペレーションの実行に必要な状態に達していない場合に生じます。たとえば、GetStreamingEndpointAPI 呼び出しが失敗し、クライアントアプリケーションがこれを無視してストリームにフレームを送り続ける場合などに発生します。

0x5200000f STATUS_SERVICE_CALL_CALLBACKS_MISSINGCallbacks 構造に一部の必須関数でエントリポイントの関数が欠落しています。

必須のコールバックがクライアントアプリケーションに実装されていることを確認します。このエラーは PIC (プラットフォーム独立コード)クライアントでのみ発生します。C++ や他のより高レベルのラッパーはこの呼び出しに対応します。

0x52000010 STATUS_SERVICE_CALL_NOT_AUTHORIZED_ERROR権限がありません。 セキュリティトークン、証明書、セキュリティトークン統合、期限を確認します。トークンに正しい権限が関連付けられていることを確認します。Kinesis ビデオストリーム のサンプルアプリケーションでは、環境変数が正しく設定されていることを確認します。

86

Page 93: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドエラーコードのリファレンス

コード メッセージ 説明 推奨されるアクション

0x52000011 STATUS_DESCRIBE_STREAM_CALL_FAILEDDescribeStreamAPI エラー。

DescribeStream API 再試行エラーのあとにこのエラーが返されます。PIC クライアントは、再試行の失敗後にこのエラーを返します。

0x52000012 STATUS_INVALID_DESCRIBE_STREAM_RESPONSE無効なDescribeStreamResponse構造体。

DescribeStreamResultEventに渡された構造体が null あるいは、無効な Amazon リソースネーム (ARN) のような無効な項目を含んでいます。

0x52000013 STATUS_STREAM_IS_BEING_DELETED_ERRORストリームが削除されています。

ストリームが削除されているため、API エラーが生じます。ストリームを使用中に、他のプロセスがこのストリームの削除を試行していないことを確認します。

0x52000014 STATUS_SERVICE_CALL_INVALID_ARG_ERRORサービス呼び出しに無効な引数が指定されています。

サービス呼び出しの引数が無効である、あるいは SDK が解釈できないエラーが発生した場合に、バックエンドはこのエラーを返します。

0x52000015 STATUS_SERVICE_CALL_DEVICE_NOT_FOUND_ERRORデバイスが見つかりませんでした。

デバイスが使用中に削除されていないことを確認します。

0x52000016 STATUS_SERVICE_CALL_DEVICE_NOT_PROVISIONED_ERRORデバイスがプロビジョニングされていません。

デバイスがプロビジョニングされていることを確認します。

0x52000017 STATUS_SERVICE_CALL_RESOURCE_NOT_FOUND_ERRORこのサービスから汎用的なリソースが返されていません。

サービスがリソース (ストリームなど) を検出できない場合にこのエラーが発生します。これには、さまざまな場面での多様な意味を持つ場合がありますが、ストリームが作成される以前の API の使用状況が原因であることがよくあります。SDK を使用すると、まずストリームを作成することを確保できます。

0x52000018 STATUS_INVALID_AUTH_LEN無効な auth info の長さ。

プロデューサー SDK の制限 (p. 82) で指定されている現在の値を参照します。

0x52000019 STATUS_CREATE_STREAM_CALL_FAILEDCreateStream APIの呼び出しに失敗しました。

エラー文字列でこのオペレーションが失敗した理由についての詳細情報を参照します。

0x5200002a STATUS_GET_STREAMING_TOKEN_CALL_FAILEDGetStreamingTokenの呼び出しに失敗しました。

エラー文字列でこのオペレーションが失敗した理由についての詳細情報を参照します。

87

Page 94: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドエラーコードのリファレンス

コード メッセージ 説明 推奨されるアクション

0x5200002b STATUS_GET_STREAMING_ENDPOINT_CALL_FAILEDGetStreamingEndpointAPI の呼び出しに失敗しました。

エラー文字列でこのオペレーションが失敗した理由についての詳細情報を参照します。

0x5200002c STATUS_INVALID_URI_LEN GetStreamingEndpointAPI から無効な長さのURI 文字列が返されます。

プロデューサー SDK の制限 (p. 82) で指定されている現在の最大値を参照します。

0x5200002d STATUS_PUT_STREAM_CALL_FAILEDPutMedia API の呼び出しに失敗しました。

エラー文字列でこのオペレーションが失敗した理由についての詳細情報を参照します。

0x5200002e STATUS_STORE_OUT_OF_MEMORYコンテンツストアがメモリ不足です。

コンテンツストアはストリーム間で共有され、全ストリーム + ~20% (最適化を考慮して) 分の最大時間を保存するために十分な容量を必要とします。ストレージをオーバーフローしないことは重要です。ストリームごとにストレージサイズとレイテンシー許容値を累積した最大時間の値を選択します。コンテンツの表示ウィンドウから落ちたフレームは、そのままにしておくよりドロップすることが推奨されます (コンテンツの保存メモリプレッシャー)。フレームのドロップがストリームのプレッシャー通知コールバックをトリガーすることがその理由です。これでアプリケーションがビットレートを低める、フレームをドロップするなどの適切な行為を行うためにアップストリームメディアコンポーネント (エンコーダーなど) を調整できます。

0x5200002f STATUS_NO_MORE_DATA_AVAILABLEストリームには現在利用可能なデータがこれ以上ありません。

これは、ネットワーキングスレッドによってサービスに送信されるフレームの消費よりメディアパイプラインが作成する量が遅い場合の潜在的な有効結果です。より高レベルのクライアント (C++、Javaや Android など) では、内部処理されるためこの警告は表示されません。

0x52000030 STATUS_INVALID_TAG_VERSION無効な Tag 構造バージョン。

構造体の正しいバージョンを指定します。

88

Page 95: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドエラーコードのリファレンス

コード メッセージ 説明 推奨されるアクション

0x52000031 STATUS_SERVICE_CALL_UNKNOWN_ERRORネットワーキングスタックから不明な、あるいは汎用的なエラーが返されます。

詳細情報については、ログを参照します。

0x52000032 STATUS_SERVICE_CALL_RESOURCE_IN_USE_ERROR使用中のリソース。 サービスから返されます。詳細については、「Kinesis ビデオストリーム API リファレンス」を参照してください。

0x52000033 STATUS_SERVICE_CALL_CLIENT_LIMIT_ERRORクライアント制限。 サービスから返されます。詳細については、「Kinesis ビデオストリーム API リファレンス」を参照してください。

0x52000034 STATUS_SERVICE_CALL_DEVICE_LIMIT_ERRORデバイス制限。 サービスから返されます。詳細については、「Kinesis ビデオストリーム API リファレンス」を参照してください。

0x52000035 STATUS_SERVICE_CALL_STREAM_LIMIT_ERRORストリーム制限。 サービスから返されます。詳細については、「Kinesis ビデオストリーム API リファレンス」を参照してください。

0x52000036 STATUS_SERVICE_CALL_RESOURCE_DELETED_ERRORリソースが削除された、あるいは削除中です。

サービスから返されます。詳細については、「Kinesis ビデオストリーム API リファレンス」を参照してください。

0x52000037 STATUS_SERVICE_CALL_TIMEOUT_ERRORサービス呼び出しがタイムアウトしました。

特定のサービス API の呼び出しがタイムアウトの結果となりました。ネットワーク接続が有効であることを確認します。PIC はオペレーションを自動的に再試行します。

0x52000038 STATUS_STREAM_READY_CALLBACK_FAILEDストリームの準備完了通知。

非同期ストリームが作成されたことを示す通知が PIC からクライアントに送信されます。

0x52000039 STATUS_DEVICE_TAGS_COUNT_NON_ZERO_TAGS_NULL無効なタグが指定されています。

タグ数がゼロではない、あるいはタグが空です。タグが指定されているか、あるいはタグ数がゼロであることを確認します。

0x5200003a STATUS_INVALID_STREAM_DESCRIPTION_VERSION無効なStreamDescription構造バージョン。

構造体の正しいバージョンを指定します。

89

Page 96: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドエラーコードのリファレンス

コード メッセージ 説明 推奨されるアクション

0x5200003b STATUS_INVALID_TAG_NAME_LEN無効なタグ名の長さ。 プロデューサー SDK の制限 (p. 82) で指定されるタグ名の制限を参照します。

0x5200003c STATUS_INVALID_TAG_VALUE_LEN無効なタグ値の長さ。 プロデューサー SDK の制限 (p. 82) で指定されるタグ値の制限を参照します。

0x5200003d STATUS_TAG_STREAM_CALL_FAILEDTagResourceAPI は失敗しました。

TagResource API 呼び出しに失敗しました。ネットワーク接続の有効性を確認します。この失敗の詳細については、ログを参照してください。

0x5200003e STATUS_INVALID_CUSTOM_DATA無効なカスタムデータによる PIC API 呼び出し。

無効なカスタムデータが PICAPI の呼び出しに指定されています。これは、PIC を直接使用するクライアントでのみ発生します。

0x5200003f STATUS_INVALID_CREATE_STREAM_RESPONSE無効なCreateStreamResponse構造体。

この構造体あるいはそのメンバーフィールドが無効です (ARN が Null あるいはプロデューサー SDK の制限 (p. 82) で指定される名前より長い場合)。

0x52000040 STATUS_CLIENT_AUTH_CALL_FAILEDクライアント認証の失敗。

複数回の再試行後、PICは適切な認証情報(AccessKeyId あるいはSecretAccessKey) の取得に失敗しました。認証の統合を確認します。サンプルアプリケーションは環境変数を使用して、認証情報を C++ プロデューサーライブラリに渡します。

0x52000041 STATUS_GET_CLIENT_TOKEN_CALL_FAILEDセキュリティトークンを取得する呼び出しに失敗しました。

この状態は、PIC を直接使用するクライアントでのみ発生します。複数回の試行後、呼び出しはこのエラーで失敗します。

0x52000042 STATUS_CLIENT_PROVISION_CALL_FAILEDプロビジョニングエラー。

プロビジョニングが実装されていません。

0x52000043 STATUS_CREATE_CLIENT_CALL_FAILEDプロデューサークライアントの作成に失敗しました。

複数回の再試行後クライアントの作成に失敗すると、PICは一般的なエラーを返します。

90

Page 97: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドエラーコードのリファレンス

コード メッセージ 説明 推奨されるアクション

0x52000044 STATUS_CLIENT_READY_CALLBACK_FAILEDREADY 状態のプロデューサークライアントの取得に失敗しました。

PIC が READY 状態に移行することに失敗すると、PIC ステートマシンによって返されます。このルート原因の詳細については、ログを参照してください。

0x52000045 STATUS_TAG_CLIENT_CALL_FAILEDプロデューサークライアントのTagResource に失敗しました。

プロデューサークライアントの TagResource API 呼び出しに失敗しました。このルート原因の詳細については、ログを参照してください。

0x52000046 STATUS_INVALID_CREATE_DEVICE_RESPONSEデバイスあるいはプロデューサーの作成に失敗しました。

より高レベルの SDK (C++または Java など) はまだ、デバイスあるいはプロデューサー作成 API を実装していません。PIC を直接使用するクライアントは、結果通知を使用して失敗を示すことができます。

0x52000047 STATUS_ACK_TIMESTAMP_NOT_IN_VIEW_WINDOW受信した ACK のタイムスタンプがビューに表示されません。

このエラーは、受信したACK に対応するフレームがコンテンツビューウィンドウから落ちる場合に発生します。一般的に、これは ACK配信が遅い場合に発生します。これは渓谷として解釈され、ダウンリンクが低速であることを示します。

0x52000048 STATUS_INVALID_FRAGMENT_ACK_VERSION無効な FragmentAck構造バージョン。

FragmentAck 構造の正しいバージョンを指定します。

0x52000049 STATUS_INVALID_TOKEN_EXPIRATION無効なセキュリティトークン期限。

セキュリティトークンの期限は、現在のタイムスタンプよりも大きく、猶予期間のある絶対的なこれから先のタイムスタンプである必要があります。猶予期間の制限については、「プロデューサー SDKの制限 (p. 82)」を参照してください。

0x5200004a STATUS_END_OF_STREAM ストリームの終了(EOS) インジケータです。

GetStreamDataAPI 呼び出しで、現在のアップロード処理セッションは終了したことを示します。これは、セッションが終了あるいはエラーが発生した、あるいはセッショントークンが期限切れとなり、セッションが更新されている場合に発生します。

91

Page 98: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドエラーコードのリファレンス

コード メッセージ 説明 推奨されるアクション

0x5200004b STATUS_DUPLICATE_STREAM_NAMEストリーム名が重複しています。

複数のストリームが同じストリーム名を持つことはできません。ストリームに一意の名前を選択します。

0x5200004c STATUS_INVALID_RETENTION_PERIOD無効な保持期間。 StreamInfo 構造に無効な保持期間が指定されています。保持期間の有効な値範囲についての詳細は、「プロデューサー SDK の制限 (p. 82)」を参照してください。

0x5200004d STATUS_INVALID_ACK_KEY_START無効 FragmentAck. フラグメント ACK 文字列を解析できませんでした。無効なキー開始インジケータです。フラグメント ACK 文字列が壊れている可能性があります。これは自己修正できるため、このエラーは警告として捉えることができます。

0x5200004e STATUS_INVALID_ACK_DUPLICATE_KEY_NAME無効 FragmentAck. フラグメント ACK 文字列を解析できませんでした。複数のキーが同じ名前を持っています。フラグメント ACK 文字列が壊れている可能性があります。これは自己修正できるため、このエラーは警告として捉えることができます。

0x5200004f STATUS_INVALID_ACK_INVALID_VALUE_START無効 FragmentAck. 無効なキー値の開始インジケータにより、フラグメントACK 文字列を解析できません。フラグメント ACK 文字列が壊れている可能性があります。これは自己修正できるため、このエラーは警告として捉えることができます。

0x52000050 STATUS_INVALID_ACK_INVALID_VALUE_END無効 FragmentAck. 無効なキー値の終了インジケータにより、フラグメントACK 文字列を解析できません。フラグメント ACK 文字列が壊れている可能性があります。これは自己修正できるため、このエラーは警告として捉えることができます。

0x52000051 STATUS_INVALID_PARSED_ACK_TYPE無効 FragmentAck. 無効な ACK 文字列が指定されたいるため、ACK フラグメントを解析できません。

0x52000052 STATUS_STREAM_HAS_BEEN_STOPPEDストリームが停止されました。

ストリームが停止されましたが、フレームは引き続きストリームに処理されています。

92

Page 99: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドエラーコードのリファレンス

コード メッセージ 説明 推奨されるアクション

0x52000053 STATUS_INVALID_STREAM_METRICS_VERSION無効なStreamMetrics 構造バージョン。

StreamMetrics 構造の正しいバージョンを指定します。

0x52000054 STATUS_INVALID_CLIENT_METRICS_VERSION無効なClientMetrics 構造バージョン。

ClientMetrics 構造の正しいバージョンを指定します。

0x52000055 STATUS_INVALID_CLIENT_READY_STATEプロデューサーの初期化が READY 状態に到達できませんでした。

プロデューサークライアントの初期化中に、READY 状態に到達できませんでした。詳細については、ログを参照してください。

0x52000056 STATUS_STATE_MACHINE_STATE_NOT_FOUND内部ステートマシンエラー。

公に表示されるエラーではありません。

0x52000057 STATUS_INVALID_FRAGMENT_ACK_TYPEFragmentAck 構造で無効な ACK タイプが指定されています。

FragmentAck 構造にはパブリックヘッダーで定義されるACK タイプが含まれていることが必要です。

0x52000058 STATUS_INVALID_STREAM_READY_STATE内部ステートマシントランジションエラー。

公に表示されるエラーではありません。

0x52000059 STATUS_CLIENT_FREED_BEFORE_STREAMプロデューサーの解放後、ストリームオブジェクトが解放されます。

プロデューサーオブジェクトが解放されると、ストリームの解放が試行されます。これは、PIC を直接使用するクライアントでのみ発生します。

0x5200005a STATUS_ALLOCATION_SIZE_SMALLER_THAN_REQUESTED内部ストレージエラー。

内部エラーとは、コンテンツストアの現在の割り当てサイズがフレームおよびフラグメントのパッケージのサイズよりも小さいことを示します。

0x5200005b STATUS_VIEW_ITEM_SIZE_GREATER_THAN_ALLOCATION内部ストレージエラー。

コンテンツビューの割り当てられる保存サイズがコンテンツストアの割り当てサイズより大きくなっています。

0x5200005c STATUS_ACK_ERR_STREAM_READ_ERRORストリーム読み込みエラー ACK。

ストリームの読み込みあるいは解析エラーを示すバックエンドから ACK が返すエラーです。これは一般的に、バックエンドがストリームの取得に失敗したときに発生します。通常の場合、自動再ストリーミングによってこのエラーを修正できます。

93

Page 100: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドエラーコードのリファレンス

コード メッセージ 説明 推奨されるアクション

0x5200005d STATUS_ACK_ERR_FRAGMENT_SIZE_REACHEDフラグメントの最大サイズに達しました。

フラグメントの最大サイズ (バイト単位) は、「プロデューサー SDK の制限 (p. 82)」で定義されています。このエラーは、非常に大きなフレームがあるか、または管理可能なサイズのフラグメントを作成するキーフレームが存在しないことを示します。エンコーダー設定を確認し、キーフレームが適切に生成されているように確保します。非常に密度の高いストリームには、最大限のサイズを管理するためにフラグメントを短い時間で生成するようにエンコーダーを設定します。

0x5200005e STATUS_ACK_ERR_FRAGMENT_DURATION_REACHEDフラグメントの最大時間に達しました。

フラグメントの最大時間は、「プロデューサー SDK の制限 (p. 82)」で定義されています。このエラーは、1 秒間のフレームが非常に低い場合、または管理可能な時間のフラグメントを作成するキーフレームが存在しないことを示します。エンコーダー設定を確認し、キーフレームが一定の間隔で適切に生成されていることを確保します。

0x5200005f STATUS_ACK_ERR_CONNECTION_DURATION_REACHED接続の最大時間に達しました。

Kinesis ビデオストリーム は「プロデューサー SDK の制限 (p. 82)」で指定されている最大の接続時間を適用します。プロデューサーSDK は最大時間に到達する前に自動的にストリームあるいはトークンを更新するため、SDK を使用するクライアントがこのエラーを受信する必要はありません。

0x52000060 STATUS_ACK_ERR_FRAGMENT_TIMECODE_NOT_MONOTONICタイムコードが一定間隔で増加しません。

プロデューサー SDK はタイムスタンプを適用するため、SDK を使用するクライアントがこのエラーを受信する必要はありません。

0x52000061 STATUS_ACK_ERR_MULTI_TRACK_MKVMKV に複数のトラックがあります。

プロデューサー SDK は単一のトラックストリームを適用するため、SDK を使用するクライアントがこのエラーを受信する必要はありません。

94

Page 101: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドエラーコードのリファレンス

コード メッセージ 説明 推奨されるアクション

0x52000062 STATUS_ACK_ERR_INVALID_MKV_DATA無効な MKV データ。 バックエンド MKV パーサーにストリームの解析エラーが発生しました。SDK を使用するクライアントでは、ストリームが移行中に破損した場合、あるいはバッファのプレッシャーによって SDK が部分的に送信されたフレームの末尾を強制的にドロップした場合などにこのエラーが発生することがあります。後者の場合、FPS または解像度を減らす、圧縮率を上げる、または (「バースト」性のネットワークの場合) 一時的なプレッシャーに対応できるようにより大きなコンテンツストアとバッファ時間を許可することが推奨されます。

0x52000063 STATUS_ACK_ERR_INVALID_PRODUCER_TIMESTAMP無効なプロデューサータイムスタンプ。

プロデューサークロックに今後大きなドリフトがある場合に、サービスは ACK にこのエラーを返します。より高レベルの SDK (Java や C++ など) は、システムクロックの一部のバージョンを使用してPIC の現在の時間コールバックに対応します。システムクロックが正しく設定されていることを確認します。PIC を直接使用するクライアントは、コールバック機能が正しいタイムスタンプを返すことを確認します。

0x52000064 STATUS_ACK_ERR_STREAM_NOT_ACTIVE非アクティブなストリーム。

ストリームが「アクティブ」状態にないときに、バックエンド API への呼び出しが実行されました。これは、クライアントがストリームを作成した直後にフレームを中にプッシュした場合に発生します。SDK はステートマシンおよびリカバリーメカニズムを通してこのシナリオを処理します。

0x52000065 STATUS_ACK_ERR_KMS_KEY_ACCESS_DENIEDAWS KMS アクセス拒否エラー。

アカウントに指定されたキーへのアクセスがない場合に返されるエラーです。

0x52000066 STATUS_ACK_ERR_KMS_KEY_DISABLEDAWS KMS キーが無効化されました。

指定されたキーが無効になりました。

95

Page 102: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドエラーコードのリファレンス

コード メッセージ 説明 推奨されるアクション

0x52000067 STATUS_ACK_ERR_KMS_KEY_VALIDATION_ERRORAWS KMS キー検証エラー。

一般的な検証エラー。詳細については、『AWS KeyManagement Service APIReference』を参照してください。

0x52000068 STATUS_ACK_ERR_KMS_KEY_UNAVAILABLEAWS KMS キー使用不可。

このキーは使用不可です。詳細については、『AWS KeyManagement Service APIReference』を参照してください。

0x52000069 STATUS_ACK_ERR_KMS_KEY_INVALID_USAGEAWS KMS キーの無効な使用。

AWS KMS キーはこのコンテキストで使用されるように設定されていません。詳細については、『AWS KeyManagement Service APIReference』を参照してください。

0x5200006a STATUS_ACK_ERR_KMS_KEY_INVALID_STATEAWS KMS の無効な状態。

詳細については、『AWSKey Management ServiceAPI Reference』を参照してください。

0x5200006b STATUS_ACK_ERR_KMS_KEY_NOT_FOUNDAWS KMS キーが見つかりませんでした。

このキーが見つかりません。詳細については、『AWSKey Management ServiceAPI Reference』を参照してください。

0x5200006c STATUS_ACK_ERR_STREAM_DELETEDストリームが削除された、または削除中です。

ストリームが別のアプリケーションまたは AWS マネジメントコンソール で削除されています。

0x5200006d STATUS_ACK_ERR_ACK_INTERNAL_ERROR内部エラー. 一般的サービス内部エラー。

0x5200006e STATUS_ACK_ERR_FRAGMENT_ARCHIVAL_ERRORフラグメントのアーカイブエラー。

サービスが永続的に存続し、フラグメントをインデックスできないときにこのエラーが返されます。稀に生じるエラーですが、これはさまざまな理由により発生します。デフォルトでは、SDK はフラグメントの送信を再試行します。

0x5200006f STATUS_ACK_ERR_UNKNOWN_ACK_ERROR未知のエラー。 サービスによって不明なエラーが返されました。

0x52000070 STATUS_MISSING_ERR_ACK_IDACK 情報の欠落。 ACK パーサーは解析を完了しましたが、FragmentAck情報が欠落しています。

96

Page 103: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドエラーコードのリファレンス

コード メッセージ 説明 推奨されるアクション

0x52000071 STATUS_INVALID_ACK_SEGMENT_LEN無効な ACK セグメントの長さ。

無効な長さの ACK セグメント文字列が ACK パーサーで指定されています。詳細については、「プロデューサーSDK の制限 (p. 82)」を参照してください。

0x52000074 STATUS_MAX_FRAGMENT_METADATA_COUNTフラグメントには最大数のメタデータ項目が追加されています。

Kinesis ビデオストリーム には、非永続的項目をフラグメントに追加、または永続的項目をメタデータキューに追加することにより、メタデータ項目を 10 個まで追加できます。詳細については、「Kinesis ビデオストリームを持つストリーミングメタデータの使用 (p. 15)」を参照してください。

0x52000075 STATUS_ACK_ERR_FRAGMENT_METADATA_LIMIT_REACHED制限 (メタデータの最大個数、メタデータの名前の長さ、またはメタデータの値の長さ)に達しました。

プロデューサー SDK では、メタデータ項目の個数とサイズが制限されます。プロデューサー SDK コード内の制限が変更されない限り、このエラーは発生しません。詳細については、「Kinesis ビデオストリーム を持つストリーミングメタデータの使用 (p. 15)」を参照してください。

0x52000076 STATUS_BLOCKING_PUT_INTERRUPTED_STREAM_TERMINATED実装されていません。  

0x52000077 STATUS_INVALID_METADATA_NAMEメタデータの名前が不正です。

メタデータの名前を「AWS」で始めることはできません。このエラーが発生した場合は、メタデータ項目はフラグメントまたはメタデータキューに追加されません。詳細については、「Kinesis ビデオストリームを持つストリーミングメタデータの使用 (p. 15)」を参照してください。

0x52000078 STATUS_END_OF_FRAGMENT_FRAME_INVALID_STATEフラグメントフレームの末尾が無効な状態です。

フラグメントの末尾は、キーフレーム以外のフラグメント化されたストリームで送信しないでください。

0x52000079 STATUS_TRACK_INFO_MISSINGトラック情報がありません。

トラック番号は 0 より大きく、トラック ID と一致している必要があります。

0x5200007a STATUS_MAX_TRACK_COUNT_EXCEEDED最大トラック数を超えています。

ストリームごとに最大 3 つのトラックを指定できます。

97

Page 104: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドエラーコードのリファレンス

コード メッセージ 説明 推奨されるアクション

0x5200007b STATUS_OFFLINE_MODE_WITH_ZERO_RETENTIONオフラインストリーミングモードの保持期間を 0 に設定します。

オフラインストリーミングモードの保持期間を 0 に設定しないでください。

0x5200007c STATUS_ACK_ERR_TRACK_NUMBER_MISMATCHエラー ACK のトラック番号が一致していません。

 

0x5200007d STATUS_ACK_ERR_FRAMES_MISSING_FOR_TRACKトラックのフレームがありません。

 

0x5200007e STATUS_ACK_ERR_MORE_THAN_ALLOWED_TRACKS_FOUND許可される最大のトラック数を超えました。

 

0x5200007f STATUS_UPLOAD_HANDLE_ABORTEDアップロード処理は中止されます。

 

0x52000080 STATUS_INVALID_CERT_PATH_LENGTH証明書のパスの長さが無効です。

 

0x52000081 STATUS_DUPLICATE_TRACK_ID_FOUND重複するトラック IDが見つかりました。

 

Duration ライブラリによって返されるエラーおよびステータスコード

次の表では、Duration ライブラリのメソッドによって返されるエラーと状態の情報を示しています。

コード メッセージ

0xFFFFFFFFFFFFFFFF INVALID_DURATION_VALUE

Common ライブラリによって返されるエラーおよびステータスコード

次の表では、Common ライブラリのメソッドによって返されるエラーと状態の情報を示しています。

Note

このエラーと状態の情報コードは多くの API で共通です。

コード メッセージ 説明

0x00000001 STATUS_NULL_ARG NULL が必須の引数として渡されました。

0x00000002 STATUS_INVALID_ARG 引数に無効な値が指定されています。

0x00000003 STATUS_INVALID_ARG_LEN 無効な長さの引数が指定されています。

0x00000004 STATUS_NOT_ENOUGH_MEMORY 十分なメモリを割り当てることができませんでした。

98

Page 105: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドエラーコードのリファレンス

コード メッセージ 説明

0x00000005 STATUS_BUFFER_TOO_SMALL 指定されたバッファサイズが小さすぎます。

0x00000006 STATUS_UNEXPECTED_EOF 予期しないエンドオブファイルに達しました。

0x00000007 STATUS_FORMAT_ERROR 無効なフォーマットが発生しました。

0x00000008 STATUS_INVALID_HANDLE_ERROR無効な処理値です。

0x00000009 STATUS_OPEN_FILE_FAILED ファイルを開くことができませんでした。

0x0000000a STATUS_READ_FILE_FAILED ファイルの読み込みに失敗しました。

0x0000000b STATUS_WRITE_TO_FILE_FAILEDファイルの書き込みに失敗しました。

0x0000000c STATUS_INTERNAL_ERROR 通常には発生しない内部エラーが生じ、SDK あるいはサービスAPI のバグである可能性があります。

0x0000000d STATUS_INVALID_OPERATION 無効なオペレーションが発生した、またはこのオペレーションは許可されていません。

0x0000000e STATUS_NOT_IMPLEMENTED この機能は実装されていません。

0x0000000f STATUS_OPERATION_TIMED_OUT オペレーションがタイムアウトしました。

0x00000010 STATUS_NOT_FOUND 必要なリソースが見つかりませんでした。

Heap ライブラリによって返されるエラーおよびステータスコード

次の表では、Heap ライブラリのメソッドによって返されるエラーと状態の情報を示しています。

コード メッセージ 説明

0x01000001 STATUS_HEAP_FLAGS_ERROR 無効なフラグの組み合わせが指定されています。

0x01000002 STATUS_HEAP_NOT_INITIALIZEDヒープが初期化される前にオペレーションが試行されました。

0x01000003 STATUS_HEAP_CORRUPTED ヒープが破損している、またはガードバンド (デバッグモード)が上書きされました。クライアントコードのバッファのオーバーフローはヒープの破損を引き起こす場合があります。

99

Page 106: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドエラーコードのリファレンス

コード メッセージ 説明

0x01000004 STATUS_HEAP_VRAM_LIB_MISSINGVRAM (ビデオ RAM) ユーザーあるいは Kernel モードライブラリがロードされない、または見つかりません。基盤のプラットフォームが VRAM の割り当てをサポートしていることを確認します。

0x01000005 STATUS_HEAP_VRAM_LIB_REOPENVRAM ライブラリを開くことができませんでした。

0x01000006 STATUS_HEAP_VRAM_INIT_FUNC_SYMBOLINIT 関数エクスポートのロードに失敗しました。

0x01000007 STATUS_HEAP_VRAM_ALLOC_FUNC_SYMBOLALLOC 関数エクスポートのロードに失敗しました。

0x01000008 STATUS_HEAP_VRAM_FREE_FUNC_SYMBOLFREE 関数エクスポートのロードに失敗しました。

0x01000009 STATUS_HEAP_VRAM_LOCK_FUNC_SYMBOLLOCK 関数エクスポートのロードに失敗しました。

0x0100000a STATUS_HEAP_VRAM_UNLOCK_FUNC_SYMBOLUNLOCK 関数エクスポートのロードに失敗しました。

0x0100000b STATUS_HEAP_VRAM_UNINIT_FUNC_SYMBOLUNINIT 関数エクスポートのロードに失敗しました。

0x0100000c STATUS_HEAP_VRAM_GETMAX_FUNC_SYMBOLGETMAX 関数エクスポートのロードに失敗しました。

0x0100000d STATUS_HEAP_DIRECT_MEM_INITハイブリッドヒープで主要なヒーププールの初期化に失敗しました。

0x0100000e STATUS_HEAP_VRAM_INIT_FAILEDVRAM の動的初期化に失敗しました。

0x0100000f STATUS_HEAP_LIBRARY_FREE_FAILEDVRAM ライブラリの割り当て解除と解放に失敗しました。

0x01000010 STATUS_HEAP_VRAM_ALLOC_FAILEDVRAM の割り当てに失敗しました。

0x01000011 STATUS_HEAP_VRAM_FREE_FAILEDVRAM の解放に失敗しました。

0x01000012 STATUS_HEAP_VRAM_MAP_FAILEDVRAM マッピングに失敗しました。

0x01000013 STATUS_HEAP_VRAM_UNMAP_FAILEDVRAM マッピング解除に失敗しました。

0x01000014 STATUS_HEAP_VRAM_UNINIT_FAILEDVRAM の初期化解除に失敗しました。

100

Page 107: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドエラーコードのリファレンス

MKVGen ライブラリによって返されるエラーおよびステータスコード次の表では、MKVGen ライブラリのメソッドによって返されるエラーと状態の情報を示しています。

コード メッセージ 説明と推奨されるアクション

0x32000001 STATUS_MKV_INVALID_FRAME_DATAFrame データ構造の無効なメンバー。時間、サイズ、フレームデータが有効であり、「プロデューサー SDK の制限 (p. 82)」で指定される制限内にあることを確認します。

0x32000002 STATUS_MKV_INVALID_FRAME_TIMESTAMP無効なフレームタイムスタンプ。計算された PTS (プレゼンテーションタイムスタンプ) および DTS (デコードタイムスタンプ) がフラグメントの開始フレームのタイムスタンプ以上です。これは、潜在的なメディアパイプラインあるいはエンコーダーの安定性の問題を指摘しています。トラブルシューティング情報については、「エラー:「Kinesis Video クライアントにフレームを送信できませんでした」 (p. 185)」を参照してください。

0x32000003 STATUS_MKV_INVALID_CLUSTER_DURATION無効なフラグメント時間が指定されています。詳細については、「プロデューサー SDK の制限 (p. 82)」を参照してください。

0x32000004 STATUS_MKV_INVALID_CONTENT_TYPE_LENGTH無効なコンテンツタイプ文字列の長さ。詳細については、「プロデューサー SDK の制限 (p. 82)」を参照してください。

0x32000005 STATUS_MKV_NUMBER_TOO_BIG EBML (拡張可能なバイナリメタ言語) 形式で表記するには大きすぎる数字をエンコードしようとしています。これは、SDK クライアントには公開されません。

0x32000006 STATUS_MKV_INVALID_CODEC_ID_LENGTH無効なコーデック ID 文字列の長さ。詳細については、「プロデューサー SDK の制限 (p. 82)」を参照してください。

0x32000007 STATUS_MKV_INVALID_TRACK_NAME_LENGTH無効なトラック名文字列の長さ。詳細については、「プロデューサー SDK の制限 (p. 82)」を参照してください。

101

Page 108: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドエラーコードのリファレンス

コード メッセージ 説明と推奨されるアクション

0x32000008 STATUS_MKV_INVALID_CODEC_PRIVATE_LENGTH無効なコーデックプライベートデータの長さ。詳細については、「プロデューサー SDK の制限 (p. 82)」を参照してください。

0x32000009 STATUS_MKV_CODEC_PRIVATE_NULLCPD サイズが 0 より大きいのに対して、コーデックプライベートデータ (CPD) が NULL です。

0x3200000a STATUS_MKV_INVALID_TIMECODE_SCALE無効なタイムコードスケール値です。詳細については、「プロデューサー SDK の制限 (p. 82)」を参照してください。

0x3200000b STATUS_MKV_MAX_FRAME_TIMECODEフレームタイムコードは最大値よりも大きい値である必要があります。詳細については、「プロデューサー SDK の制限 (p. 82)」を参照してください。

0x3200000c STATUS_MKV_LARGE_FRAME_TIMECODE最大フレームタイムコードに到達しています。MKV 形式は、フレームの相対的なタイムコードとしてクラスターの先頭に16 ビット符号を使用します。このエラーは、フレームのタイムコードが表示されない場合に生じます。このエラーは、不正なタイムコードスケールが選択されている、またはクラスター時間が長すぎるため、表現するフレームのタイムコードが 16ビット符号スペースをオーバーフローすることを示唆しています。

0x3200000d STATUS_MKV_INVALID_ANNEXB_NALU_IN_FRAME_DATA無効な Annex-B 開始コードが発生しました。たとえば、Annex-B 順応フラグが指定され、コードに 3 つ以上のゼロがある無効な開始シーケンスが発生した場合などです。有効な Annex-B 形式には、バイトストリームの 3 つ以上のゼロのシーケンスを回避するために、「エミュレーション防御」があります。詳細については、MPEGの仕様を参照してください。Android でのこのエラーの詳細については、「Android でのSTATUS_MKV_INVALID_ANNEXB_NALU_IN_FRAME_DATA(0x3200000d)エラー (p. 187)」を参照してください。

102

Page 109: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドエラーコードのリファレンス

コード メッセージ 説明と推奨されるアクション

0x3200000e STATUS_MKV_INVALID_AVCC_NALU_IN_FRAME_DATA順応 AVCC フラグが指定されている場合の無効な AVCC NALuパッケージ。バイトストリームが有効な AVCC 形式であることを確認します。詳細については、MPEG の仕様を参照してください。

0x3200000f STATUS_MKV_BOTH_ANNEXB_AND_AVCC_SPECIFIED順応 AVCC および Annex-B NALが両方とも指定されています。いずれか 1 つを指定、あるいは指定なしにします。

0x32000010 STATUS_MKV_INVALID_ANNEXB_NALU_IN_CPD順応 Annex-B フラグが指定されているときの CPD の無効なAnnex-B 形式。CPD が有効なAnnex-B 形式であることを確認します。そうでない場合、CPDAnnex-B 順応フラグを削除します。

0x32000011 STATUS_MKV_PTS_DTS_ARE_NOT_SAMEKinesis ビデオストリームは、PTS (タイムスタンプを表現)および DTS (デコードタイムスタンプ) に同じフラグメント開始フレームを適用します。これはフラグメントを開始するキーフレームです。

0x32000012 STATUS_MKV_INVALID_H264_H265_CPDH264/H265 コーデックプライベートデータの貼り付けに失敗しました。

0x32000013 STATUS_MKV_INVALID_H264_H265_SPS_WIDTHコーデックプライベートデータから幅を抽出できませんでした。

0x32000014 STATUS_MKV_INVALID_H264_H265_SPS_HEIGHTコーデックプライベートデータから高さを抽出できませんでした。

0x32000015 STATUS_MKV_INVALID_H264_H265_SPS_NALU無効な H264/H265 SPS NALu。

0x32000016 STATUS_MKV_INVALID_BIH_CPD コーデックプライベートデータの無効なビットマップ情報ヘッダー形式。

0x32000017 STATUS_MKV_INVALID_HEVC_NALU_COUNT高効率ビデオコーディング(HEVC) のネットワーク抽象化レイヤーユニット (NALU) 数が無効です。

0x32000018 STATUS_MKV_INVALID_HEVC_FORMATHEVC の形式が無効です。

0x32000019 STATUS_MKV_HEVC_SPS_NALU_MISSINGシーケンスパラメータセット(SPS) に HEVC NALU が見つかりません。

103

Page 110: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドエラーコードのリファレンス

コード メッセージ 説明と推奨されるアクション

0x3200001a STATUS_MKV_INVALID_HEVC_SPS_NALU_SIZEHEVC SPS NALU サイズが無効です。

0x3200001b STATUS_MKV_INVALID_HEVC_SPS_CHROMA_FORMAT_IDCクロマ形式 IDC が無効です。

0x3200001c STATUS_MKV_INVALID_HEVC_SPS_RESERVEDHEVC 予約 SPS が無効です。

0x3200001d STATUS_MKV_MIN_ANNEX_B_CPD_SIZEAnnex-b コーデックのプライベートベータの最小値。H264 の場合、この値は 11 以上である必要があります。H265 の場合、この値は 15 以上である必要があります。

0x3200001e STATUS_MKV_ANNEXB_CPD_MISSING_NALUSAnnex-B NALU のコーデックプライベートデータがありません。

0x3200001f STATUS_MKV_INVALID_ANNEXB_CPD_NALUSAnnex-B NALU のコーデックプライベートベータが無効です。

0x32000020 STATUS_MKV_INVALID_TAG_NAME_LENGTH無効なタグ名の長さ。有効な値はゼロより大きく、128 未満です。

0x32000021 STATUS_MKV_INVALID_TAG_VALUE_LENGTHタグ値の長さが無効です。有効な値はゼロより大きく 256 未満です。

0x32000022 STATUS_MKV_INVALID_GENERATOR_STATE_TAGSジェネレーター状態タグが無効です。

0x32000023 STATUS_MKV_INVALID_AAC_CPD_SAMPLING_FREQUENCY_INDEXAAC コーデックのプライベートデータサンプリング頻度インデックスが無効です。

0x32000024 STATUS_MKV_INVALID_AAC_CPD_CHANNEL_CONFIGAAC コーデックのプライベートデータチャネル設定が無効です。

0x32000025 STATUS_MKV_INVALID_AAC_CPD AAC コーデックのプライベートデータが無効です。

0x32000026 STATUS_MKV_TRACK_INFO_NOT_FOUNDトラック情報が見つかりませんでした。

0x32000027 STATUS_MKV_INVALID_SEGMENT_UUIDUUID セグメント UUID が無効です。

0x32000028 STATUS_MKV_INVALID_TRACK_UIDトラック UID が無効です。

Trace ライブラリによって返されるエラーおよびステータスコード

次の表では、Trace ライブラリのメソッドによって返されるエラーと状態の情報を示しています。

104

Page 111: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドエラーコードのリファレンス

コード メッセージ

0x10100001 STATUS_MIN_PROFILER_BUFFER

Utils ライブラリによって返されるエラーおよびステータスコード

次の表では、Utils ライブラリのメソッドによって返されるエラーと状態の情報を示しています。

コード メッセージ

0x40000001 STATUS_INVALID_BASE64_ENCODE

0x40000002 STATUS_INVALID_BASE

0x40000003 STATUS_INVALID_DIGIT

0x40000004 STATUS_INT_OVERFLOW

0x40000005 STATUS_EMPTY_STRING

0x40000006 STATUS_DIRECTORY_OPEN_FAILED

0x40000007 STATUS_PATH_TOO_LONG

0x40000008 STATUS_UNKNOWN_DIR_ENTRY_TYPE

0x40000009 STATUS_REMOVE_DIRECTORY_FAILED

0x4000000a STATUS_REMOVE_FILE_FAILED

0x4000000b STATUS_REMOVE_LINK_FAILED

0x4000000c STATUS_DIRECTORY_ACCESS_DENIED

0x4000000d STATUS_DIRECTORY_MISSING_PATH

0x4000000e STATUS_DIRECTORY_ENTRY_STAT_ERROR

View ライブラリによって返されるエラーおよびステータスコード

次の表では、View ライブラリのメソッドによって返されるエラーと状態の情報を示しています。

コード メッセージ 説明

0x30000001 STATUS_MIN_CONTENT_VIEW_ITEMS無効なコンテンツビュー項目数が指定されています。詳細については、「プロデューサー SDKの制限 (p. 82)」を参照してください。

0x30000002 STATUS_INVALID_CONTENT_VIEW_DURATION無効なコンテンツビュー時間が指定されています。詳細については、「プロデューサー SDK の制限 (p. 82)」を参照してください。

105

Page 112: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドエラーコードのリファレンス

コード メッセージ 説明

0x30000003 STATUS_CONTENT_VIEW_NO_MORE_ITEMSヘッド位置を超える試みが行われました。

0x30000004 STATUS_CONTENT_VIEW_INVALID_INDEX無効なインデックスが指定されました。

0x30000005 STATUS_CONTENT_VIEW_INVALID_TIMESTAMP無効なタイムスタンプがある、あるいはタイムスタンプが重複しています。フレームのデコードタイムスタンプは、前のフレームのタイムスタンプに前のフレームの時間を加えた値以上になる必要があります (`DTS(n) >= DTS(n-1) +Duration(n-1)`)。このエラーは、多くの場合「不安定な」エンコーダーを示しています。エンコーダーはエンコードされたフレームを大量に生成し、タイムスタンプが内部フレーム時間よりも小さい値です。あるいは、ストリームが SDK のタイムスタンプを使用するように設定され、このフレームがフレーム時間よりも高速で送信されています。エンコーダーの一部の「不安定」を解消するには、StreamInfo.StreamCaps構造でより短いフレーム時間を設定します。たとえば、ストリームが 25FPS の場合、各フレームの時間は 40 ミリ秒です。しかし、エンコーダーの不安定に対応するには、この時間の半分 (20 ミリ秒) を使用することが推奨されます。一部のストリームでは、エラーを検出するためにより正確な時間制御が必要となります。

0x30000006 STATUS_INVALID_CONTENT_VIEW_LENGTH無効なコンテンツビュー項目データの長さが指定されています。

PutFrame コールバックによって返されるエラーおよびステータスコード - C プロデューサーライブラリ以下のセクションには、C プロデューサーライブラリ内の PutFrame 操作のコールバックによって返されるエラーおよびステータス情報が含まれています。

106

Page 113: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドエラーコードのリファレンス

コード メッセージ 説明 推奨されるアクション

0x15000001 STATUS_STOP_CALLBACK_CHAINコールバックチェーンが停止しました。

 

0x15000002 STATUS_MAX_CALLBACK_CHAINコールバックチェーンの最大値に達しました。

 

0x15000003 STATUS_INVALID_PLATFORM_CALLBACKS_VERSION無効なPlatformCallbacks構造バージョン。

構造体の正しいバージョンを指定します。

0x15000004 STATUS_INVALID_PRODUCER_CALLBACKS_VERSION無効なProducerCallbacks構造バージョン。

構造体の正しいバージョンを指定します。

0x15000005 STATUS_INVALID_STREAM_CALLBACKS_VERSION無効なStreamCallbacks構造バージョン。

構造体の正しいバージョンを指定します。

0x15000006 STATUS_INVALID_AUTH_CALLBACKS_VERSION無効なAuthCallbacks 構造バージョン。

構造体の正しいバージョンを指定します。

0x15000007 STATUS_INVALID_API_CALLBACKS_VERSION無効なApiCallbacks 構造バージョン。

構造体の正しいバージョンを指定します。

0x15000008 STATUS_INVALID_AWS_CREDENTIALS_VERSION無効なAwsCredentials 構造バージョン。

構造体の正しいバージョンを指定します。

0x15000009 STATUS_MAX_REQUEST_HEADER_COUNTリクエストヘッダーカウントの最大値に達しました。

 

0x1500000a STATUS_MAX_REQUEST_HEADER_NAME_LENリクエストヘッダー名の最大長に達しています。

 

0x1500000b STATUS_MAX_REQUEST_HEADER_VALUE_LENリクエストヘッダー値の最大長に達しています。

 

0x1500000c STATUS_INVALID_API_CALL_RETURN_JSONAPI コールに無効な戻り値の JSON。

 

0x1500000d STATUS_CURL_INIT_FAILEDCurl の初期化に失敗しました。

 

0x1500000e STATUS_CURL_LIBRARY_INIT_FAILEDCurl lib 初期化に失敗しました。

 

0x1500000f STATUS_INVALID_DESCRIBE_STREAM_RETURN_JSONDescribeStream に無効な戻り値の JSON。

 

0x150000010 STATUS_HMAC_GENERATION_ERRORHMAC の生成エラー。

 

107

Page 114: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドNAL 適応フラグ

コード メッセージ 説明 推奨されるアクション

0x150000011 STATUS_IOT_FAILED IOT 認証に失敗しました。

 

0x150000012 STATUS_MAX_ROLE_ALIAS_LEN_EXCEEDEDロールエイリアスの最大長に達しました。

短いエイリアスの長さを指定してください。

0x150000013 STATUS_MAX_USER_AGENT_NAME_POSTFIX_LEN_EXCEEDEDエージェント名ポストフィックスの最大長に達しました。

 

0x150000014 STATUS_MAX_CUSTOM_USER_AGENT_LEN_EXCEEDED顧客のユーザーエージェントの最大長に達しました。

 

0x150000015 STATUS_INVALID_USER_AGENT_LENGTH無効なユーザーエージェントの長さ。

 

0x150000016 STATUS_INVALID_ENDPOINT_CACHING_PERIODエンドポイントの無効なキャッシュ期間。

24 時間未満のキャッシュ期間を指定してください。

0x150000017 STATUS_IOT_EXPIRATION_OCCURS_IN_PAST過去の IOT 有効期限切れタイムスタンプが発生します。

 

0x150000018 STATUS_IOT_EXPIRATION_PARSING_FAILEDIoT 有効期限切れの解析に失敗しました。

 

Network Abstraction Layer (NAL) 適応フラグを参照このセクションでは、StreamInfo.NalAdaptationFlags列挙に利用可能なフラグに関する情報が含まれています。

アプリケーションのエレメンタリーストリームは、Annex-B または AVCC 形式のいずれかにすることができます。

• Annex-B 形式は、2 バイトのゼロで NALU (Network Abstraction Layer Units) を区切り、その後に 1 バイトまたは 3 バイトのゼロと数値 1 が続きます (開始コードと呼ばれる、00000001 など)。

• AVCC 形式はまた、NALU をラップしますが、各 NALU の前に NALU のサイズを示す値 (通常は 4 バイト) があります。

多くのエンコーダーは Annex-B ビットストリーム形式を作成します。一部の上位ビットストリームプロセッサ (AWS マネジメントコンソール の再生エンジンや Media Source Extensions (MSE) プレーヤーなど) では、フレームに AVCC 形式が使用されます。

H.264 コーデックの SPS/PPS (シーケンスパラメータセット/ピクチャパラメータセット) であるコーデックプライベートデータ (CPD) は、Annex-B または AVCC 形式にすることもできます。ただし、CPD の場合、形式は前に説明したものとは異なります。

フラグは、次のように、SDK に指示し、フレームデータと CPD の NALU を AVCC または Annex-B に適応させるよう にします。

フラグ 適応

NAL_ADAPTATION_FLAG_NONE 適応なし

108

Page 115: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドプロデューサーの構造

フラグ 適応

NAL_ADAPTATION_ANNEXB_NALS Annex-B NALU を AVCC NALUに適応

NAL_ADAPTATION_AVCC_NALS AVCC NALU を Annex-B NALUに適応

NAL_ADAPTATION_ANNEXB_CPD_NALSコーデックのプライベートデータの Annex-B NALU を AVCC 形式 NALU に適応

NAL_ADAPTATION_ANNEXB_CPD_AND_FRAME_NALSコーデックおよびフレームプライベートデータの Annex-BNALU を AVCC 形式 NALU に適応

NALU タイプの詳細については、RFC 3984 の、セクション 1.3: ネットワーク抽象化レイヤーユニットタイプを参照してください。

プロデューサー SDK の構造このセクションでは、データを Kinesis ビデオストリーム プロデューサーオブジェクトに提供するために使用できる構造について説明します。

トピック• DeviceInfo/ DefaultDeviceInfoProvider (p. 109)• StorageInfo (p. 109)

DeviceInfo/ DefaultDeviceInfoProviderDeviceInfo オブジェクトおよび DefaultDeviceInfoProvider オブジェクトは、Kinesis ビデオストリームProducer オブジェクトの動作を制御します。

メンバーフィールド

• version: 現行バージョンのコードベースで正しいバージョンの構造が使用されていることを確認するための整数値。現行バージョンは、DEVICE_INFO_CURRENT_VERSION マクロを使用して指定します。

• name: 人間が判読できるデバイス名。• tagCount/tags: 現在使用されていません。• streamCount: デバイスで処理できる最大ストリーム数。これにより、最初にストリームを指すポイン

ターのストレージが事前に割り当てられますが、実際のストリームオブジェクトは後で作成されます。デフォルトは 16 ストリームですが、この数は DefaultDeviceInfoProvider.cpp ファイルで変更できます。

• storageInfo: メインのストレージ設定を説明するオブジェクト。詳細については、「StorageInfo (p. 109)」を参照してください。

StorageInfoKinesis ビデオストリーム のメインストレージの設定を指定します。

デフォルトの実装は、ストリーミング向けに最適化された、断片化の少ない高速なヒープ実装に基づきます。使用する MEMALLOC アロケータは、特定のプラットフォームで上書きできます。一部のプラット

109

Page 116: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドストリーム構造

フォームにおける仮想メモリの割り当ては、物理ページでバッキングされません。メモリが使用されると、仮想ページは物理ページでバッキングされます。これにより、ストレージの使用率が低いときは、システム全体のメモリ負荷が低くなります。

デフォルトのストレージサイズを次の式に基づいて計算します。DefragmentationFactor は 1.2 (20パーセント) に設定する必要があります。

Size = NumberOfStreams * AverageFrameSize * FramesPerSecond * BufferDurationInSeconds * DefragmentationFactor

次の例では、デバイスに音声ストリームとビデオストリームがあります。音声ストリームには 1 秒あたり512 サンプルがあり、各サンプルは平均 100 バイトです。ビデオストリームには 1 秒あたり 25 サンプルがあり、各サンプルは平均 10,000 バイトです。各ストリームのバッファ期間は 3 分です。

Size = (512 * 100 * (3 * 60) + 25 * 10000 * (3 * 60)) * 1.2 = (9216000 + 45000000) * 1.2 = 65059200 = ~ 66MB.

デバイスで使用できるメモリが多い場合は、重大な断片化を避けるためにストレージにメモリを追加することをお勧めします。

エンコードの複雑さが高い (高モーションのためにフレームサイズがより大きい) ときや帯域幅が低いときでも、すべてのストリームに十分なバッファを提供できるストレージサイズであることを確認します。ロデューサーでメモリ負荷が発生すると、ストレージのオーバーフロープレッシャーコールバック (StorageOverflowPressureFunc) が発行されます。ただし、コンテンツストアに使用可能なメモリがない場合は、Kinesis ビデオストリーム 内に挿入されるフレームが破棄され、エラー(STATUS_STORE_OUT_OF_MEMORY = 0x5200002e) になります。詳細については、「クライアントライブラリによって返されるエラーおよびステータスコード (p. 85)」を参照してください。アプリケーションの確認 (ACK) が利用できない場合、または保持された ACK が遅延した場合にも発生する可能性があります。この場合、より古いフレームがドロップアウトを開始する前に、バッファは「バッファ期間」の容量まで埋まります。

メンバーフィールド

• version: 現行バージョンのコードベースで正しいバージョンの構造が使用されていることを確認するための整数値。

• storageType: 基盤となるストレージのバッキング/実装を指定する DEVICE_STORAGE_TYPE 列挙。現在、サポートされている値は DEVICE_STORAGE_TYPE_IN_MEM のみです。将来の実装ではDEVICE_STORAGE_TYPE_HYBRID_FILE がサポートされます。これは、ファイルに格納されたコンテンツストアにストレージがフォールバックすることを示します。

• storageSize: 事前に割り当てるストレージサイズ (バイト単位)。最小の割り当ては 10 MB です。最大の割り当ては 10 GB です。(今後ファイルに格納されるコンテンツストアの実装に伴って変更される予定です。)

• spillRatio: セカンダリオーバーフローストレージ (ファイルストレージ) ではなく、直接メモリストレージタイプ (RAM) から割り当てるストレージの割合 (%) を示す整数値。現在使用されていません。

• rootDirectory: ファイルに格納されるコンテンツストアがあるディレクトリへのパス。現在使用されていません。

Kinesis ビデオストリームの構造次の構造を使用して Kinesis ビデオストリーム のインスタンスにデータを提供できます。

トピック• StreamDefinition/ StreamInfo (p. 111)• ClientMetrics (p. 120)

110

Page 117: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドストリーム構造

• StreamMetrics (p. 121)

StreamDefinition/ StreamInfoC++ レイヤーの StreamDefinition オブジェクトは、プラットフォームに依存しないコードのStreamInfo オブジェクトをラップし、コンストラクタの一部のデフォルト値を提供します。

メンバーフィールド

フィールド データタイプ 説明 デフォルト値

stream_name string オプションのストリーム名。ストリーム名の長さの詳細については、「プロデューサーSDK の制限 (p. 82)」を参照してください。ストリームごとに一意の名前が必要です。

名前を指定しないと、名前がランダムに生成されます。

retention_period duration<uint64_t,ratio<3600>>

ストリームの保持期間(秒単位)。0 の指定は、保持なしを示します。

3600 (1 時間)

タグ const map<string,string>*

ユーザー情報を含むキー/値ペアのマップ。ストリームに既存のタグセットがある場合、新しいタグは既存のタグセットに追加されます。

タグがありません

kms_key_id string ストリームの暗号化に使用される AWS KMSキー ID。詳細については、「Kinesis ビデオストリーム でのデータ保護 (p. 30)」を参照してください。

デフォルト KMS キー(aws/kinesis-video)。

streaming_type STREAMING_TYPE 列挙 STREAMING_TYPE_REALTIMEはサポートされる唯一の値です。

 

content_type string ストリームのコンテンツ形式。Kinesis ビデオストリーム コンソールは、video/h264 形式でコンテンツを再生できます。

video/h264

max_latency duration<uint64_t,milli>

ストリームの最大レイテンシー (ミリ秒)。この時間をバッファ期間が超えると、ストリームのレイテンシープレッシャーコールバック (指

milliseconds::zero()

111

Page 118: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドストリーム構造

フィールド データタイプ 説明 デフォルト値定されている場合) が呼び出されます。0 を指定すると、ストリームのレイテンシープレッシャーコールバックは呼び出されません。

fragment_duration duration<uint64_t> フラグメントの有効期間 (秒単位)。この値は、key_frame_fragmentation値と組み合わせて使用します。この値がfalse の場合、この継続期間が経過すると、Kinesis ビデオストリーム はキーフレームでフラグメントを生成します。たとえば、Advanced AudioCoding (AAC) オーディオストリームは各フレームをキーフレームとして使用します。key_frame_fragmentation= false を指定すると、この継続期間の経過後に、2 秒のフラグメントが生じます。

2

112

Page 119: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドストリーム構造

フィールド データタイプ 説明 デフォルト値

timecode_scale duration<uint64_t,milli>

MKV タイムコードスケール (ミリ秒単位)。MKV クラスター内でフレームのタイムコードの詳細度を指定します。MKV フレームのタイムコードは、常にクラスターの開始を基準にします。MKVでは、符号付きの 16ビット値 (0 〜 32767)を使用してクラスター内のタイムコード (フラグメント) を示します。したがって、指定されたタイムコードスケールでフレームのタイムコードを表現できることを確認する必要があります。タイムコードスケール値のデフォルトである 1 ミリ秒の場合、表現できるフレームの最大値は32,767 ミリ秒 ~= 32 秒です。これは、Kinesisビデオストリーム の制限 (p. 174) で指定されたフラグメント継続時間の最大値 (10 秒) を超えます。

1

key_frame_fragmentation bool キーフレームでフラグメントを生成するかどうかを指定します。true の場合、SDKはキーフレームがあるたびにフラグメントの開始を生成します。false の場合、Kinesis ビデオストリーム は少なくともfragment_durationの期間待機してから、その後のキーフレームで新しいフラグメントを生成します。

true

113

Page 120: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドストリーム構造

フィールド データタイプ 説明 デフォルト値

frame_timecodes bool フレームのタイムコードを使用するか、現在時刻のコールバックを使用してタイムスタンプを生成するかどうかを指定します。多くのエンコーダーでは、フレームでタイムスタンプを生成しません。したがって、このパラメータに false を指定すると、確実にフレームがタイムスタンプ付きで Kinesis ビデオストリーム に配置されます。

true

absolute_fragment_times bool Kinesis ビデオストリーム では、基盤となるパッケージング機構として MKV を使用します。MKV の仕様では、クラスターの開始地点(フラグメント) に相対するフレームのタイムコードは厳格です。ただし、クラスターのタイムコードはストリームの開始時刻に対して相対値の場合と絶対値の場合があります。タイムスタンプが相対値である場合、PutMediaサービスの API コールでは、オプションであるストリームの開始タイムスタンプを使用して、クラスターのタイムスタンプを調整します。このサービスで保存されるフラグメントには常に絶対値のタイムスタンプが使用されます。

true

fragment_acks bool アプリケーションレベルのフラグメント ACK(確認) を受け取るかどうかを指定します。

true の場合、SDK はACK を受け取り、相応に対応します。

restart_on_error bool 特定のエラー発生時に再開するかどうかを指定します。

true の場合、SDK はエラー発生時にストリーミングの再開を試行します。

114

Page 121: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドストリーム構造

フィールド データタイプ 説明 デフォルト値

recalculate_metrics bool メトリクスを再計算するかどうかを指定します。メトリクスを取得するための呼び出しごとに、再計算によって最新の「実行中」の値が取得されます。これに伴って CPU に小さな影響が生じます。電力やフットプリントが極端に低いデバイスでは、これを false に設定して、CPU サイクルの消費を抑える必要があります。それ以外の場合、この値に falseを使用することはお勧めしません。

true

115

Page 122: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドストリーム構造

フィールド データタイプ 説明 デフォルト値

nal_adaptation_flags uint32_t Network AbstractionLayer unit (NALU) 適応フラグを指定します。ビットストリームがH.264 でエンコードされている場合、NALUで未加工またはパッケージとして処理できます。これは Annex-B 形式または AVCC 形式のいずれかになります。大半の基本ストリームプロデューサー/コンシューマー (読み取りのエンコーダー/デコーダー) では Annex-B 形式を使用します。この形式には、エラー回復などの利点があるためです。高レベルのシステムでは AVCC 形式を使用します。これは、MPEG、HLS、DASHなどのデフォルト形式です。コンソールの再生では、ブラウザの MSE (Media SourceExtensions) を使用して、AVCC 形式を使用するストリームをデコードして再生します。H.264 (および M-JPEG と H.265) の場合、SDK には適応機能が用意されています。

多くの基本ストリームは次の形式になります。この例では、Abは Annex-B 開始コード(001 または 0001) です。

Ab(Sps)Ab(Pps)Ab(I-frame)Ab(P/B-frame) Ab(P/B-frame)…. Ab(Sps)Ab(Pps)Ab(I-frame)Ab(P/B-frame) Ab(P/B-frame)

H.264 の場合、コーデックプライベートデータ(CPD) は SPS (シーケンスパラメータセット) とPPS (ピクチャパラメー

デフォルトでは、フレームデータとコーデックプライベートデータの両方で Annex-B 形式を AVCC 形式に適応させます。

116

Page 123: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドストリーム構造

フィールド データタイプ 説明 デフォルト値タセット) パラメータ内にあり、AVCC 形式に適合させることができます。メディアパイプラインで個別に CPD を指定しない限り、アプリケーションはフレームから CPD を抽出します。これが可能なのは、最初の IDR フレーム (SPS/PPS を含む) を検索し、2 つの NALU(Ab(Sps)Ab(Pps))を抽出して、StreamDefinitionの CPD に設定するためです。

詳細については、「NAL適応フラグ (p. 108)」を参照してください。

frame_rate uint32_t 予想されるフレームレート。この値を使用してバッファリングニーズの計算を効率化できます。

25

avg_bandwidth_bps uint32_t ストリームの予想される平均帯域幅。この値を使用してバッファリングニーズの計算を効率化できます。

4 * 1024 * 1024

117

Page 124: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドストリーム構造

フィールド データタイプ 説明 デフォルト値

buffer_duration duration<uint64_t> ストリームのバッファ期間 (秒単位)。SDKは、buffer_durationの上限までフレームをコンテンツストアに保持します。その後、ウィンドウが進むと、古いフレームは破棄されます。破棄されるフレームがバックエンドに送信されていない場合、破棄フレームコールバックが呼び出されます。現在のバッファ期間が max_latencyより大きい場合、ストリームのレイテンシープレッシャーコールバックが呼び出されます。フラグメントの永続化 ACK が受信されると、バッファはトリミングされて次のフラグメント開始地点に送られます。これは、コンテンツがクラウド内で永続的に保持されるため、コンテンツをローカルデバイスに保存する必要がなくなるためです。

120

118

Page 125: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドストリーム構造

フィールド データタイプ 説明 デフォルト値

replay_duration duration<uint64_t> 再開が有効になっている場合、エラー発生時の再生まで現在のリーダーをロールバックする期間 (秒単位)。ロールバックはバッファの開始位置で停止します (ストリーミングを開始したばかりであるか、永続化 ACK が受信された場合)。ロールバックは、フラグメントの開始を示すキーフレームを確定しようとします。再開の原因となったエラーが、デッドホスト (ホストがまだアライブでフレームデータを内部バッファに保持している状態) を示さない場合、ロールバックは最後に受信した ACK フレームで停止します。その後、次のキーフレームまでロールフォワードします (フラグメント全体がすでにホストメモリに保存されているため)。

40

connection_staleness duration<uint64_t> SDK でバッファリング ACK を受信しない場合、ストリームの古さのコールバックが呼び出されるまでの時間 (秒単位)。これは、デバイスからフレームが送信されていても、バックエンドで受信されていないことを示します。この状況は、中間ホップまたはロードバランサーで接続が切断されていることを示します。

30

codec_id string MKV トラックのコーデック ID。

V_MPEG4/ISO/AVC

track_name string MKV トラック名。 kinesis_video

119

Page 126: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドストリーム構造

フィールド データタイプ 説明 デフォルト値

codecPrivateData unsigned char* コーデックプライベートデータ (CPD) のバッファ。ストリームの開始前に CPD に関する情報がメディアパイプラインにある場合は、StreamDefinition.codecPrivateDataで設定できます。ビットがコピーされ、バッファを再利用できます。または、ストリームを作成するための呼び出し後にバッファが解放されます。ただし、ストリームの作成時にデータが利用できない場合は、KinesisVideoStream.start(cpd)関数のオーバーロードのいずれかに設定できます。

null

codecPrivateDataSize uint32_t コーデックプライベートデータのバッファサイズ。

0

ClientMetricsClientMetrics オブジェクトを満たすには getKinesisVideoMetrics を呼び出します。

メンバーフィールド

フィールド データタイプ 説明

バージョン UINT32 構造のバージョン。CLIENT_METRICS_CURRENT_VERSIONマクロで定義します。

contentStoreSize UINT64 コンテンツストア全体のサイズ (バイト単位)。これは、DeviceInfo.StorageInfo.storageSizeでの指定値です。

contentStoreAvailableSize UINT64 現在使用可能なストレージサイズ (バイト単位)。

contentStoreAllocatedSize UINT64 現在割り当てられているサイズ。割り当て済みのサイズ + 使用可能なサイズは、内部のブックキーピングとコンテンツストアの実装のため、ストレージ全体のサイズよりわずかに小さくなります。

120

Page 127: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドストリーム構造

フィールド データタイプ 説明

totalContentViewsSize UINT64 すべてのストリームですべてのコンテンツビューに割り当てられているメモリのサイズ。これは、ストレージサイズとは無関係です。このメモリはMEMALLOC マクロを使用して割り当てられます。これを上書きしてカスタムアロケータを指定できます。

totalFrameRate UINT64 すべてのストリームで確認された合計フレームレート。

totalTransferRate UINT64 すべてのストリームで確認された合計ストリームレート (バイト/秒)。

StreamMetricsStreamMetrics オブジェクトを満たすには getKinesisVideoMetrics を呼び出します。

メンバーフィールド

フィールド データタイプ 説明

バージョン UINT32 構造のバージョン。STREAM_METRICS_CURRENT_VERSIONマクロで定義します。

currentViewDuration UINT64 蓄積されたフレームの時間。高速ネットワーキングの場合、この時間は 0 またはフレーム時間 (フレーム転送時) のいずれかになります。時間がStreamDefinition に指定された max_latency よりも長くなる場合は、ストリームレイテンシーコールバック (指定されている場合) が呼び出されます。時間は 100ns 単位で指定します。これは PIC レイヤーのデフォルトの時間単位です。

overallViewDuration UINT64 全体の表示時間。ストリームにACK や永続化が設定されていない場合、この値は Kinesis ビデオストリーム に挿入されるフレームが増えるに従って増加し、StreamDefinition に指定された buffer_duration と等しくなります。ACK が有効になっていて永続化 ACK が受信される場合は、ACK タイムスタンプがフラグメント全体の先頭を

121

Page 128: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドコールバック

フィールド データタイプ 説明示すため、バッファは次のキーフレーム位置でトリミングされます。時間は 100 ns 単位で指定します。これは PIC レイヤーのデフォルトの時間単位です。

currentViewSize UINT64 現在のバッファのサイズ (バイト単位)。

overallViewSize UINT64 全体の表示サイズ (バイト単位)。

currentFrameRate UINT64 現在のストリームで確認されたフレームレート。

currentTransferRate UINT64 すべてのストリームで確認された転送レート (バイト/秒)。

プロデューサー SDK コールバックAmazon Kinesis ビデオストリーム プロデューサー SDK のクラスとメソッドは独自のプロセスを維持しません。その代わり、受信した関数呼び出しとイベントを使用してコールバックをスケジュールし、アプリケーションと通信します。

アプリケーションが SDK とやり取りするために使用できるコールバックパターンは 2 つあります。

• CallbackProvider: このオブジェクトは、プラットフォームに依存しないコード (PIC) コンポーネントからアプリケーションへのすべてのコールバックを公開します。このパターンではすべての機能を使用できますが、実装では C++ レイヤーにあるすべてのパブリック API メソッドと署名を処理する必要があります。

• StreamCallbackProvider (p. 123) および ClientCallbackProvider (p. 123): これらのオブジェクトはストリーム固有およびクライアント固有のコールバックを公開します。SDK の C++ レイヤーはその他のコールバックを公開します。これは、プロデューサー SDK とやり取りするために推奨されるコールバックパターンです。

次の図は、コールバックオブジェクトのオブジェクトモデルです。

前の図の DefaultCallbackProvider は CallbackProvider (PIC のすべてのコールバックを公開します) から派生し、StreamCallbackProvider および ClientCallbackProvider が含まれます。

このトピックは、以下のセクションで構成されます。• ClientCallbackProvider (p. 123)• StreamCallbackProvider (p. 123)

122

Page 129: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドコールバック

• ClientCallbacks 構造 (p. 123)• ストリーミング再試行へのコールバックの実装 (p. 126)

ClientCallbackProviderClientCallbackProvider オブジェクトはクライアントレベルのコールバック関数を公開します。関数の詳細は「ClientCallbacks (p. 123)」に記載されています。

コールバックメソッド:

• getClientReadyCallback: クライアントの準備完了状態を報告します。• getStorageOverflowPressureCallback: ストレージオーバーフローまたは

プレッシャーを報告します。このコールバックは、ストレージの使用率が以下のSTORAGE_PRESSURE_NOTIFICATION_THRESHOLD 値 (ストレージ全体のサイズの 5 パーセント) に下がると呼び出されます。詳細については、「StorageInfo (p. 109)」を参照してください。

StreamCallbackProviderStreamCallbackProvider オブジェクトはストリームレベルのコールバック関数を公開します。

コールバックメソッド:

• getDroppedFragmentReportCallback: 削除されたフラグメントを報告します。• getDroppedFrameReportCallback: 削除されたフレームを報告します。• getFragmentAckReceivedCallback: ストリームでフラグメント ACK が受信されたことを報告しま

す。• getStreamClosedCallback: ストリームのクローズ状態を報告します。• getStreamConnectionStaleCallback: 古い接続状況を報告します。この状況では、プロデュー

サーはサービスにデータを送信していますが、送達確認を受信していません。• getStreamDataAvailableCallback: ストリームにデータが利用可能であることを報告します。• getStreamErrorReportCallback: ストリームのエラー状態を報告します。• getStreamLatencyPressureCallback: ストリームのレイテンシー状態を報告します。蓄

積されたバッファのサイズが max_latency 値より大きくなった場合です。詳細については、「StreamDefinition/ StreamInfo (p. 111)」を参照してください。

• getStreamReadyCallback: ストリームの準備完了状態を報告します。• getStreamUnderflowReportCallback: ストリームのアンダーフロー状態を報告します。この関数

は現在使用されておらず、将来使用するために予約されています。

StreamCallbackProvider のソースコードについては、StreamCallbackProvider.h を参照してください。

ClientCallbacks 構造ClientCallbacks 構造には、特定のイベントが発生したときに PIC によって呼び出されるコールバック関数のエントリポイントが含まれています。またこの構造には、CALLBACKS_CURRENT_VERSION フィールドにバージョン情報が含まれるほか、個別のコールバック関数で返されるユーザー定義データが含まれる customData フィールドが含まれています。

クライアントアプリケーションは this ポインターを custom_data フィールドで使用できます。これは次のコード例のようにメンバー関数を実行時に静的 ClientCallback 関数にマッピングします。

STATUS TestStreamCallbackProvider::streamClosedHandler(UINT64 custom_data, STREAM_HANDLE stream_handle, UINT64 stream_upload_handle) {

123

Page 130: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドコールバック

LOG_INFO("Reporting stream stopped.");

TestStreamCallbackProvider* streamCallbackProvider = reinterpret_cast<TestStreamCallbackProvider*> (custom_data);streamCallbackProvider->streamClosedHandler(...);

イベント

関数 説明 タイプ

CreateDeviceFunc 現在はバックエンドに実装されていません。この呼び出しはJava または C++ から呼び出されると失敗します。その他のクライアントはプラットフォーム固有の初期化を実行します。

バックエンド API

CreateStreamFunc ストリームを作成したときに呼び出されます。

バックエンド API

DescribeStreamFunc DescribeStream が呼び出されたときに呼び出されます。

バックエンド API

GetStreamingEndpointFunc GetStreamingEndpoint が呼び出されたときに呼び出されます。

バックエンド API

GetStreamingTokenFunc GetStreamingToken が呼び出されたときに呼び出されます。

バックエンド API

PutStreamFunc PutStream が呼び出されたときに呼び出されます。

バックエンド API

TagResourceFunc TagResource が呼び出されたときに呼び出されます。

バックエンド API

     

CreateMutexFunc 同期ミューテックスを作成します。

同期

FreeMutexFunc ミューテックスを解放します。 同期

LockMutexFunc 同期ミューテックスをロックします。

同期

TryLockMutexFunc ミューテックスをロックするように試みます。現在実装されていません。

同期

UnlockMutexFunc ミューテックスのロックを解除します。

同期

     

ClientReadyFunc クライアントが準備完了状態になると呼び出されます。

通知

DroppedFrameReportFunc フレームが削除されたときに報告されます。

通知

124

Page 131: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドコールバック

関数 説明 タイプ

DroppedFragmentReportFunc フラグメントが削除されたときに報告されます。この関数は現在使用されておらず、将来使用するために予約されています。

通知

FragmentAckReceivedFunc フラグメント ACK (バッファリング、受信、保持、エラー) が受信されたときに呼び出されます。

通知

StorageOverflowPressureFuncストレージの使用率がSTORAGE_PRESSURE_NOTIFICATION_THRESHOLD値 (ストレージ全体のサイズの 5パーセントとして定義) に下がると呼び出されます。

通知

StreamClosedFunc 残りのフレームの最後のビットがストリーミングされたときに呼び出されます。

通知

StreamConnectionStaleFunc ストリームが古い接続状態になると呼び出されます。この状況では、プロデューサーはサービスにデータを送信していますが、送達確認を受信していません。

通知

StreamDataAvailableFunc ストリームデータが使用可能になったときに呼び出されます。

通知

StreamErrorReportFunc ストリームエラーが発生したときに呼び出されます。この状況になると、PIC はストリームを自動的に閉じます。

通知

StreamLatencyPressureFunc ストリームがレイテンシー状態になったときに呼び出されます。蓄積されたバッファのサイズが max_latency 値より大きくなった場合です。詳細については、「StreamDefinition/StreamInfo (p. 111)」を参照してください。

通知

StreamReadyFunc ストリームが準備完了状態になると呼び出されます。

通知

StreamUnderflowReportFunc この関数は現在使用されておらず、将来使用するために予約されています。

通知

     

DeviceCertToTokenFunc 接続証明書をトークンとして返します。

プラットフォーム統合

GetCurrentTimeFunc 現在時刻を返します。 プラットフォーム統合

125

Page 132: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドコールバック

関数 説明 タイプ

GetDeviceCertificateFunc デバイス証明書を返します。この関数は現在使用されておらず、将来使用するために予約されています。

プラットフォーム統合

GetDeviceFingerprintFunc デバイスフィンガープリントを返します。この関数は現在使用されておらず、将来使用するために予約されています。

プラットフォーム統合

GetRandomNumberFunc 0 から RAND_MAX までの乱数を返します。

プラットフォーム統合

GetSecurityTokenFunc バックエンド API と通信する関数に渡されるセキュリティトークンを返します。シリアル化されたAccessKeyId、SecretKeyId、およびセッショントークンを指定して実装できます。

プラットフォーム統合

LogPrintFunc タグとログレベルを伴うテキスト行をログ記録します。詳細については、「PlatformUtils.h」を参照してください。

プラットフォーム統合

前の表のプラットフォーム統合関数の最後のパラメータは ServiceCallContext 構造であり、以下のフィールドがあります。

• version: 構造のバージョン。• callAfter: 関数を呼び出すまでの絶対時間。• timeout: オペレーションのタイムアウト (100 ナノ秒単位)。• customData: クライアントに返されるユーザー定義の値。• pAuthInfo: 呼び出しの認証情報。詳細については、次の (__AuthInfo) 構造を参照してください。

認証情報は、__AuthInfo 構造を使用して提供されます。シリアル化された認証情報またはプロバイダー固有の認証トークンのいずれかを使用できます。この構造には次のフィールドがあります。

• version: __AuthInfo 構造のバージョン。• type: 認証情報のタイプを定義する AUTH_INFO_TYPE 値 (証明書またはセキュリティトークン)。• data: 認証情報を含むバイト配列。• size: dataパラメータのサイズ。• expiration: 認証情報の有効期限 (100 ナノ秒単位)。

ストリーミング再試行へのコールバックの実装Kinesis Video Producer SDK は、コールバック関数を使用して、ストリーミングのステータスを提供します。ストリーミング中に発生する一時的なネットワークの問題を解消するには、次のコールバックメカニズムを実装することをお勧めします。

126

Page 133: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドコールバック

• ストリームのレイテンシープレッシャーコールバック - このコールバックメカニズムは、ストリームのレイテンシーの条件が SDK で発生するとトリガーされます。このトリガーは、累積バッファサイズが MAX_LATENCY 値より大きい場合に発生します。ストリームが作成されると、ストリーミングアプリケーションによって MAX_LATENCY がデフォルト値の 60 秒に設定されます。このコールバックの一般的な実装として、接続をリセットします。必要に応じて、https://github.com/awslabs/amazon-kinesis-video-streams-producer-sdk-cpp/blob/master/kinesis-video-c-producer/src/source/StreamLatencyStateMachine.c のサンプル実装を使用することができます。ネットワーク障害が原因で未配信のフレームをセカンダリストレージに保存してバックフィルを設定することはできません。

• ストリームの古さのコールバック - このコールバックは、プロデューサーより AWS KVS サービスにデータを送信できる場合 (アップリンク) にトリガーされますが、送達確認 (バッファされた ACK) を時間内 (デフォルトは 60 秒) に戻すことはできません。ネットワーク設定に応じて、ストリームのレイテンシープレッシャーコールバックかストリームの古さのコールバック、またはその両方がトリガーされる場合があります。ストリームのレイテンシープレッシャーコールバックの再試行の実装と同様に、一般的な実装として、接続をリセットし、ストリーミング用に新しい接続を開始します。必要に応じて、https://github.com/awslabs/amazon-kinesis-video-streams-producer-c/blob/master/src/source/ConnectionStaleStateMachine.c のサンプル実装を使用することができます。

• ストリームのエラーコールバック - このコールバックは、KVS API サービスコールの呼び出し中にネットワーク接続のタイムアウトまたはその他のエラーが SDK によって検出された場合にトリガーされます。ネットワークタイムアウトエラーから復旧するには、https://github.com/awslabs/amazon-kinesis-video-streams-producer-sdk-cpp/blob/master/kinesis-video-gst-demo/kinesis_video_gstreamer_sample_app.cpp#L1023 で、ストリームを再作成するためのサンプル実装を参照して使用できます。

• ドロップされたフレームのコールバック - このコールバックは、ネットワーク速度が低い、またはストリームエラーが原因でストレージサイズがいっぱいになるとトリガーされます。ネットワーク速度が原因でフレームがドロップアウトする場合は、ネットワークの速度に合わせて、ストレージサイズを増やすか、ビデオフレームサイズまたはフレームレートを減らします。

127

Page 134: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイド手順: Kinesis ビデオストリームパーサーライブラリの使用

Kinesis ビデオストリームパーサーライブラリ

Kinesis ビデオストリームパーサーライブラリは Java アプリケーション内で使用できる使いやすいツールセットで、これを用いることで Kinesis ビデオストリーム 内の MKV データを使用できます。

このライブラリには次のツールが含まれます。

• StreamingMkvReader (p. 129): このクラスは指定された MKV 要素をビデオストリームから読み取ります。

• FragmentMetadataVisitor (p. 130): このクラスはフラグメント (メディア要素) およびトラック (音声や字幕といったメディア情報を含む個々のデータストリーム) からメタデータを取得します。

• OutputSegmentMerger (p. 131): このクラスは、ビデオストリームの連続したフラグメントまたはチャンクを結合します。

• KinesisVideoExample (p. 132): これは、Kinesis ビデオストリームパーサーライブラリの使用方法を示すサンプルアプリケーションです。

ライブラリには、ツールの使用方法を示すテストも含まれています。

手順: Kinesis ビデオストリームパーサーライブラリの使用

この手順には、以下のステップが含まれます。

• the section called “ステップ 1: コードをダウンロードして設定する” (p. 129)• the section called “ステップ 2: コードを作成してテストする” (p. 129)• the section called “ステップ 3: コードを実行して検証する” (p. 134)

前提条件Kinesis ビデオストリームパーサーライブラリを検証および使用するには以下が必要です。

• Amazon Web Services (AWS) アカウントAWS アカウントをお持ちでない場合は、次の手順を実行してください。• https://aws.amazon.com/ を開いて、[AWS アカウントの作成] を選択します。

Note

過去に AWS マネジメントコンソール にサインインした場合は、お使いのブラウザで使用できないことがあります。その場合は、[Sign In to the Console] を選択し、次に [Create a newAWS account] を選択します。

• オンラインの手順に従います。

サインアップ手順の一環として、通話呼び出しを受け取り、電話のキーパッドを用いて PIN を入力することが求められます。

128

Page 135: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドステップ 1: コードをダウンロードして設定する

Kinesis ビデオストリーム へのプログラムからのアクセス設定時に必要となるため、AWS アカウント IDを書き留めておいてください。

• Eclipse Java Neon や JetBrains IntelliJ Idea などの Java 統合開発環境 (IDE)。

ステップ 1: コードをダウンロードして設定するこのセクションでは、Java ライブラリおよびテストコードをダウンロードし、プロジェクトを Java IDEにインポートします。

この手順の前提条件その他の詳細については、「ストリームパーサーライブラリ (p. 128)」を参照してください。

1. ディレクトリを作成し、GitHub リポジトリ (https://github.com/aws/amazon-kinesis-video-streams-parser-library) からライブラリソースコードのクローンを作成します。

$ git clone https://github.com/aws/amazon-kinesis-video-streams-parser-library

2. 使用する Java IDE (Eclipse や IntelliJ IDEA など) を開き、ダウンロードした Apache Maven プロジェクトをインポートします。

• Eclipse: [File]、[Import]、[Maven]、[Existing Maven Projects] を選択して kinesis-video-streams-parser-lib フォルダに移動します。

• IntelliJ Idea では: [インポート] を選択します。ダウンロードしたパッケージのルートに含まれるpom.xml ファイルに移動します。

詳細については、関連する IDE ドキュメントを参照してください。

次のステップthe section called “ステップ 2: コードを作成してテストする” (p. 129)

ステップ 2: コードを作成してテストするこのセクションでは、Java ライブラリとテストコードを検証し、ライブラリに含まれるツールを独自のコードで使用する方法について学習します。

Kinesis ビデオストリームパーサーライブラリには以下のツールがあります。

• StreamingMkvReader (p. 129)• FragmentMetadataVisitor (p. 130)• OutputSegmentMerger (p. 131)• KinesisVideoExample (p. 132)

StreamingMkvReaderこのクラスは指定された MKV 要素をストリームからブロックしない方法で読み取ります。

次のコード例 (FragmentMetadataVisitorTest から) は、Streaming MkvReader を作成、使用してinputStream と呼ばれる入力ストリームから MkvElement オブジェクトを取得する方法を示しています。

129

Page 136: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドFragmentMetadataVisitor

StreamingMkvReader mkvStreamReader = StreamingMkvReader.createDefault(new InputStreamParserByteSource(inputStream)); while (mkvStreamReader.mightHaveNext()) { Optional<MkvElement> mkvElement = mkvStreamReader.nextIfAvailable(); if (mkvElement.isPresent()) { mkvElement.get().accept(fragmentVisitor); ... } } }

FragmentMetadataVisitorこのクラスはフラグメント (メディア要素) およびトラック (コーデックのプライベートデータ、ピクセルの幅、ピクセルの高さといったメディア情報を含む個々のデータストリーム) のメタデータを取得します。

次のコード例 (FragmentMetadataVisitorTest ファイルから) は FragmentMetadataVisitor を使って MkvElement オブジェクトからデータを取得する方法を示しています。

FragmentMetadataVisitor fragmentVisitor = FragmentMetadataVisitor.create(); StreamingMkvReader mkvStreamReader = StreamingMkvReader.createDefault(new InputStreamParserByteSource(in)); int segmentCount = 0; while(mkvStreamReader.mightHaveNext()) { Optional<MkvElement> mkvElement = mkvStreamReader.nextIfAvailable(); if (mkvElement.isPresent()) { mkvElement.get().accept(fragmentVisitor); if (MkvTypeInfos.SIMPLEBLOCK.equals(mkvElement.get().getElementMetaData().getTypeInfo())) { MkvDataElement dataElement = (MkvDataElement) mkvElement.get(); Frame frame = ((MkvValue<Frame>)dataElement.getValueCopy()).getVal(); MkvTrackMetadata trackMetadata = fragmentVisitor.getMkvTrackMetadata(frame.getTrackNumber()); assertTrackAndFragmentInfo(fragmentVisitor, frame, trackMetadata); } if (MkvTypeInfos.SEGMENT.equals(mkvElement.get().getElementMetaData().getTypeInfo())) { if (mkvElement.get() instanceof MkvEndMasterElement) { if (segmentCount < continuationTokens.size()) { Optional<String> continuationToken = fragmentVisitor.getContinuationToken(); Assert.assertTrue(continuationToken.isPresent()); Assert.assertEquals(continuationTokens.get(segmentCount), continuationToken.get()); } segmentCount++; } } }

}

前述の例は、次のコーディングパターンを示しています。

• データ解析のための FragmentMetadataVisitor およびデータ提供のためのStreamingMkvReader (p. 129) を作成します。

• ストリーム内の各 MkvElement について、そのメタデータが SIMPLEBLOCK タイプかどうかを検証します。

130

Page 137: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドOutputSegmentMerger

• 該当する場合は MkvElement から MkvDataElement を取得します。• MkvDataElement から Frame (メディアデータ) を取得します。• FragmentMetadataVisitor から Frame 用の MkvTrackMetadata を取得します。• Frame および MkvTrackMetadata オブジェクトから次のデータを取得して検証します。

• 追跡番号。• フレームのピクセルの高さ。• フレームのピクセルの幅。• フレームのエンコードに使用するコーデックのコーデック ID。• このフレームが順番に到着したこと。つまり、前のフレームのトラック番号 (存在する場合) が、現在

のフレームのトラック番号よりも小さいことを検証します。

プロジェクトで FragmentMetadataVisitor を使用するには、ビジターの accept 方法を使ってMkvElement オブジェクトをビジターにパスします。

mkvElement.get().accept(fragmentVisitor);

OutputSegmentMergerこのクラスは、ストリーム内の異なるトラックのメタデータを単一のセグメントを持つストリームにマージします。

次のコード例 (FragmentMetadataVisitorTest ファイルから) は、OutputSegmentMerger を使ってinputBytes と呼ばれるバイト配列の追跡メタデータをマージする方法を示しています。

FragmentMetadataVisitor fragmentVisitor = FragmentMetadataVisitor.create();

ByteArrayOutputStream outputStream = new ByteArrayOutputStream();

OutputSegmentMerger outputSegmentMerger = OutputSegmentMerger.createDefault(outputStream);

CompositeMkvElementVisitor compositeVisitor = new TestCompositeVisitor(fragmentVisitor, outputSegmentMerger);

final InputStream in = TestResourceUtil.getTestInputStream("output_get_media.mkv");

StreamingMkvReader mkvStreamReader = StreamingMkvReader.createDefault(new InputStreamParserByteSource(in)); while (mkvStreamReader.mightHaveNext()) { Optional<MkvElement> mkvElement = mkvStreamReader.nextIfAvailable(); if (mkvElement.isPresent()) { mkvElement.get().accept(compositeVisitor); if (MkvTypeInfos.SIMPLEBLOCK.equals(mkvElement.get().getElementMetaData().getTypeInfo())) { MkvDataElement dataElement = (MkvDataElement) mkvElement.get(); Frame frame = ((MkvValue<Frame>) dataElement.getValueCopy()).getVal(); Assert.assertTrue(frame.getFrameData().limit() > 0); MkvTrackMetadata trackMetadata = fragmentVisitor.getMkvTrackMetadata(frame.getTrackNumber()); assertTrackAndFragmentInfo(fragmentVisitor, frame, trackMetadata); }}

前述の例は、次のコーディングパターンを示しています。

• FragmentMetadataVisitor (p. 130) を作成してストリームからメタデータを取得する。

131

Page 138: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドKinesisVideoExample

• 出力ストリームを作成してマージされたメタデータを取得する.• OutputSegmentMerger を作成し、ByteArrayOutputStream に渡す。• 2 つのビジターを含む CompositeMkvElementVisitor を作成する。• 指定されたファイルを指す InputStream を作成する。• 入力データ内の各要素を出力ストリームにマージします。

KinesisVideoExampleこれは、Kinesis ビデオストリームパーサーライブラリの使用方法を示すサンプルアプリケーションです。

このクラスは次の操作を実行します。

• Kinesis ビデオストリーム を作成します。指定した名前がすでに存在する場合は、ストリームが削除され、再作成されます。

• ビデオフラグメントを Kinesis ビデオストリーム にストリームするために、PutMedia を呼び出します。• Kinesis ビデオストリーム からビデオフラグメントをストリームするために、GetMedia を呼び出しま

す。• StreamingMkvReader (p. 129) を使用してストリームで返されたフラグメントを解析

し、FragmentMetadataVisitor (p. 130) を使用してフラグメントを記録します。

ストリームを削除して再作成次のコード例 (StreamOps.javaファイルから) は、Kinesis ビデオストリーム を削除します。

//Delete the streamamazonKinesisVideo.deleteStream(new DeleteStreamRequest().withStreamARN(streamInfo.get().getStreamARN()));

次のコード例 (StreamOps.javaファイルから) は、指定された名前の Kinesis ビデオストリーム を作成します。

amazonKinesisVideo.createStream(new CreateStreamRequest().withStreamName(streamName).withDataRetentionInHours(DATA_RETENTION_IN_HOURS).withMediaType("video/h264"));

PutMedia 呼び出し次のコード例 (PutMediaWorker.java ファイルから) は、ストリームの PutMedia を呼び出します。

putMedia.putMedia(new PutMediaRequest().withStreamName(streamName).withFragmentTimecodeType(FragmentTimecodeType.RELATIVE).withProducerStartTimestamp(new Date()).withPayload(inputStream), new PutMediaAckResponseHandler() {...});

GetMedia 呼び出し次のコード例 (GetMediaWorker.java ファイルから) は、ストリームの GetMedia を呼び出します。

132

Page 139: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドKinesisVideoExample

GetMediaResult result = videoMedia.getMedia(new GetMediaRequest().withStreamName(streamName).withStartSelector(startSelector));

GetMedia の結果を解析このセクションでは、StreamingMkvReader (p. 129)、FragmentMetadataVisitor (p. 130)、CompositeMkvElementVisitorを使用して、GetMedia から返されたデータを解析し、ファイルに保存して、ログに記録する方法について説明します。

StreamingMkvReader で GetMedia の出力を読み込む次のコード例 (GetMediaWorker.java ファイルから) は、StreamingMkvReader (p. 129) を作成し、それを使用して GetMedia オペレーションの結果を解析します。

StreamingMkvReader mkvStreamReader = StreamingMkvReader.createDefault(new InputStreamParserByteSource(result.getPayload()));log.info("StreamingMkvReader created for stream {} ", streamName);try { mkvStreamReader.apply(this.elementVisitor);} catch (MkvElementVisitException e) { log.error("Exception while accepting visitor {}", e);}

上記のコード例では、StreamingMkvReader (p. 129) は GetMedia 結果のペイロードから MKVElementオブジェクトを取得します。次のセクションでは、要素は FragmentMetadataVisitor (p. 130) に渡されます。

FragmentMetadataVisitor フラグメントを取得次のコード例 (KinesisVideoExample.java および StreamingMkvReader.java ファイルから)は、FragmentMetadataVisitor (p. 130) を作成します。StreamingMkvReader (p. 129) で反復されたMkvElement オブジェクトは、accept メソッドを使用して訪問者に渡されます。

KinesisVideoExample.java: から

FragmentMetadataVisitor fragmentMetadataVisitor = FragmentMetadataVisitor.create();

StreamingMkvReader.java: から

if (mkvElementOptional.isPresent()) { //Apply the MkvElement to the visitor mkvElementOptional.get().accept(elementVisitor); }

要素を記録し、ファイルに書き込む次のコード例 (KinesisVideoExample.javaファイルから) は、以下のオブジェクトを作成し、それらをGetMediaProcessingArguments 関数の戻り値の一部として返します。

• システムログに書き込む LogVisitor (MkvElementVisitor の拡張)。• 受信データを MKV ファイルに書き込む OutputStream。• OutputStream にバインドされたデータをバッファする BufferedOutputStream。

133

Page 140: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイド次のステップ

• 同じトラックと EBML データで GetMedia 結果の連続した要素をマージする the section called“OutputSegmentMerger” (p. 131)

• FragmentMetadataVisitor (p. 130)、the section called“OutputSegmentMerger” (p. 131)、LogVisitor を 1 人の要素訪問者に構成するCompositeMkvElementVisitor

//A visitor used to log as the GetMedia stream is processed. LogVisitor logVisitor = new LogVisitor(fragmentMetadataVisitor);

//An OutputSegmentMerger to combine multiple segments that share track and ebml metadata into one //mkv segment. OutputStream fileOutputStream = Files.newOutputStream(Paths.get("kinesis_video_example_merged_output2.mkv"), StandardOpenOption.WRITE, StandardOpenOption.CREATE); BufferedOutputStream outputStream = new BufferedOutputStream(fileOutputStream); OutputSegmentMerger outputSegmentMerger = OutputSegmentMerger.createDefault(outputStream);

//A composite visitor to encapsulate the three visitors. CompositeMkvElementVisitor mkvElementVisitor = new CompositeMkvElementVisitor(fragmentMetadataVisitor, outputSegmentMerger, logVisitor);

return new GetMediaProcessingArguments(outputStream, logVisitor, mkvElementVisitor);

メディア処理の引数は GetMediaWorker に渡され、次に ExecutorService に渡され、ワーカーは別のスレッドで実行されます。

GetMediaWorker getMediaWorker = GetMediaWorker.create(getRegion(), getCredentialsProvider(), getStreamName(), new StartSelector().withStartSelectorType(StartSelectorType.EARLIEST), amazonKinesisVideo, getMediaProcessingArgumentsLocal.getMkvElementVisitor());executorService.submit(getMediaWorker);

次のステップthe section called “ステップ 3: コードを実行して検証する” (p. 134)

ステップ 3: コードを実行して検証するKinesis ビデオストリームパーサーライブラリには、ユーザー独自のプロジェクトでの使用を想定したツールが含まれます。プロジェクトにはこれらのツールに対するユニットテストが含まれており、これを実行することでインストールを検証できます。

ライブラリには次のユニットテストが含まれます。

• mkv• ElementSizeAndOffsetVisitorTest

• MkvValueTest

• StreamingMkvReaderTest

• ユーティリティ

134

Page 141: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドステップ 3: コードを実行して検証する

• FragmentMetadataVisitorTest

• OutputSegmentMergerTest

135

Page 142: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイド例: Kinesis ビデオストリーム へのデータの送信

Amazon Kinesis ビデオストリーム 例次のコード例では、Kinesis ビデオストリーム API を使用する方法を示しています。

例: Kinesis ビデオストリーム へのデータの送信• 例: Kinesis ビデオストリーム プロデューサー SDK GStreamer プラグイン (p. 137): Kinesis ビデオス

トリーム プロデューサー SDK を GStreamer 送信先として使用する構築方法を示します。• Docker コンテナで GStreamer エレメントを実行します。 (p. 141): RTSP ビデオを IP カメラから

Kinesis ビデオストリーム へ送信するための、構築済みの Docker イメージの使用方法を示します。• 例: RTSP ソースからのストリーミング (p. 149): 独自の Docker イメージの構築方法および IP カメラ

から Kinesis ビデオストリーム への RTSP ビデオの送信方法を示します。• 例: PutMedia API を使用した Kinesis ビデオストリーム へのデータの送信 (p. 146): Java プロデュー

サーライブラリを使用する (p. 48) を使用して、すでに PutMedia API を使用するコンテナ形式 (MKV) のKinesis ビデオストリーム にデータを送信する方法を示します。

例: Kinesis ビデオストリーム からのデータの取得• KinesisVideoExample (p. 132): Kinesis ビデオストリーム パーサーライブラリを使用したビデオフラグ

メントの解析方法およびログの記録方法を示します。• 例: Kinesis ビデオストリーム フラグメントの解析およびレンダリング (p. 151): JCodec および

JFrame を使用した Kinesis ビデオストリーム フラグメントの解析方法およびレンダリング方法を示します。

• the section called “Amazon SageMaker” (p. 153): Amazon SageMaker を使用して、特定のオブジェクトがビデオストリームに表示されるタイミングを決定するソリューションを示します。

例: ビデオデータの再生• 例: HTML および JavaScript での HLS の使用 (p. 10): Kinesis ビデオストリーム の HLS ストリーミング

セッションを取得して、ウェブページで再生する方法を示します。

前提条件• サンプルコードでは、AWS 認証情報プロファイルファイルで設定したプロファイルを指定するか、統合

開発環境 (IDE) の Java システムプロパティの認証情報を提供することで、認証情報を提供します。そのため、認証情報を設定します (まだ設定していない場合)。詳細については、「開発用の AWS 認証情報とリージョンのセットアップ」を参照してください。

• コードの表示および実行には次のいずれかの Java IDE の使用をお勧めします。• Eclipse Java Neon

136

Page 143: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドGStreamer

• JetBrains IntelliJ IDEA

例: Kinesis ビデオストリーム プロデューサー SDKGStreamer プラグイン

このトピックでは、Amazon Kinesis ビデオストリーム プロデューサー SDK を GStreamer プラグインとして使用するために構築する方法を示します。

トピック• GStreamer エレメントのダウンロード、構築、設定 (p. 138)• GStreamer エレメントを実行します。 (p. 138)• GStreamer 起動コマンドの例 (p. 139)• Docker コンテナで GStreamer エレメントを実行します。 (p. 141)• GStreamer エレメントパラメータのリファレンス (p. 143)

GStreamer は、多数のカメラやビデオソースで使用される一般的なメディアフレームワークです。モジュラープラグインを組み合わせてカスタムのメディアパイプラインを作成できます。Kinesis ビデオストリーム GStreamer プラグインは、既存の GStreamer メディアパイプラインの Kinesis ビデオストリーム への統合を大幅に簡易化します。GStreamer を統合した後は、ウェブカメラや RTSP (Real Time StreamingProtocol) カメラから Kinesis ビデオストリーム にビデオをストリーミングすることができます。リアルタイムや後の再生、保存、詳細な分析に使用できます。

GStreamer プラグインは、Kinesis ビデオストリーム プロデューサー SDK によって提供される機能をGStreamer のシンクエレメント (kvssink) にカプセル化することで、Kinesis ビデオストリーム へのビデオストリームの転送を自動的に管理します。GStreamer フレームワークは、カメラや他のビデオソースのようなデバイスからのメディアフローを構築して処理、レンダリング、保存を行うための標準的なマネージド環境を提供します。

GStreamer パイプラインは通常、ソース (ビデオカメラ) とシンクエレメント (ビデオをレンダリングするプレーヤーやオフラインで取得するためのストレージ) 間のリンクで構成されます。この例では、プロデューサー SDK エレメントをビデオソース (ウェブカメラまたは IP カメラ) のシンク、つまりメディア送信先として使用します。SDK をカプセル化したプラグインエレメントは、その後ビデオストリームのKinesis ビデオストリーム への送信を管理します。

このトピックでは、ウェブカメラや RTSP ストリームなどのビデオソースからビデオをストリーミングできる GStreamer メディアパイプラインの構築方法を説明します。これは通常、中間エンコードステージ(H.264 エンコーディングを使用) を経由して Kinesis ビデオストリーム に接続されます。ビデオストリームが Kinesis ビデオストリーム として使用できる場合、Kinesis ビデオストリームパーサーライブラリを使用してビデオストリームをさらに処理、再生、保存、分析できます。

137

Page 144: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドGStreamer エレメントのダウンロード、構築、設定

GStreamer エレメントのダウンロード、構築、設定GStreamer プラグインの例は Kinesis ビデオストリーム C++ プロデューサー SDK に含まれています。SDK の前提条件およびダウンロードの詳細については、「ステップ 1: C++ プロデューサーライブラリコードをダウンロードして設定する (p. 60)」を参照してください。

プロデューサー SDK GStreamer シンクは、macOS、Ubuntu、Raspberry Pi、または Windows で動的ライブラリとして構築できます。GStreamer プラグインは build ディレクトリにあります。このプラグインをロードするには、プラグインが GST_PLUGIN_PATH にある必要があります。次のコマンドを実行します。

export GST_PLUGIN_PATH=`pwd`/build

GStreamer エレメントを実行します。Kinesis ビデオストリーム プロデューサー SDK エレメントをシンクとして GStreamer を実行するには、gst-launch-1.0 コマンドを実行します。GStreamer プラグインで使用する適切な設定を使用します。たとえば、Linux システム上の v4l2 デバイスには v4l2src を、RTSP デバイスには rtspsrc を使用します。kvssink をシンク (パイプラインの最終的な送信先) としてを指定し、ビデオをプロデューサー SDKに送信します。

kvssink エレメントには以下の必須パラメータがあります。

• stream-name: 送信先 Kinesis ビデオストリーム の名前。• storage-size: デバイスのストレージサイズ (キロバイト)。デバイスストレージの構成の詳細につい

ては、「StorageInfo (p. 109)」を参照してください。• access-key: Kinesis ビデオストリーム にアクセスするために使用する AWS アクセスキー。このパラ

メータか credential-path のどちらかを指定する必要があります。• secret-key: Kinesis ビデオストリーム にアクセスするために使用する AWS シークレットキー。この

パラメータか credential-path のどちらかを指定する必要があります。• credential-path: Kinesis ビデオストリーム にアクセスするための認証情報を含むファイルのパス。

認証情報ファイルの例については、Sample Static Credential および Sample Rotating Credential を参照してください。認証情報の変更の詳細については、「IAM ユーザーのアクセスキーの管理」を参照してください。このパラメータか、access-key および secret-key かの、どちらかを指定する必要があります。

kvssink のオプションのパラメータの詳細については、「GStreamer エレメントパラメータのリファレンス (p. 143)」を参照してください。

GStreamer プラグインとパラメータの最新情報については、GStreamer Plugins を参照するか、次のコマンドを実行してオプションのリストを表示します。

gst-inspect-1.0 kvssink

構築が失敗した場合、またはGST_PLUGIN_PATH が設定されていない場合、出力は次のようになります。

No such element or plugin 'kvssink'

138

Page 145: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイド起動コマンド

GStreamer 起動コマンドの例以下の例で、GStreamer プラグインを使用して異なるタイプのデバイスからビデオをストリーミングする方法を示します。

例 1: Ubuntu の RTSP カメラからビデオをストリーミングする次のコマンドを実行すると、ネットワーク RTSP カメラからストリーミングする GStreamer パイプラインが Ubuntu に作成されます。これは rtspsrc GStreamer プラグインを使用します。

$ gst-launch-1.0 rtspsrc location="rtsp://YourCameraRtspUrl" short-header=TRUE ! rtph264depay ! video/x-h264, format=avc,alignment=au ! kvssink stream-name="YourStreamName" storage-size=512 access-key="YourAccessKey" secret-key="YourSecretKey" aws-region="YourAWSRegion"

例 2: Ubuntu の USB カメラからビデオをエンコードしてストリーミングする次のコマンドを実行すると、USB カメラからのストリームを H.264 フォーマットでエンコードし、Kinesis ビデオストリーム にストリーミングする GStreamer パイプラインが Ubuntu に作成されます。この例では v412src GStreamer プラグインを使用します。

$ 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=500 ! video/x-h264,stream-format=avc,alignment=au,profile=baseline ! kvssink stream-name="YourStreamName" storage-size=512 access-key="YourAccessKey" secret-key="YourSecretKey" aws-region="YourAWSRegion"

例 3: Ubuntu の USB カメラからエンコード済みビデオをストリーミングする次のコマンドを実行すると、カメラが H.264 フォーマットでエンコード済みのビデオを Kinesis ビデオストリーム にストリーミングする GStreamer パイプラインが Ubuntu に作成されます。この例では v412srcGStreamer プラグインを使用します。

$ gst-launch-1.0 v4l2src do-timestamp=TRUE device=/dev/video0 ! h264parse ! video/x-h264,stream-format=avc,alignment=au ! kvssink stream-name="plugin" storage-size=512 access-key="YourAccessKey" secret-key="YourSecretKey" aws-region="YourAWSRegion"

例 4: macOS のネットワークカメラからビデオをストリーミングする次のコマンドを実行すると、ビデオをネットワークカメラから Kinesis ビデオストリーム にストリーミングする GStreamer パイプラインが macOS に作成されます。この例では rtspsrc GStreamer プラグインを使用します。

$ gst-launch-1.0 rtspsrc location="rtsp://YourCameraRtspUrl" short-header=TRUE ! rtph264depay ! video/x-h264, format=avc,alignment=au ! kvssink stream-name="YourStreamName" storage-size=512 access-key="YourAccessKey" secret-key="YourSecretKey" aws-region="YourAWSRegion"

139

Page 146: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイド起動コマンド

例 5: Windows のネットワークカメラからビデオをストリーミングする次のコマンドを実行すると、ビデオをネットワークカメラから Kinesis ビデオストリーム にストリーミングする GStreamer パイプラインが Windows に作成されます。この例では rtspsrc GStreamer プラグインを使用します。

$ gst-launch-1.0 rtspsrc location="rtsp://YourCameraRtspUrl" short-header=TRUE ! rtph264depay ! video/x-h264, format=avc,alignment=au ! kvssink stream-name="YourStreamName" storage-size=512 access-key="YourAccessKey" secret-key="YourSecretKey" aws-region="YourAWSRegion"

例 6: Raspberry Pi のカメラからビデオをストリーミングする次のコマンドを実行すると、ビデオを Kinesis ビデオストリーム にストリーミングする GStreamer パイプラインが Raspberry Pi に作成されます。この例では v412src GStreamer プラグインを使用します。

$ gst-launch-1.0 v4l2src do-timestamp=TRUE device=/dev/video0 ! videoconvert ! video/x-raw,format=I420,width=640,height=480,framerate=30/1 ! omxh264enc control-rate=1 target-bitrate=5120000 periodicity-idr=45 inline-header=FALSE ! h264parse ! video/x-h264,stream-format=avc,alignment=au,width=640,height=480,framerate=30/1,profile=baseline ! kvssink stream-name="YourStreamName" frame-timestamp=dts-only access-key="YourAccessKey" secret-key="YourSecretKey" aws-region="YourAWSRegion"

例 7: Raspberry Pi のカメラからビデオをストリーミングしてリージョンを指定する次のコマンドを実行すると、ビデオを 米国東部(バージニア北部) リージョンの Kinesis ビデオストリーム にストリーミングする GStreamer パイプラインが Raspberry Pi に作成されます。この例では v412srcGStreamer プラグインを使用します。

$ gst-launch-1.0 v4l2src do-timestamp=TRUE device=/dev/video0 ! videoconvert ! video/x-raw,format=I420,width=640,height=480,framerate=30/1 ! omxh264enc control-rate=1 target-bitrate=5120000 periodicity-idr=45 inline-header=FALSE ! h264parse ! video/x-h264,stream-format=avc,alignment=au,width=640,height=480,framerate=30/1,profile=baseline ! kvssink stream-name="YourStreamName" frame-timestamp=dts-only access-key="YourAccessKey" secret-key="YourSecretKey" aws-region="YourAWSRegion"

例 8: Raspberry-PI と Ubuntu でオーディオとビデオの両方をストリーミングするgst-launch-1.0 コマンドを実行して、Raspberry-PI および Ubuntu でオーディオとビデオの両方のストリーミングを開始する方法について説明します。

例 9: MacOS で、オーディオとビデオの両方をストリーミングするgst-launch-1.0 コマンドを実行して、MacOS でオーディオとビデオの両方のストリーミングを開始する方法について説明します。

140

Page 147: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドDocker コンテナで GStreamer エレメントを実行します。

例 10: オーディオとビデオの両方を含む MKV ファイルのアップロードgst-launch-1.0 コマンドを実行して、オーディオとビデオの両方を含む MKV ファイルをアップロードする方法について説明します。

Docker コンテナで GStreamer エレメントを実行します。Docker は、コンテナを使用してアプリケーションを開発、デプロイ、実行するためのプラットフォームです。Docker を使用して GStreamer パイプラインを作成することで Kinesis ビデオストリーム のオペレーティング環境が標準化され、アプリケーションの構築と実行を大幅に簡素化できます。

Docker をインストールして設定するには、以下を参照してください。

• Docker のダウンロード手順• Docker の開始方法

Docker をインストールした後、docker pull コマンドを使用して Kinesis ビデオストリーム C++ プロデューサー SDK (および GStreamer プラグイン) を Amazon Elastic Container Registry からダウンロードできます。

Docker コンテナで Kinesis ビデオストリーム プロデューサー SDK エレメントをシンクとして GStreamerを実行するには

トピック• Docker クライアントを認証する (p. 141)• Ubuntu、macOS、Windows、または Raspberry Pi の Docker イメージのダウンロード (p. 141)• Docker イメージを実行する (p. 142)

Docker クライアントを認証するイメージのプル元になる Amazon ECR レジストリに対して Docker クライアントを認証します。使用するレジストリごとに認証トークンを取得する必要があり、トークンは 12 時間有効です。詳細については、Amazon Elastic Container Registry ユーザーガイドの「レジストリの認証」を参照してください。

Example : Amazon ECR を使用して認証する

aws ecr get-login --no-include-email --region us-west-2 --registry-ids 546150905175

このコマンドを処理すると、次のような出力が生成されます。

docker login -u AWS -p <Password> https://YourAccountId.dkr.ecr.us-west-2.amazonaws.com

結果の出力は、Amazon ECR レジストリに対して Docker クライアントを認証するために使用する、Docker ログインコマンドとなります。

Ubuntu、macOS、Windows、または Raspberry Pi の Docker イメージのダウンロードオペレーティングシステムに応じて次のコマンドのいずれかを使用し、Docker イメージを Docker 環境にダウンロードします。

141

Page 148: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドDocker コンテナで GStreamer エレメントを実行します。

Ubuntu の Docker イメージのダウンロード

sudo docker pull 546150905175.dkr.ecr.us-west-2.amazonaws.com/kinesis-video-producer-sdk-cpp-amazon-linux:latest

macOS の Docker イメージのダウンロード

sudo docker pull 546150905175.dkr.ecr.us-west-2.amazonaws.com/kinesis-video-producer-sdk-cpp-amazon-linux:latest

Windows の Docker イメージのダウンロード

docker pull 546150905175.dkr.ecr.us-west-2.amazonaws.com/kinesis-video-producer-sdk-cpp-amazon-windows:latest

Raspberry Pi の Docker イメージのダウンロード

sudo docker pull 546150905175.dkr.ecr.us-west-2.amazonaws.com/kinesis-video-producer-sdk-cpp-raspberry-pi:latest

イメージが正常に追加されたことを確認するには、次のコマンドを使用します。

docker images

Docker イメージを実行するオペレーティングシステムに応じて、次のコマンドのいずれかを使用して Docker イメージを実行します。

Ubuntu で Docker イメージを実行する

sudo docker run -it --network="host" --device=/dev/video0 546150905175.dkr.ecr.us-west-2.amazonaws.com/kinesis-video-producer-sdk-cpp-amazon-linux /bin/bash

macOS で Docker イメージを実行する

sudo docker run -it --network="host" 546150905175.dkr.ecr.us-west-2.amazonaws.com/kinesis-video-producer-sdk-cpp-amazon-linux /bin/bash

Windows で Docker イメージを実行する

docker run -it 546150905175.dkr.ecr.us-west-2.amazonaws.com/kinesis-video-producer-sdk-cpp-windows <AWS_ACCESS_KEY_ID> <AWS_SECRET_ACCESS_KEY> <RTSP_URL> <STREAM_NAME>

Raspberry Pi で Docker イメージを実行する

sudo docker run -it --device=/dev/video0 --device=/dev/vchiq -v /opt/vc:/opt/vc 546150905175

142

Page 149: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドパラメータリファレンス

.dkr.ecr.us-west-2.amazonaws.com/kinesis-video-producer-sdk-cpp-raspberry-pi /bin/bash

Docker によりコンテナが起動され、コンテナ内でコマンドを実行するコマンドプロンプトが表示されます。

コンテナ内で、次のコマンドを使用して環境変数を設定します。

export LD_LIBRARY_PATH=/opt/awssdk/amazon-kinesis-video-streams-producer-sdk-cpp/kinesis-video-native-build/downloads/local/lib:$LD_LIBRARY_PATHexport PATH=/opt/awssdk/amazon-kinesis-video-streams-producer-sdk-cpp/kinesis-video-native-build/downloads/local/bin:$PATHexport GST_PLUGIN_PATH=/opt/awssdk/amazon-kinesis-video-streams-producer-sdk-cpp/kinesis-video-native-build/downloads/local/lib:$GST_PLUGIN_PATH

デバイスに適した gst-launch-1.0 コマンドを使用してカメラからのストリーミングを開始します。

Note

macOS では、Docker コンテナで GStreamer を実行する場合にのみネットワークカメラからビデオをストリーミングできます。Docker コンテナで macOS の USB カメラからのビデオのストリーミングはサポートされていません。

gst-launch-1.0 コマンドを使用してローカルウェブカメラまたはネットワーク RTSP カメラに接続する礼については、「起動コマンド (p. 139)」を参照してください。

GStreamer エレメントパラメータのリファレンスビデオを Amazon Kinesis ビデオストリーム プロデューサー SDK に送信するには、kvssink をシンクまたはパイプラインの最終的な送信先としてを指定します。このリファレンスでは、kvssink の必須およびオプションのパラメータに関する情報を提供します。詳細については、「the section called“GStreamer” (p. 137)」を参照してください。

kvssink エレメントには以下の必須パラメータがあります。

• stream-name: 送信先 Kinesis ビデオストリーム の名前。

Note

IoT 認証を使用する場合、stream-name の値が、(IoT プロビジョニング内の) iot-thingname の値と同一でなければなりません。詳細については、IoT 認証の使用中に "無効なモノの名前が渡されました (Invalid thing name passed)" エラーが発生 (p. 188)を参照してください。

• storage-size: デバイスのストレージサイズ (キロバイト)。デバイスストレージの構成の詳細については、「StorageInfo (p. 109)」を参照してください。

• access-key: Kinesis ビデオストリーム にアクセスするために使用する AWS アクセスキー。このパラメータか credential-path のどちらかを指定する必要があります。

• secret-key: Kinesis ビデオストリーム にアクセスするために使用する AWS シークレットキー。このパラメータか credential-path のどちらかを指定する必要があります。

• credential-path: Kinesis ビデオストリーム にアクセスするための認証情報を含むファイルのパス。認証情報ファイルの例については、Sample Static Credential および Sample Rotating Credential を参照してください。このパラメータか、access-key および secret-key かの、どちらかを指定する必要があります。

kvssink エレメントには以下のオプションパラメータがあります。これらのパラメータの詳細については、Kinesis ビデオストリームの構造 (p. 110)を参照してください。

143

Page 150: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドパラメータリファレンス

パラメータ 説明 単位/タイプ デフォルト値

absolute-fragment-times

絶対フラグメントタイムを使用するかどうか。

Boolean true

avg-bandwidth-bps ストリームの予想される平均帯域幅。

1 秒あたりのバイト 4194304

aws-region 使用する AWS リージョン。

文字列 us-west-2

buffer-duration ストリームのバッファ期間。

Seconds 180

codec-id ストリームのコーデック ID。

文字列 "V_MPEG4/ISO/AVC"

connection-staleness

ストリームの古さのコールバックが呼び出されるまでの時間。

Seconds 60

content-type ストリームのコンテンツタイプ。

文字列 "video/h264"

fragment-acks ACK フラグメントを使用するかどうか。

Boolean true

fragment-duration フラグメントの有効期間。

ミリ秒 2000

framerate 予想されるフレームレート。

1 秒あたりのフレーム 25

frame-timecodes フレームのタイムコードを使用するか、現在時刻のコールバックを使用してタイムスタンプを生成するかどうかを指定します。

Boolean true

frame-timestamp • (0): pts-only: Kinesisビデオストリーム に送信されるフレームごとに、デコードタイムスタンプ (DTS)をプレゼンテーションタイムスタンプ(PTS) に等しく設定します。

• (1): dts-only: Kinesisビデオストリーム に送信されるフレームごとに、PTS を DTSに等しく設定します。

• (2): default-timestamp: PTS およ

列挙型GstKvsSinkFrameTimestampType

default-timestamp

144

Page 151: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドパラメータリファレンス

パラメータ 説明 単位/タイプ デフォルト値び DTS を両方使用します。片方が使用できない場合は、もう片方を使用します。

key-frame-fragmentation

キーフレームでフラグメントを生成するかどうかを指定します。

Boolean true

log-config ログ設定のパス。 文字列 "./kvs_log_configuration"

max-latency ストリームの最大レイテンシー。

Seconds 60

recalculate-metrics

メトリクスを再計算するかどうかを指定します。

Boolean true

replay-duration 再開が有効になっている場合、エラー発生時の再生まで現在のリーダーをロールバックする期間。

Seconds 40

restart-on-error エラーが発生したときに再起動するかどうか。

Boolean true

retention-period ストリームが保持される期間。

時間 2

rotation-period キーの更新間隔。詳細については、「カスタマーマスターキーのローテーション」を参照してください。

Seconds 2400

streaming-type ストリーミングタイプ。有効な値を次に示します。

• 0: リアルタイム• 1: ほぼリアルタイム

(現在サポートされていません)

• 2: オフライン (現在サポートされていません)

列挙型GstKvsSinkStreamingType

0: リアルタイム

timecode-scale MKV のタイムコードスケール。

ミリ秒 1

track-name MKV トラック名。 文字列 "kinesis_video"

145

Page 152: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドPutMedia API

パラメータ 説明 単位/タイプ デフォルト値

iot-certificate kvssink 要素で使用される IoT 認証情報。次のキーと値を使用できます。

• endpoint=iotcredentialsproviderendpoint• cert-path=/

localdirectorypath /to/certificate

• key-path=/localdirectorypath /to/private/key

• ca-path=/localdirectorypath/to/ca-cert

• role-aliases=role-aliases

文字列 なし

例: PutMedia API を使用した Kinesis ビデオストリーム へのデータの送信

この例は、PutMedia API を使用して以下を行う方法を説明するものです。この例は、すでにコンテナ形式 (MKV) であるデータの送信方法を示しています。送信前にデータをコンテナ形式にアセンブルする (カメラの動画データをフレームにアセンブルするなど) 必要がある場合は、Kinesis ビデオストリーム プロデューサーライブラリ (p. 47) を参照してください。

Note

PutMedia オペレーションは、接続およびデータフロー、送達確認の全二重管理のため、C++ および Java SDK でのみ利用できます。他の言語ではサポートされていません。

この例には以下のステップが含まれます。• ステップ 1: コードをダウンロードして設定する (p. 146)• ステップ 2: コードを作成してテストする (p. 147)• ステップ 3: コードを実行して検証する (p. 149)

ステップ 1: コードをダウンロードして設定するこのセクションでは、Java のコード例をダウンロードしてプロジェクトを Java IDE にインポートし、ライブラリのロケーションを設定して、AWS 認証情報を使用するコードを設定します。

1. ディレクトリを作成し、GitHub リポジトリのソースコード例からクローンを作成します。PutMediaの例は、Java プロデューサーライブラリ (p. 48) の一部です。

$ git clone https://github.com/awslabs/amazon-kinesis-video-streams-producer-sdk-java

2. 使用する Java IDE (Eclipse や IntelliJ IDEA など) を開き、ダウンロードした Apache Maven プロジェクトをインポートします。

146

Page 153: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドステップ 2: コードを作成してテストする

• Eclipse では: [ファイル]、[インポート]、[Maven]、[Existing Maven Projects (既存の Maven プロジェクト)] を選択し、ダウンロードしたパッケージのルートに移動します。pom.xml ファイルを選択します。

• IntelliJ Idea では: [インポート] を選択します。ダウンロードしたパッケージのルートに含まれるpom.xml ファイルに移動します。

詳細については、関連する IDE ドキュメントを参照してください。3. インポートしたライブラリのロケーションが IDE で見つかるようにするため、プロジェクトを更新し

ます。• IntelliJ IDEA の場合は以下を実行します。

a. プロジェクトの lib ディレクトリのコンテキスト (右クリック) メニューを開き、[Add aslibrary] を選択します。

b. [ファイル]、[Project Structure] の順に選択します。c. [Project Settings] で [Modules] を選択します。d. [Sources] タブで Language Level を 7 以上に設定します。

• Eclipse の場合は以下を実行します。

a. プロジェクトのコンテキスト (右クリック) メニューを開き、[プロパティ]、[Java BuildPath]、[ソース] の順に選択します。次に、以下の操作を実行します。

1. [Source] タブで、[Native library location] をダブルクリックします。2. [Native Library Folder Configuration] ウィザードで [Workspace] を選択します。3. [Native Library Folder] の選択肢からプロジェクトの lib ディレクトリを選択します。

b. プロジェクトのコンテキスト (右クリック) メニューを開き、[プロパティ] を選択します。次に、以下の操作を実行します。

1. [Libraries] タブで、[Add Jars] を選択します。2. [JAR selection (JAR 選択)] ウィザードで、プロジェクトの lib ディレクトリ内のすべて

の .jar を選択します。

ステップ 2: コードを作成してテストするPutMedia API の例 () は、次のコーディングパターンを示しています。PutMediaDemo

トピック• PutMediaClient を作成する (p. 147)• メディアをストリーミングしてスレッドを一時停止する (p. 148)

このセクションのコード例は、PutMediaDemo クラスのものです。

PutMediaClient を作成するPutMediaClient オブジェクトを作成するには以下のパラメーターが必要です。

• PutMedia エンドポイントの URI。• ストリーミングする MKV ファイルを指す InputStream。• ストリーム名。この例では、Java プロデューサーライブラリを使用する (p. 48) (my-stream) で作成さ

れたものと同じストリームを使用します。別のストリームを使用するには、以下のパラメーターを変更します。

147

Page 154: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドステップ 2: コードを作成してテストする

private static final String STREAM_NAME="my-stream";

Note

PutMedia API の例では、ストリームは作成されません。Java プロデューサーライブラリを使用する (p. 48) 用のテストアプリケーションの使用、Kinesis ビデオストリーム コンソールの使用、または AWS CLI の使用のいずれかの方法で、ストリームを作成する必要があります。

• 現在のタイムスタンプ。• タイムコードのタイプ。この例では RELATIVE が使用されます。これは、タイムスタンプがコンテナの

開始を基準にしていることを示します。• 受信したパケットが承認済の送信者から送信されたことを確認する AWSKinesisVideoV4Signer オブ

ジェクト。• 最大アップストリーム帯域幅 (Kbps)• パケットの送達確認を受け取る AckConsumer オブジェクト.

PutMediaClient オブジェクトは以下のコードを作成します。

/* actually URI to send PutMedia request */final URI uri = URI.create(KINESIS_VIDEO_DATA_ENDPOINT + PUT_MEDIA_API);

/* input stream for sample MKV file */final InputStream inputStream = new FileInputStream(MKV_FILE_PATH);

/* use a latch for main thread to wait for response to complete */final CountDownLatch latch = new CountDownLatch(1);

/* a consumer for PutMedia ACK events */final AckConsumer ackConsumer = new AckConsumer(latch);

/* client configuration used for AWS SigV4 signer */final ClientConfiguration configuration = getClientConfiguration(uri);

/* PutMedia client */final PutMediaClient client = PutMediaClient.builder() .putMediaDestinationUri(uri) .mkvStream(inputStream) .streamName(STREAM_NAME) .timestamp(System.currentTimeMillis()) .fragmentTimeCodeType("RELATIVE") .signWith(getKinesisVideoSigner(configuration)) .upstreamKbps(MAX_BANDWIDTH_KBPS) .receiveAcks(ackConsumer) .build();

メディアをストリーミングしてスレッドを一時停止するクライアントが作成されると、サンプルが putMediaInBackground との同時ストリーミングを開始します。AckConsumer が返されるまでメインスレッドは latch.await で一時停止し、この時点でクライアントは切断されます。

/* start streaming video in a background thread */ client.putMediaInBackground();

/* wait for request/response to complete */ latch.await();

148

Page 155: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドステップ 3: コードを実行して検証する

/* close the client */ client.close();

ステップ 3: コードを実行して検証するPutMedia API の例を実行するには、以下を実行します。

1. Kinesis ビデオストリーム コンソールで、または AWS CLI を使用して my-stream という名前のストリームを作成します。

2. 作業ディレクトリを Java プロデューサー SDK ディレクトリに変更します。

$ cd /<YOUR_FOLDER_PATH_WHERE_SDK_IS_DOWNLOADED>/amazon-kinesis-video-streams-producer-sdk-java/

3. Java SDK およびデモアプリケーションをコンパイルします。

mvn package

4. /tmp ディレクトリに一時ファイル名を作成します。

$ jar_files=$(mktemp)

5. ローカルリポジトリからファイルへの依存関係のクラスパス文字列を作成します。

$ mvn -Dmdep.outputFile=$jar_files dependency:build-classpath

6. LD_LIBRARY_PATH 環境変数の値を次のように設定します。

$ export LD_LIBRARY_PATH=/<YOUR_FOLDER_PATH_WHERE_SDK_IS_DOWNLOADED>/amazon-kinesis-video-streams-producer-sdk-cpp/kinesis-video-native-build/downloads/local/lib:$LD_LIBRARY_PATH$ classpath_values=$(cat $jar_files)

7. AWS 認証情報を指定して、次のようにコマンドラインからデモを実行します。

$ java -classpath target/kinesisvideo-java-demo-1.0-SNAPSHOT.jar:$classpath_values -Daws.accessKeyId=${ACCESS_KEY} -Daws.secretKey=${SECRET_KEY} -Djava.library.path=/opt/amazon-kinesis-video-streams-producer-sdk-cpp/kinesis-video-native-build com.amazonaws.kinesisvideo.demoapp.DemoAppMain

8. https://console.aws.amazon.com/kinesisvideo/ で Kinesis ビデオストリーム コンソールを開き、[Manage Streams (ストリームの管理)] ページでストリームを選択します。動画が [Video Preview] ペインで再生されます。

例: RTSP ソースからのストリーミングC++ プロデューサーライブラリ (p. 57)には、RTSP (Real Time Streaming Protocol) ネットワークカメラに接続する Docker コンテナの定義が含まれています。Docker を使用することで Kinesis ビデオストリームのオペレーティング環境が標準化され、アプリケーションの構築と実行を大幅に簡素化できます。

RTSP デモアプリケーションを使用するには、最初に C++ プロデューサーライブラリ (p. 57) をインストールして構築します。

次の手順では、RTSP デモアプリケーションのセットアップ方法と使用方法を示しています。

149

Page 156: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイド前提条件

トピック• 前提条件 (p. 150)• Docker イメージの作成 (p. 150)• RTSP サンプルアプリケーションを実行する (p. 150)

前提条件Kinesis ビデオストリーム RTSP サンプルアプリケーションを実行するには、以下が必要です。

• Docker: Docker のインストールと使用に関する情報については、以下のリンクを参照してください。• Docker のダウンロード手順• Docker の開始方法

• RTSP ネットワークカメラソース: 推奨カメラについては、「システム要件 (p. 3)」を参照してください。

Docker イメージの作成まず、デモアプリケーション内で実行される Docker イメージを構築します。

1. 新しいディレクトリを作成し、次のファイルを docker_native_scripts ディレクトリから新しいディレクトリにコピーします。

• Dockerfile

• start_rtsp_in_docker.sh

2. 前の手順で作成したディレクトリに移動します。3. 以下のコマンドを使用して、Docker イメージを構築します。このコマンドは、イメージを作成してそ

れに rtspdockertest とタグ付けします。

docker build -t rtspdockertest .

4. 前のステップで返されたイメージ ID を記録します (例: 54f0d65f69b2)。

RTSP サンプルアプリケーションを実行する次のコマンドを使用して Kinesis ビデオストリーム Docker コンテナを起動します。前のステップで取得したイメージ ID、AWS 認証情報、RTSP ネットワークカメラの URL、およびデータを送信する Kinesis ビデオストリーム の名前を指定します。

$ docker run -it <IMAGE_ID> <AWS_ACCESS_KEY_ID> <AWS_SECRET_ACCESS_KEY> <RTSP_URL> <STREAM_NAME>

アプリケーションをカスタマイズするには、Dockerfile の ENTRYPOINT コマンドをコメントまたは削除し、以下のコマンドを使用してコンテナを起動します。

docker run -it <IMAGE_ID> bash

Docker コンテナ内でサンプルアプリケーションをカスタマイズしストリーミングを開始するように表示されます。

150

Page 157: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドレンダラー

例: Kinesis ビデオストリーム フラグメントの解析およびレンダリング

ストリームパーサーライブラリ (p. 128) には、Amazon Kinesis ビデオストリーム フラグメントの解析とレンダリングを説明する KinesisVideoRendererExample という名前のアプリケーションが含まれています。この例では、例: Kinesis ビデオストリーム プロデューサー SDK GStreamer プラグイン (p. 137) アプリケーションを使用して取り込まれた H.264 エンコードのフレームを JCodec を使用してデコードします。JCodec を使用してフレームをデコードすると、視覚イメージは JFrame を使用してレンダリングされます。

この例は、次を実行する方法を説明しています。

• GetMedia API を使用して Kinesis ビデオストリーム からフレームを取得し、表示するためにストリームをレンダリングします。

• Kinesis ビデオストリーム コンソールを使用する代わりに、カスタムアプリケーションでストリームの動画コンテンツを表示します。

また、表示される前にデコードを必要としない JPEG ファイルのストリームなど、H.264 としてエンコードされていない Kinesis ビデオストリーム コンテンツの表示にこの例のクラスを使用することもできます。

次の手順では、レンダラ―デモアプリケーションのセットアップと使用方法を示しています。

前提条件レンダラ―の例のライブラリを確かめて使用するには、以下が必要です。

• Amazon Web Services (AWS) アカウントAWS アカウントがまだない場合は、「Kinesis ビデオストリームの開始方法」を参照してください。

• Eclipse Java Neon や JetBrains IntelliJ Idea などの Java 統合開発環境 (IDE)。

レンダラ―の例の実行1. ディレクトリを作成して、GitHub リポジトリのソースコード例からクローンを作成します。

$ git clone https://github.com/aws/amazon-kinesis-video-streams-parser-library

2. 使用する Java IDE (Eclipse や IntelliJ IDEA など) を開き、ダウンロードした Apache Maven プロジェクトをインポートします。

• Eclipse では: [ファイル]、[インポート]、[Maven]、[Existing Maven Projects] を選択します。kinesis-video-streams-parser-lib ディレクトリに移動します。

• IntelliJ Idea では: [インポート] を選択します。ダウンロードしたパッケージのルートに含まれるpom.xml ファイルに移動します。

Note

IntelliJ が依存関係を検出できない場合は、以下の手順の実行が必要になることがあります。• 構築のクリーン: [File (ファイル)]、[Settings (設定)]、[Build, Execution, Deployment (構

築、実行、デプロイ)]、[Compiler (コンパイラー)] の順に選択します。[Clear outputdirectory on rebuild (再構築時に出力ディレクトリをクリアする)] が選択されていることを確認して、[Build (構築)]、[Build Project (プロジェクトの構築)] の順に選択します。

151

Page 158: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイド仕組み

• プロジェクトの再インポート: プロジェクトのコンテキスト (右クリック) メニューを開き、[Maven]、[Reimport (再インポート)] の順に選択します。

詳細については、関連する IDE ドキュメントを参照してください。3. Java IDE で src/test/java/com.amazonaws.kinesisvideo.parser/examples/

KinesisVideoRendererExampleTest を開きます。4. このファイルから @Ignore ディレクティブを削除します。5. .stream パラメータを使用する Kinesis ビデオストリーム の名前に置き換えます。6. KinesisVideoRendererExample テストを実行します。

仕組み例のアプリケーションは次を示します。

• MKV データの送信 (p. 152)• MKV フラグメントをフレームに解析する (p. 152)• フレームのデコードと表示 (p. 152)

MKV データの送信この例では、動画データを [render-example-stream] とい名前のストリームに送信するために PutMediaを使用して rendering_example_video.mkv ファイルからサンプル MKV データ を送信します。

このアプリケーションは PutMediaWorker を作成します。

PutMediaWorker putMediaWorker = PutMediaWorker.create(getRegion(), getCredentialsProvider(), getStreamName(), inputStream, streamOps.amazonKinesisVideo);executorService.submit(putMediaWorker);

PutMediaWorker クラスの詳細については、ストリームパーサーライブラリ (p. 128) ドキュメンテーションで「PutMedia 呼び出し (p. 132)」を参照してください。

MKV フラグメントをフレームに解析するこの例では次に、GetMediaWorker を使用してストリームから MKV フラグメントを取得し、解析します。

GetMediaWorker getMediaWorker = GetMediaWorker.create(getRegion(), getCredentialsProvider(), getStreamName(), new StartSelector().withStartSelectorType(StartSelectorType.EARLIEST), streamOps.amazonKinesisVideo, getMediaProcessingArgumentsLocal.getFrameVisitor());executorService.submit(getMediaWorker);

GetMediaWorker クラスの詳細については、ストリームパーサーライブラリ (p. 128) ドキュメンテーションで「GetMedia 呼び出し (p. 132)」を参照してください。

フレームのデコードと表示この例では次に、JFrame を使用してフレームをデコードし、表示します。

152

Page 159: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon SageMaker

以下は、JFrame を拡張する KinesisVideoFrameViewer クラスからのコード例です。

public void setImage(BufferedImage bufferedImage) { image = bufferedImage; repaint();}

java.awt.image.BufferedImage のインスタンスとしてイメージが表示されます。BufferedImage を使用する方法を示す例については、「Reading/Loading an Image (イメージの読み取りとロード)」を参照してください。

例: Amazon SageMaker を使用してビデオストリーム内のオブジェクトを識別する

この例では、Amazon SageMaker を使用して、特定のオブジェクトが Amazon Kinesis ビデオストリームに表示されるタイミングを識別するソリューションを作成する方法を示します。Amazon SageMaker は、開発者およびデータ科学者が機械学習モデルを迅速かつ容易に構築、トレーニング、デプロイするための、マネージド型プラットフォームです。

この例は、アプリケーションの機能を含む Docker コンテナと、アプリケーションの AWS リソースのデプロイを自動化する AWS CloudFormation テンプレートで構成されています。

AWS CloudFormation テンプレートによって以下のリソースが作成されます。

• ライブラリソフトウェアを実行する AWS Fargate コンピューティングエンジンを使用する AmazonElastic Container Service (Amazon ECS) クラスター。

• Fargate タスクで実行されるワーカー間でチェックポイントと関連状態を管理する Amazon DynamoDBテーブル。

• Amazon SageMaker から生成された推論出力を取得する Kinesis データストリーム。• Amazon SageMaker からの出力を解析する AWS Lambda 関数。• サービス間でのアクセス用の AWS Identity and Access Management (IAM) リソース。• アプリケーションのモニタリング用の Amazon CloudWatch リソース。

アプリケーションは、データを処理する Amazon SageMaker エンドポイントすべてと互換性があります。この例には、サンプルのオブジェクト識別アルゴリズムテンプレートを使用する Amazon SageMakerエンドポイントを作成するための手順が含まれています。アプリケーションのユースケースと要件に基づいて、アルゴリズムを変更したり置き換えたりできます。

トピック• 前提条件 (p. 153)• アプリケーションの作成 (p. 154)• アプリケーションのモニタリング (p. 156)• アプリケーションの機能拡張 (p. 157)• アプリケーションのクリーンアップ (p. 158)

前提条件サンプルアプリケーションには、以下の前提条件があります。

153

Page 160: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドアプリケーションの作成

• Amazon SageMaker (p. 154)• Kinesis ビデオストリーム (p. 154)• サービスにリンクされたロール (p. 154)

Amazon SageMakerこの例では Amazon SageMaker ノートブックが必要です。ノートブックの作成については、AmazonSageMaker 開発者ガイドの「ノートブックインスタンスの作成」を参照してください。ノートブックを作成するときは、以下の点に注意してください。

• [Jupyter] コンソールの [SageMaker Examples (SageMaker 例)] タブの[Introduction to Amazon Algorithms (Amazon アルゴリズムの概要)] セクションからobject_detection_image_json_format.ipynb 例をノートブックに追加します。

• 例を追加するときに、Amazon Simple Storage Service (Amazon S3) バケットを作成し、[前提条件] ステップでその名前を指定します。

• ノートブックを作成したら、Amazon SageMaker コンソールで [エンドポイント設定] を選択し、[エンドポイント名] を記録します。

Kinesis ビデオストリームこの例では、ライブビデオデータを含む 1 つ以上の Kinesis ビデオストリームが必要です。Kinesis ビデオストリーム を作成してカメラからデータを送信する方法については、「GStreamer (p. 137)」を参照してください。Kinesis ビデオストリーム の名前を記録します。

サービスにリンクされたロールこの例では、アカウントに AWS Fargate オペレーションのサービスにリンクされたロールが必要です。新しい AWS アカウントでは、このロールがデフォルトで有効になっています。アプリケーションの作成時に以下のエラーが表示された場合は、サービスにリンクされたロールを有効にする必要があります。

Unable to assume the service linked role. Please verify that the ECS service linked role exists

サービスにリンクされたロールを有効にするには、以下のコマンドを実行します。

aws iam create-service-linked-role --aws-service-name ecs.amazonaws.com

アプリケーションの作成サンプルアプリケーションを作成するには、AWS CloudFormation と付属のテンプレートを使用します。

AWS CloudFormation を使用してアプリケーションを作成するには

1. AWS マネジメントコンソール にサインインし、AWS リージョンの以下のいずれかのリンクを使用して AWS CloudFormation コンソールを開きます。このリンクからリージョンの正しいスタックが起動されます。

• アジアパシフィック (シドニー) リージョン (ap-southeast-2) で起動• アジアパシフィック (東京) リージョン (ap-northeast-1) で起動• 欧州 (フランクフルト) リージョン (eu-central-1) で起動

154

Page 161: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドアプリケーションの作成

• 欧州 (アイルランド) リージョン (eu-west-1) で起動• 米国東部(バージニア北部) リージョン (us-east-1) で起動• 米国西部 (オレゴン) リージョン (us-west-2) で起動

2. [スタックの作成] ページで、以下の値を入力します。

• スタックに一意の名前 (username-KVS-SageMaker など) を付けます。• 前のセクションで作成した Amazon SageMaker エンドポイント名 (エンドポイント ARN ではない)

を指定します。• Kinesis ビデオストリーム の名前を入力します。複数の Kinesis ビデオストリーム がある場合は、

ストリーム名を引用符で囲み、コンマで区切ります。• 残りの設定はそのままにします。

[Next (次へ)] を選択します。3. [Options (オプション)] ページで、設定をそのままにします。4. [AWS CloudFormation によって IAM リソースが作成される場合があることを承認します] チェック

ボックスをオンにします。[Next (次へ)] を選択します。

AWS CloudFormation によってアプリケーションが作成されます。

次の表は、この AWS CloudFormation テンプレートを使用してスタックを作成するときに Docker コンテナで使用されるパラメータの一覧です。これらの値はテンプレートの SSM リソースで事前定義されていますが、必要に応じてカスタマイズできます。

リソース名 デフォルト値 説明

inferenceInterval 6 SageMaker エンドポイントに送信されるビデオフレームのサンプリングレート。現在、I フレームでの推論のみサポートされています。デフォルト値の 6 は、6 つの Iフレームごとに 1 つが SageMaker エンドポイントに送信されることを意味します。

sageMakerTaskQueueSize 5000 SageMaker エンドポイントへの保留中のリクエストを管理するキューのサイズ。キューのサイズは、「inferenceInternval」と「sageMakerTaskTimeoutInMilli」による影響を受けます。Sagemaker の推論に時間がかかる場合、リクエストはこのキューにバッファされます。

sageMakerTaskThreadPoolSize 20 SageMaker リクエストの同時実行に使用されるスレッド数。

sageMakerTaskTimeoutInMilli 20000 SageMaker エンドポイントに送信される単一のリクエスト (または再試行リクエスト) に許可される最大期間。

sageMakerTaskThreadPoolName SageMakerThreadPool-%d

SageMaker エンドポイントにリクエストを送信しているスレッドプールの名前。

これらのパラメータの値をカスタマイズするには、[スタックの作成] ページでテンプレートの URL を選択して AWS CloudFormation テンプレートをダウンロードし、テンプレートの次のような Params セクションでこれらのパラメータを見つけます。

Params: Type: AWS::SSM::Parameter Properties: Name: Ref: AppName Description: "Configuration for SageMaker app" Type: String Value: Fn::Sub: | {"streamNames":[${StreamNames}], "tagFilters":[${TagFilters}],"sageMakerEndpoint":"${SageMakerEndpoint}", "endPointAcceptContentType": "${EndPointAcceptContentType}",

155

Page 162: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドアプリケーションのモニタリング

"kdsStreamName":"${Kds}","inferenceInterval":6,"sageMakerTaskQueueSize":5000, "sageMakerTaskThreadPoolSize":20,"sageMakerTaskTimeoutInMilli":20000, "sageMakerTaskThreadPoolName":"SageMakerThreadPool-%d"}

アプリケーションのモニタリングAWS CloudFormation テンプレートによって作成されたアプリケーションには、Amazon CloudWatch ダッシュボードと CloudWatch ログストリームが含まれており、これらを使用してアプリケーションのメトリクスとイベントをモニタリングします。

アプリケーションダッシュボードアプリケーションには、アプリケーションメトリクスをモニタリングするための CloudWatch ダッシュボードが含まれています。アプリケーションダッシュボードを表示するには、CloudWatch コンソール(https://console.aws.amazon.com/cloudwatch/) を開き、左側のナビゲーションバーで [ダッシュボード] を選択します。

[KVS-SageMaker-Driver-KvsSageMakerIntegration-aws-region] ダッシュボードを選択します。ダッシュボードには以下の情報が表示されます。

• Frame Metrics: ビデオストリームを処理すること、Amazon SageMaker エンドポイントにフレームを送信すること、Amazon SageMaker ノートブックを Amazon SageMaker 推論出力の処理用 AWS Lambda関数に接続する Kinesis データストリームに書き込むことに関するメトリクス。

• IngestToProcessLatency: Kinesis ビデオストリーム サービスにビデオフレームが取り込まれてからアプリケーションがフレームを受信するまでの時間差。

• Current Lease Total: アプリケーションには、リースを使用して Kinesis ビデオストリーム から読み取るアクセス許可が付与されます。このメトリクスはアクティブなリースの数を示します。アプリケーションは Kinesis ビデオストリーム ごとに 1 つのリースを使用し、ストリーム間の同期に 1 つのリースを使用します。

• Lease Sync Metrics: アクセス許可リース同期の頻度と持続期間。• LeaseCount per Worker: Amazon SageMaker ワーカースレッド間のリースの分配。• Number of Workers: ストリームを処理している Amazon SageMaker ワーカーの数。Amazon ECS クラ

スター内の各タスクには実行中の 1 つのワーカーがあります。1 つのワーカーは複数のストリームを処理できます。

• ECS Service Utilization: Amazon ECS クラスターの使用状況メトリクス。• KinesisDataStream: Kinesis データストリームの使用状況メトリクス。• SageMaker: Amazon SageMaker ノートブックによって実行されたオペレーション。• Lambda: Amazon SageMaker ノートブックからの出力を処理する Lambda 関数の数と持続期間。

これらのグラフのいずれかの情報がオペレーション上の問題 (安定しているのではなく着実に増加している値など) を示している場合は、アプリケーションログを読んで問題を特定する方法について、以下のセクションを参照してください。

CloudWatch ログアプリケーションには 2 つの CloudWatch ログが含まれています。

トピック• アプリケーションログ (p. 157)• Lambda 関数ログ (p. 157)

156

Page 163: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドアプリケーションの機能拡張

アプリケーションログ

アプリケーションログを使用して、アプリケーションイベントとエラー状態をモニタリングできます。このログは、製品サポートに問題を連絡する必要がある場合に役立ちます。

アプリケーションログを読むには

1. Amazon ECS コンソール (https://console.aws.amazon.com/ecs) を開きます。2. [KVS-Sagemaker-Driver] クラスターを選択します。3. [サービス] タブで [stack-name-SageMakerDriverService] サービスを選択します。4. [ログ] タブを選択します。

アプリケーションログには、初期化、設定、リースアクティビティなどのイベントが表示されます。

Lambda 関数ログ

Lambda 関数ログを使用して、オブジェクトの成功した識別を追跡できます。

Lambda ログを読むには

1. AWS Lambda コンソール (https://console.aws.amazon.com/lambda) を開きます。2. アプリケーションの Lambda 関数を選択します。Lambda 関数名は以下の形式です。

stack-name-LambdaFunction-A1B2C3D4E5F6G

3. [Monitoring (モニタリング)] パネルを選択します。4. [CloudWatch のログを表示] を選択します。

アプリケーションの CloudWatch ログには、Kinesis ビデオストリーム と他のアプリケーションのイベントでのオブジェクトの成功した識別が示されています。

アプリケーションの機能拡張以下のように AWS CloudFormation テンプレートウィンドウに指定した値を変更することで、アプリケーションにカスタム機能を追加できます。

• EndPointAcceptContentType: Amazon SageMaker エンドポイントが JPG 形式のフレームを受け付けない場合は、この値を変更できます。以下の形式がサポートされています。• image/jpeg

• image/png

• image/bmp

• image/gif

• application/x-image

• LambdaFunctionBucket、LambdaFunctionKey: 付属の設定では、Amazon SageMaker 出力を処理してCloudWatch Logs に書き込む AWS Lambda 関数が使用されます。Amazon SageMaker 出力を他の場所に送信する場合は、独自の Lambda 関数を提供できます。

• タグフィルタ: the section called “TagStream” (p. 234) アクションを使用してタグ付けされたストリームがある場合は、処理するストリームのタグを指定できます。たとえば、2 つのストリームのLocation キー値がそれぞれ Front と Parking である場合、以下のエントリにより、それらのストリームのみを使用するようにフィルタ処理します。

{"key":"Location","values":["Front","Parking"]}

157

Page 164: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドアプリケーションのクリーンアップ

アプリケーションのクリーンアップこのチュートリアル用に作成したアプリケーションを使い終わったら、継続的な請求が発生しないように、保持しないリソースを削除することをお勧めします。

1. Amazon SageMaker エンドポイント: 既存のエンドポイントを使用するのではなく、このチュートリアル用に Amazon SageMaker エンドポイントを作成した場合は、そのエンドポイントを削除してください。Amazon SageMaker コントロールパネルで、[エンドポイント設定] を選択します。作成したエンドポイントを選択してから、[Actions (アクション)]、[Delete (削除)] の順に選択します。削除を確定します。

2. Amazon SageMaker ノートブック: Amazon SageMaker コンソールで、[ノートブックインスタンス]を選択します。作成したノートブックを選択しから、[Actions (アクション)]、[Stop (停止)] の順に選択します。ノートブックに [Status (ステータス)] が [停止] と表示されたら、[Actions (アクション)]、[Delete (削除)] の順に選択します。削除を確定します。

Note

Amazon SageMaker リソースのクリーンアップの詳細については、Amazon SageMaker 開発者ガイドの「クリーンアップ」を参照してください。

3. Amazon SageMaker 実行ポリシー: IAM コンソールのナビゲーションペインで、[ポリシー]を選択します。このチュートリアル用に作成したポリシーを選択します。ポリシーの名前はAmazonSageMaker-ExecutionPolicy-timestamp のようになります。

[ポリシーアクション]、[Delete (削除)] の順に選択します。 削除を確定します。4. Amazon SageMaker 実行ロール: IAM コンソールのナビゲーションペインで、[ロール] を選択しま

す。このチュートリアル用に作成したロールを選択します。ポリシーの名前は AmazonSageMaker-ExecutionRole-timestamp のようになります。

[ロールの削除] を選択します。削除を確定します。5. AWS CloudFormation スタック: AWS CloudFormation コンソールで、このチュートリアル用に作成し

たスタックを選択します。[アクション]、[スタックの削除] の順に選択します。削除を確定します。6. Amazon S3 バケット: Amazon S3 コンソールで、Amazon SageMaker アセットの保存用に作成した

バケットを選択します。[Delete] を選択します。バケットの名前を入力し、[Confirm (確認)] を選択して削除を確定します。

7. Kinesis ビデオストリーム: Kinesis ビデオストリーム コンソールで、アプリケーション用に作成したビデオストリームを選択します。[Delete] を選択します。削除を確定します。

158

Page 165: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドCloudWatch を使用したメトリクスのモニタリング

Kinesis ビデオストリーム のモニタリング

モニタリングは、Kinesis ビデオストリーム および AWS ソリューションの信頼性、可用性、パフォーマンスを維持する上で重要な部分です。マルチポイント障害が発生した場合は、その障害をより簡単にデバッグできるように、AWS ソリューションのすべての部分からモニタリングデータを収集する必要があります。ただし、Kinesis ビデオストリーム のモニタリングを開始する前に、以下の質問に対する回答を反映したモニタリング計画を作成する必要があります。

• どのような目的でモニタリングしますか?• モニタリングの対象となるリソースとは ?• どのくらいの頻度でこれらのリソースをモニタリングしますか?• 使用するモニタリングツールは?• 誰がモニタリングタスクを実行しますか?• 誰が問題が発生したときに通知を受け取りますか?

モニタリングの目的を定義し、モニタリングの計画を作成したら、次のステップとして、お客様の環境内で通常の Kinesis ビデオストリーム パフォーマンスのベースラインを確立します。さまざまな時間帯に、さまざまな負荷条件で Kinesis ビデオストリーム パフォーマンスを測定します。Kinesis ビデオストリーム をモニタリングしながら、収集したモニタリングデータの履歴を格納する必要があります。現在のKinesis ビデオストリーム パフォーマンスをこの履歴データと比較して、通常のパフォーマンスパターンとパフォーマンス異常を識別することで、発生する可能性のある異常への対処方法を考案することが容易になります。

トピック• CloudWatch を使用した Kinesis ビデオストリーム メトリクスのモニタリング (p. 159)• AWS CloudTrail を使用した Kinesis ビデオストリーム API コールのログ記録 (p. 170)

CloudWatch を使用した Kinesis ビデオストリームメトリクスのモニタリング

Amazon CloudWatch を使用して Kinesis ビデオストリーム をモニタリングすることで、Kinesis ビデオストリーム から raw データを収集し、リアルタイムに近い読み取り可能なメトリクスに加工することができます。これらの統計は 15 か月間記録されるため、履歴情報にアクセスしてウェブアプリケーションやサービスの動作をより的確に把握できます。

Kinesis ビデオストリーム 管理コンソールでは、次の 2 つの方法で Kinesis ビデオストリーム のCloudWatch メトリクスを表示できます。

• [ダッシュボード] ページの [Account-level metrics for Current Region (現在のリージョンのアカウントレベルのメトリクス)] セクションで、[ビデオストリーム] タブを選択します。

• ビデオストリームの詳細ページで、[モニタリング] タブを選択します。

Kinesis ビデオストリーム は以下のメトリクスを提供します。

159

Page 166: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドCloudWatch を使用したメトリクスのモニタリング

メトリクス 説明

PutMedia.Requests 指定されたストリームでの PutMedia API リクエストの数。

単位: 個

PutMedia.IncomingBytes ストリームの PutMedia の一部として受信したバイトの数。

単位: バイト

PutMedia.IncomingFragments ストリームの PutMedia の一部として受信した完全なフラグメントの数。

単位: 個

PutMedia.IncomingFrames ストリームの PutMedia の一部として受信した完全なフレームの数。

単位: 個

PutMedia.ActiveConnections サービスホストへの接続の合計数。

単位: 個

PutMedia.ConnectionErrors ストリームの PutMedia 接続を確立中に発生したエラー。

単位: 個

PutMedia.FragmentIngestionLatency Kinesis ビデオストリーム によってフラグメントの最初のバイトが受信されてから最後のバイトが受信されるまでの時間差。

単位: ミリ秒

PutMedia.FragmentPersistLatency 完全なフラグメントデータが受信されてアーカイブされたときからの所要時間。

単位: 個

PutMedia.Latency 接続確立中にリクエストを送信してから InletService から HTTP レスポンスを受信するまでの時間差。

単位: 個

PutMedia.BufferingAckLatency Kinesis ビデオストリーム によって新しいフラグメントの最初のバイトが受信されてからフラグメントのバッファリング確認が送信されるまでの時間差。

単位: ミリ秒

PutMedia.ReceivedAckLatency Kinesis ビデオストリーム によって新しいフラグメントの最後のバイトが受信されてからフラグメントの受信確認が送信されるまでの時間差。

単位: ミリ秒

160

Page 167: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドCloudWatch を使用したメトリクスのモニタリング

メトリクス 説明

PutMedia.PersistedAckLatency Kinesis ビデオストリーム によって新しいフラグメントの最後のバイトが受信されてからフラグメントの永続性確認が送信されるまでの時間差。

単位: ミリ秒

PutMedia.ErrorAckCount ストリームの PutMedia を実行中に送信されたエラー確認の数。

単位: 個

PutMedia.Success フラグメントが正常に書き込まれるたびに 1。フラグメントが失敗するたびに 0。このメトリクスの平均値は、完全で有効なフラグメントがどれくらい送信されたかを示しています。

単位: 個

GetMedia.Requests 指定されたストリームでの GetMedia API リクエストの数。

単位: 個

GetMedia.OutgoingBytes 特定のストリームで GetMedia API の一部としてサービスから送信されたバイトの合計数。

単位: バイト

GetMedia.OutgoingFragments ストリームの GetMedia を実行中に送信されたフラグメントの数。

単位: 個

GetMedia.OutgoingFrames 指定されたストリームで GetMedia 中に送信されたフレームの数。

単位: 個

GetMedia.MillisBehindNow 現在のサーバータイムスタンプと、最後のフラグメントが送信されたサーバータイムスタンプの時間の差。

単位: ミリ秒

GetMedia.ConnectionErrors 正常に確立されなかった接続の数。

単位: 個

161

Page 168: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドCloudWatch を使用したメトリクスのモニタリング

メトリクス 説明

GetMedia.Success 各フラグメントが正常に送信されると 1、失敗すると0。平均値は成功率を示しています。

Note

失敗には、400(ユーザー)エラーと 500(システム)エラーの両方が含まれます。AWS リクエスト ID など、リクエストとレスポンスの概要を有効にする方法の詳細については、「リクエストおよびレスポンスの概要のログ記録」を参照してください。

単位: カウント

GetMediaForFragmentList.OutgoingBytes特定のストリームで GetMediaForFragmentList APIの一部としてサービスから送信されたバイトの合計数。

単位: バイト

GetMediaForFragmentList.OutgoingFragments特定のストリームで GetMediaForFragmentList APIの一部としてサービスから送信されたフラグメントの合計数。

単位: 個

GetMediaForFragmentList.OutgoingFrames特定のストリームで GetMediaForFragmentList APIの一部としてサービスから送信されたフレームの合計数。

単位: 個

GetMediaForFragmentList.Requests 指定されたストリームでのGetMediaForFragmentList API リクエストの数。

単位: 個

GetMediaForFragmentList.Success 各フラグメントが正常に送信されると 1、失敗すると0。平均値は成功率を示しています。

Note

失敗には、400(ユーザー)エラーと 500(システム)エラーの両方が含まれます。AWS リクエスト ID など、リクエストとレスポンスの概要を有効にする方法の詳細については、「リクエストおよびレスポンスの概要のログ記録」を参照してください。

単位: カウント

ListFragments.Latency 特定のストリーム名の ListFragments API コールのレイテンシー。

単位: ミリ秒

162

Page 169: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドCloudWatch を使用したメトリクスのモニタリング

メトリクス 説明

GetHLSStreamingSessionURL.Latency 特定のストリーム名の GetHLSStreamingSessionURLAPI コールのレイテンシー。

単位: ミリ秒

GetHLSStreamingSessionURL.Requests 指定されたストリームでのGetHLSStreamingSessionURL API リクエストの数。

単位: 個

GetHLSStreamingSessionURL.Success 各リクエストが成功すると 1、失敗すると 0。平均値は成功率を示しています。

Note

失敗には、400(ユーザー)エラーと 500(システム)エラーの両方が含まれます。AWS リクエスト ID など、リクエストとレスポンスの概要を有効にする方法の詳細については、「リクエストおよびレスポンスの概要のログ記録」を参照してください。

単位: カウント

GetHLSMasterPlaylist.Latency 特定のストリーム名の GetHLSMasterPlaylist APIコールのレイテンシー。

単位: ミリ秒

GetHLSMasterPlaylist.Requests 指定されたストリームでの GetHLSMasterPlaylistAPI リクエストの数。

単位: 個

GetHLSMasterPlaylist.Success 各リクエストが成功すると 1、失敗すると 0。平均値は成功率を示しています。

Note

失敗には、400(ユーザー)エラーと 500(システム)エラーの両方が含まれます。AWS リクエスト ID など、リクエストとレスポンスの概要を有効にする方法の詳細については、「リクエストおよびレスポンスの概要のログ記録」を参照してください。

単位: カウント

GetHLSMediaPlaylist.Latency 特定のストリーム名の GetHLSMediaPlaylist APIコールのレイテンシー。

単位: ミリ秒

GetHLSMediaPlaylist.Requests 指定されたストリームでの GetHLSMediaPlaylistAPI リクエストの数。

単位: 個

163

Page 170: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドCloudWatch を使用したメトリクスのモニタリング

メトリクス 説明

GetHLSMediaPlaylist.Success 各リクエストが成功すると 1、失敗すると 0。平均値は成功率を示しています。

Note

失敗には、400(ユーザー)エラーと 500(システム)エラーの両方が含まれます。AWS リクエスト ID など、リクエストとレスポンスの概要を有効にする方法の詳細については、「リクエストおよびレスポンスの概要のログ記録」を参照してください。

単位: カウント

GetMP4InitFragment.Latency 特定のストリーム名の GetMP4InitFragment API コールのレイテンシー。

単位: ミリ秒

GetMP4InitFragment.Requests 指定されたストリームでの GetMP4InitFragment APIリクエストの数。

単位: 個

GetMP4InitFragment.Success 各リクエストが成功すると 1、失敗すると 0。平均値は成功率を示しています。

Note

失敗には、400(ユーザー)エラーと 500(システム)エラーの両方が含まれます。AWS リクエスト ID など、リクエストとレスポンスの概要を有効にする方法の詳細については、「リクエストおよびレスポンスの概要のログ記録」を参照してください。

単位: カウント

GetMP4MediaFragment.Latency 特定のストリーム名の GetMP4MediaFragment APIコールのレイテンシー。

単位: ミリ秒

GetMP4MediaFragment.Requests 指定されたストリームでの GetMP4MediaFragmentAPI リクエストの数。

単位: 個

164

Page 171: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドCloudWatch を使用したメトリクスのモニタリング

メトリクス 説明

GetMP4MediaFragment.Success 各リクエストが成功すると 1、失敗すると 0。平均値は成功率を示しています。

Note

失敗には、400(ユーザー)エラーと 500(システム)エラーの両方が含まれます。AWS リクエスト ID など、リクエストとレスポンスの概要を有効にする方法の詳細については、「リクエストおよびレスポンスの概要のログ記録」を参照してください。

単位: カウント

GetMP4MediaFragment.OutgoingBytes 特定のストリームで GetMP4MediaFragment API の一部としてサービスから送信されたバイトの合計数。

単位: バイト

GetTSFragment.Latency 特定のストリーム名の GetTSFragment API コールのレイテンシー。

単位: ミリ秒

GetTSFragment.Requests 指定されたストリームでの GetTSFragment API リクエストの数。

単位: 個

GetTSFragment.Success 各リクエストが成功すると 1、失敗すると 0。平均値は成功率を示しています。

Note

失敗には、400(ユーザー)エラーと 500(システム)エラーの両方が含まれます。AWS リクエスト ID など、リクエストとレスポンスの概要を有効にする方法の詳細については、「リクエストおよびレスポンスの概要のログ記録」を参照してください。

単位: カウント

GetTSFragment.OutgoingBytes 特定のストリームで GetTSFragment API の一部としてサービスから送信されたバイトの合計数。

単位: バイト

GetDASHStreamingSessionURL.Latency 特定のストリーム名のGetDASHStreamingSessionURL API コールのレイテンシー。

単位: ミリ秒

165

Page 172: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドCloudWatch を使用したメトリクスのモニタリング

メトリクス 説明

GetDASHStreamingSessionURL.Requests指定されたストリームでのGetDASHStreamingSessionURL API リクエストの数。

単位: 個

GetDASHStreamingSessionURL.Success 各リクエストが成功すると 1、失敗すると 0。平均値は成功率を示しています。

Note

失敗には、400(ユーザー)エラーと 500(システム)エラーの両方が含まれます。AWS リクエスト ID など、リクエストとレスポンスの概要を有効にする方法の詳細については、「リクエストおよびレスポンスの概要のログ記録」を参照してください。

単位: カウント

GetDASHManifest.Latency 特定のストリーム名の GetDASHManifest API コールのレイテンシー。

単位: ミリ秒

GetDASHManifest.Requests 指定されたストリームでの GetDASHManifest API リクエストの数。

単位: 個

GetDASHManifest.Success 各リクエストが成功すると 1、失敗すると 0。平均値は成功率を示しています。

Note

失敗には、400(ユーザー)エラーと 500(システム)エラーの両方が含まれます。AWS リクエスト ID など、リクエストとレスポンスの概要を有効にする方法の詳細については、「リクエストおよびレスポンスの概要のログ記録」を参照してください。

単位: カウント

GetClip.Latency 特定のビデオストリーム名の GetClip API コールのレイテンシー。

単位: ミリ秒

GetClip.Requests 特定のビデオストリームの GetClip API リクエストの数。

単位: Count

166

Page 173: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドCloudWatch メトリクスのガイダンス

メトリクス 説明

GetClip.Success 各リクエストが成功すると 1、失敗すると 0。平均値は成功率を示しています。

Note

失敗には、400(ユーザー)エラーと 500(システム)エラーの両方が含まれます。AWS リクエスト ID など、リクエストとレスポンスの概要を有効にする方法の詳細については、「リクエストおよびレスポンスの概要のログ記録」を参照してください。

単位: カウント

GetClip.OutgoingBytes 特定のビデオストリームの GetClip API の一部としてサービスから送信された合計バイト数。

単位: バイト

CloudWatch メトリクスのガイダンスCloudWatch メトリクスは、以下の質問に対する回答を見つけるのに役立ちます。

トピック• データは Kinesis ビデオストリーム サービスに到達しているか? (p. 167)• データが Kinesis ビデオストリーム サービスによって正しく取り込まれていないのはなぜです

か? (p. 168)• Kinesis ビデオストリーム サービスからデータの読み込みが、プロデューサーからの送信と同じレート

でないのはなぜですか? (p. 168)• コンソールにビデオが含まれないのはなぜですか? また、ビデオの再生に遅延があるのはなぜです

か? (p. 168)• リアルタイムのデータの読み取りの遅延とは何ですか? また、クライアントがストリームの先頭から

遅延するのはなぜですか? (p. 169)• クライアントは Kinesis ビデオストリーム からデータを読み取っていますか? また、そのレートはど

れだけですか? (p. 169)• クライアントが Kinesis ビデオストリーム からデータを読み取ることはできないのはなぜです

か? (p. 169)

データは Kinesis ビデオストリーム サービスに到達しているか?関連するメトリクス:

• PutMedia.IncomingBytes

• PutMedia.IncomingFragments

• PutMedia.IncomingFrames

アクション項目:

• これらのメトリクスの低下があった場合は、アプリケーションがまだサービスにデータを送信しているかどうか確認します。

167

Page 174: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドCloudWatch メトリクスのガイダンス

• ネットワーク帯域幅を確認します。ネットワーク帯域幅が不十分な場合は、それが原因でサービスがデータを受信するレートが低下している可能性があります。

データが Kinesis ビデオストリーム サービスによって正しく取り込まれていないのはなぜですか?関連するメトリクス:

• PutMedia.Requests

• PutMedia.ConnectionErrors

• PutMedia.Success

• PutMedia.ErrorAckCount

アクション項目:

• PutMedia.ConnectionErrors の増加があった場合は、プロデューサークライアントによって受信された HTTP 応答/エラーコードを表示して、接続の確立中に発生したエラーを確認します。

• PutMedia.Success の低下または PutMedia.ErrorAckCount の増加があった場合は、サービスによって送信された ack 応答の ack エラーコードを表示して、データの取り込みが失敗している理由を確認します。詳細については、「AckErrorCode.Values」を参照してください。

Kinesis ビデオストリーム サービスからデータの読み込みが、プロデューサーからの送信と同じレートでないのはなぜですか?関連するメトリクス:

• PutMedia.FragmentIngestionLatency

• PutMedia.IncomingBytes

アクション項目:

• これらのメトリクスに低下があった場合は、接続のネットワーク帯域幅を確認します。低帯域幅接続により、データはより低いレートでサービスに到達する可能性があります。

コンソールにビデオが含まれないのはなぜですか? また、ビデオの再生に遅延があるのはなぜですか?関連するメトリクス:

• PutMedia.FragmentIngestionLatency

• PutMedia.FragmentPersistLatency

• PutMedia.Success

• ListFragments.Latency

• PutMedia.IncomingFragments

アクション項目:

• PutMedia.FragmentIngestionLatency の増加または PutMedia.IncomingFragments の低下があった場合は、ネットワーク帯域幅と、データがまだ送信されているかどうかを確認します。

168

Page 175: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドCloudWatch メトリクスのガイダンス

• PutMedia.Success の低下があった場合は、ack エラーコードを確認します。詳細については、「AckErrorCode.Values」を参照してください。

• PutMedia.FragmentPersistLatency または ListFragments.Latency の増加があった場合は、高い確率でサービスの問題が発生しています。長時間にわたり状況が持続する場合は、カスタマーサービスに連絡し、サービスに問題があるかどうかを確認してください。

リアルタイムのデータの読み取りの遅延とは何ですか? また、クライアントがストリームの先頭から遅延するのはなぜですか?関連するメトリクス:

• GetMedia.MillisBehindNow

• GetMedia.ConnectionErrors

• GetMedia.Success

アクション項目:

• GetMedia.ConnectionErrors の増加があった場合は、ストリームへの再接続の頻繁な試行により、コンシューマーによるストリームの読み取りに後れが生じている可能性があります。GetMedia リクエストに対して返される HTTP レスポンス/エラーコードを確認します。

• GetMedia.Success の低下があった場合は、サービスがコンシューマーにデータを送信することができないことが原因である可能性があります。その場合、接続が切断され、コンシューマーから再接続されます。それにより、コンシューマーはストリームの先頭から遅延します。

• GetMedia.MillisBehindNow の増加があった場合は、帯域幅制限を表示し、帯域幅が低くなっているためにデータの受信が低速になっているかどうか確認します。

クライアントは Kinesis ビデオストリーム からデータを読み取っていますか? また、そのレートはどれだけですか?関連するメトリクス:

• GetMedia.OutgoingBytes

• GetMedia.OutgoingFragments

• GetMedia.OutgoingFrames

• GetMediaForFragmentList.OutgoingBytes

• GetMediaForFragmentList.OutgoingFragments

• GetMediaForFragmentList.OutgoingFrames

アクション項目:

• これらのメトリクスは、リアルタイムのアーカイブされたデータが読み取られているレートを示します。

クライアントが Kinesis ビデオストリーム からデータを読み取ることはできないのはなぜですか?関連するメトリクス:

• GetMedia.ConnectionErrors

169

Page 176: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドCloudTrail を使用した API コールのログ作成

• GetMedia.Success

• GetMediaForFragmentList.Success

• PutMedia.IncomingBytes

アクション項目:

• GetMedia.ConnectionErrors の増加があった場合は、GetMedia リクエストによって返されるHTTP 応答/エラーコードを確認します。詳細については、「AckErrorCode.Values」を参照してください。

• 最新/ライブデータの読み取りを試みている場合は、PutMedia.IncomingBytes を確認して、サービスがコンシューマーに送信するストリームにデータが入ってきているかどうかを調べます。

• GetMedia.Success または GetMediaForFragmentList.Success の低下があった場合は、サービスがコンシューマーにデータを送信できないことが原因である可能性があります。長時間にわたり状況が持続する場合は、カスタマーサービスに連絡し、サービスに問題があるかどうかを確認してください。

AWS CloudTrail を使用した Kinesis ビデオストリーム API コールのログ記録

Amazon Kinesis ビデオストリーム は、ユーザー、ロール、または Amazon Kinesis ビデオストリームの AWS サービスによって実行されるアクションを記録するサービス AWS CloudTrail と統合されています。CloudTrail では、イベントとして Amazon Kinesis ビデオストリーム に対するすべての API コールをキャプチャします。キャプチャされた呼び出しには、Amazon Kinesis ビデオストリーム コンソールの呼び出しと、Amazon Kinesis ビデオストリーム API オペレーションへのコード呼び出しが含まれます。証跡を作成する場合は、Amazon Kinesis ビデオストリーム のイベントなど、Amazon S3 バケットへのCloudTrail イベントの継続的な配信を有効にすることができます。証跡を設定しない場合でも、CloudTrailコンソールの [Event history (イベント履歴)] で最新のイベントを表示できます。CloudTrail によって収集された情報を使用して、リクエストの作成元の IP アドレス、リクエストの実行者、リクエストの実行日時などの詳細を調べて、Amazon Kinesis ビデオストリーム に対してどのようなリクエストが行われたかを判断できます。

CloudTrail の詳細(設定して有効にする方法など)については、『AWS CloudTrail User Guide』を参照してください。

Kinesis ビデオストリーム および CloudTrailCloudTrail は、アカウント作成時に AWS アカウントで有効になります。Amazon Kinesis ビデオストリーム でサポートされるイベントアクティビティが発生すると、そのアクティビティは CloudTrail イベントとして AWS のサービスの他のイベントと共に [Event history (イベント履歴)] に記録されます。最近のイベントは、AWS アカウントで表示、検索、ダウンロードできます。詳細については、「CloudTrail イベント履歴でのイベントの表示」を参照してください。

Amazon Kinesis ビデオストリームのイベントなど、AWS アカウントのイベントの継続的な記録については、証跡を作成します。証跡により、CloudTrail はログファイルを Amazon S3 バケットに配信できます。デフォルトでは、コンソールで作成した証跡がすべての AWS リージョンに適用されます。証跡では、AWS パーティションのすべてのリージョンからのイベントがログに記録され、指定した Amazon S3バケットにログファイルが配信されます。さらに、より詳細な分析と AWS ログで収集されたデータに基づいた行動のためにその他の CloudTrail サービスを設定できます。詳細については、以下を参照してください。

• 証跡を作成するための概要• CloudTrail でサポートされるサービスと統合

170

Page 177: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイド例: Amazon Kinesis ビデオス

トリーム ログファイルエントリ

• CloudTrail の Amazon SNS 通知の設定• 「複数のリージョンから CloudTrail ログファイルを受け取る」と「複数のアカウントから CloudTrail ロ

グファイルを受け取る」

Amazon Kinesis ビデオストリーム は CloudTrail ログファイルのイベントとして以下のアクションを記録します。

• CreateStream• DeleteStream• DescribeStream• GetDataEndpoint• ListStreams• ListTagsForStream• TagStream• UntagStream• UpdateDataRetention• UpdateStream

各イベントまたはログエントリには、リクエストの生成者に関する情報が含まれます。この ID 情報は以下のことを確認するのに役立ちます。

• リクエストが、ルートまたは AWS Identity and Access Management (IAM) ユーザー認証情報のどちらを使用して送信されたかどうか。

• リクエストが、ロールとフェデレーティッドユーザーのどちらの一時的なセキュリティ認証情報を使用して送信されたか.

• リクエストが、別の AWS サービスによって送信されたかどうか。

詳細については、「CloudTrail userIdentity 要素」を参照してください。

例: Amazon Kinesis ビデオストリーム ログファイルエントリ証跡は、指定した Amazon S3 バケットにイベントをログファイルとして配信できる設定です。CloudTrailログファイルには、1 つ以上のログエントリが含まれます。イベントは任意の送信元からの単一のリクエストを表し、リクエストされたアクション、アクションの日時、リクエストのパラメータなどに関する情報が含まれます。CloudTrail ログファイルは、パブリック API コールの順序付けられたスタックトレースではないため、特定の順序では表示されません。

次の例は、CreateStream アクションを示す CloudTrail ログエントリです。

{ "Records": [ { "eventVersion": "1.05", "userIdentity": { "type": "IAMUser", "principalId": "EX_PRINCIPAL_ID", "arn": "arn:aws:iam::123456789012:user/Alice", "accountId": "123456789012", "accessKeyId": "EXAMPLE_KEY_ID", "userName": "Alice" },

171

Page 178: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイド例: Amazon Kinesis ビデオス

トリーム ログファイルエントリ

"eventTime": "2018-05-25T00:16:31Z", "eventSource": " kinesisvideo.amazonaws.com", "eventName": "CreateStream", "awsRegion": "us-east-1", "sourceIPAddress": "127.0.0.1", "userAgent": "aws-sdk-java/unknown-version Linux/x.xx", "requestParameters": { "streamName": "VideoStream", "dataRetentionInHours": 2, "mediaType": "mediaType", "kmsKeyId": "arn:aws:kms::us-east-1:123456789012:alias", "deviceName": "my-device" }, "responseElements": { "streamARN":arn:aws:kinesisvideo:us-east-1:123456789012:stream/VideoStream/12345" }, "requestID": "db6c59f8-c757-11e3-bc3b-57923b443c1c", "eventID": "b7acfcd0-6ca9-4ee1-a3d7-c4e8d420d99b" }, { "eventVersion": "1.05", "userIdentity": { "type": "IAMUser", "principalId": "EX_PRINCIPAL_ID", "arn": "arn:aws:iam::123456789012:user/Alice", "accountId": "123456789012", "accessKeyId": "EXAMPLE_KEY_ID", "userName": "Alice" }, "eventTime": "2018-05-25:17:06Z", "eventSource": " kinesisvideo.amazonaws.com", "eventName": "DeleteStream", "awsRegion": "us-east-1", "sourceIPAddress": "127.0.0.1", "userAgent": "aws-sdk-java/unknown-version Linux/x.xx", "requestParameters": { "streamARN": "arn:aws:kinesisvideo:us-east-1:012345678910:stream/VideoStream/12345", "currentVersion": "keqrjeqkj9" }, "responseElements": null, "requestID": "f0944d86-c757-11e3-b4ae-25654b1d3136", "eventID": "0b2f1396-88af-4561-b16f-398f8eaea596" }, { "eventVersion": "1.05", "userIdentity": { "type": "IAMUser", "principalId": "EX_PRINCIPAL_ID", "arn": "arn:aws:iam::123456789012:user/Alice", "accountId": "123456789012", "accessKeyId": "EXAMPLE_KEY_ID", "userName": "Alice" }, "eventTime": "2014-04-19T00:15:02Z", "eventSource": " kinesisvideo.amazonaws.com", "eventName": "DescribeStream", "awsRegion": "us-east-1", "sourceIPAddress": "127.0.0.1", "userAgent": "aws-sdk-java/unknown-version Linux/x.xx", "requestParameters": { "streamName": "VideoStream" }, "responseElements": null, "requestID": "a68541ca-c757-11e3-901b-cbcfe5b3677a", "eventID": "22a5fb8f-4e61-4bee-a8ad-3b72046b4c4d"

172

Page 179: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイド例: Amazon Kinesis ビデオス

トリーム ログファイルエントリ

}, { "eventVersion": "1.05", "userIdentity": { "type": "IAMUser", "principalId": "EX_PRINCIPAL_ID", "arn": "arn:aws:iam::123456789012:user/Alice", "accountId": "123456789012", "accessKeyId": "EXAMPLE_KEY_ID", "userName": "Alice" }, "eventTime": "2014-04-19T00:15:03Z", "eventSource": "kinesisvideo.amazonaws.com", "eventName": "GetDataEndpoint", "awsRegion": "us-east-1", "sourceIPAddress": "127.0.0.1", "userAgent": "aws-sdk-java/unknown-version Linux/x.xx", "requestParameters": { "streamName": "VideoStream", "aPIName": "LIST_FRAGMENTS"" }, "responseElements": null, "requestID": "a6e6e9cd-c757-11e3-901b-cbcfe5b3677a", "eventID": "dcd2126f-c8d2-4186-b32a-192dd48d7e33" }, { "eventVersion": "1.05", "userIdentity": { "type": "IAMUser", "principalId": "EX_PRINCIPAL_ID", "arn": "arn:aws:iam::123456789012:user/Alice", "accountId": "123456789012", "accessKeyId": "EXAMPLE_KEY_ID", "userName": "Alice" }, "eventTime": "2018-05-25T00:16:56Z", "eventSource": "kinesisvideo.amazonaws.com", "eventName": "ListStreams", "awsRegion": "us-east-1", "sourceIPAddress": "127.0.0.1", "userAgent": "aws-sdk-java/unknown-version Linux/x.xx", "requestParameters": { "maxResults": 100, "streamNameCondition": {"comparisonValue":"MyVideoStream" comparisonOperator":"BEGINS_WITH"}} }, "responseElements": null, "requestID": "e9f9c8eb-c757-11e3-bf1d-6948db3cd570", "eventID": "77cf0d06-ce90-42da-9576-71986fec411f" } ]}

173

Page 180: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドコントロールプレーン API の制限

Kinesis ビデオストリーム の制限Kinesis ビデオストリーム には以下の制限があります。

以下の制限は、サポートチケットを送信することでアップグレードできるソフト [s]、または増やすことができないハード [h] のいずれかです。

コントロールプレーン API の制限次のセクションでは、コントロールプレーン API の制限を示します。

アカウントレベルのリクエスト制限に到達すると、ClientLimitExceededException がスローされます。

アカウントレベルのストリーム制限、またはストリームレベルの制限に達すると、StreamLimitExceededException がスローされます。

コントロールプレーン API の制限

API アカウントの制限: リクエスト

アカウントの制限: ストリーム

ストリームレベルの制限

関連する例外と注意

CreateStream 50 TPS [s] 米国東部(バージニア北部)および米国西部(オレゴン)リージョンでは、アカウントあたり 2500 ストリーム。その他すべてのサポートされているリージョンでは、アカウントあたり 1000 ストリーム。

Note

この制限は、アカウントあたり100,000ストリーム(またはそれ以上)まで増やすことができます。AWS

  デバイス、CLI、SDK 駆動型のアクセス、およびコンソールは、すべてこの API を呼び出します。ストリームが既に存在しない場合、1 つの API コールのみが成功します。

174

Page 181: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドコントロールプレーン API の制限

API アカウントの制限: リクエスト

アカウントの制限: ストリーム

ストリームレベルの制限

関連する例外と注意

マネジメントコンソール(https://console.aws.amazon.com/) にサインインし、KinesisVideoStreamsのサービス制限の引き上げケースを送信してこの制限の引き上げをリクエストします。

DescribeStream 300 TPS [h] 該当なし 5 TPS [h]  

UpdateStream 50 TPS [h] 該当なし 5 TPS [h]  

ListStreams 50 TPS [h] 該当なし    

DeleteStream 50 TPS [h] 該当なし 5 TPS [h]  

GetDataEndpoint 300 TPS [h] 該当なし 5 TPS [h] ほとんどのPutMedia/GetMedia ユースケースでは、ストリーミングトークンを更新するために 45分ごとに呼び出されます。データエンドポイントのキャッシュは、アプリケーションで失敗時に再ロードされる場合、安全です。

UpdateDataRetention50 TPS [h] 該当なし 5 TPS [h]  

TagStream 50 TPS [h] 該当なし 5 TPS [h]  

UntagStream 50 TPS [h] 該当なし 5 TPS [h]  

ListTagsForStream50 TPS [h] 該当なし 5 TPS [h]  

175

Page 182: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドメディアおよびアーカイブ済みメディア API の制限

メディアおよびアーカイブ済みメディア API の制限

次のセクションでは、メディアおよびアーカイブ済みメディア API の制限について説明します。

ストリームレベルの制限を超過すると、StreamLimitExceededException がスローされます。

接続レベルのリクエスト制限に到達すると、ConnectionLimitExceededException がスローされます。

次のエラーまたは ACK は、フラグメントレベルの制限に達したときにスローされます。

• MIN_FRAGMENT_DURATION_REACHED ACK は、最小期間より小さいフラグメントに対して返されます。

• MAX_FRAGMENT_DURATION_REACHED ACK は、最大期間より大きいフラグメントに対して返されます。

• MAX_FRAGMENT_SIZE ACK は、最大データサイズより大きいフラグメントに対して返されます。• GetMediaForFragmentList オペレーションでフラグメントの制限に達した場

合、FragmentLimitExceeded の例外がスローされます。

データプレーンの API の制限

API ストリームレベルの制限

接続レベルの制限

帯域幅制限 フラグメントレベルの制限

関連する例外と注意

PutMedia 5 TPS [h] 1 [s] 12.5 MB/秒、または100 Mbps [s]

• 最小フラグメント継続時間:1 秒 [h]

• 最大フラグメント継続時間:10 秒 [h]

• 最大フラグメントサイズ: 50MB [h]

• トラックの最大数:3 [s]

一般的な PutMedia リクエストには数秒のデータが含まれ、ストリームあたりの TPS は減ります。制限を超える複数の同時接続の場合、最後の接続が受け入れられます。

GetHLSStreamingSessionURL5 TPS バースト、1 TPS持続 [h]

該当なし 該当なし 該当なし ストリームごとに 10 セッションのみ同時にアクティブにすることができます[h]。制限に到達すると、新しいセッションが作成されたときに最も古いセッションが取り消されます。

GetDASHStreamingSessionURL5 TPS バースト、1 TPS持続 [h]

該当なし 該当なし 該当なし ストリームごとに 10 セッションのみ同時にアクティブにすることができます

176

Page 183: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドメディアおよびアーカイブ済みメディア API の制限

API ストリームレベルの制限

接続レベルの制限

帯域幅制限 フラグメントレベルの制限

関連する例外と注意

[h]。制限に到達すると、新しいセッションが作成されたときに最も古いセッションが取り消されます。

GetMedia 5 TPS [h] 3 [s] 25 MB/秒または 200Mbps [s]

該当なし 3 つのクライアントのみが、いつでもメディアストリームからコンテンツを同時に受け取ることができます。それ以上のクライアント接続は拒否されます。一意の消費クライアントは 2または 3 TPS 以上を必要としません。これは、接続の確立後に、アプリケーションが継続的に読み込むことが予期されるためです。

通常のフラグメントが約 5MB である場合、この制限は Kinesis ビデオストリームあたり最大 75 MB/秒を意味します。このようなストリームは、ストリームの最大受信ビットレートの 2 倍の送信ビットレートを持ちます。

ListFragments 5 TPS [h] 該当なし 該当なし 該当なし  

GetMediaForFragmentList5 TPS [h] 5 [s] 25 MB/秒または 200MbpsA [s]

フラグメントの最大数:1000 [h]

5 つのフラグメントベースの消費アプリケーションが同時にメディアを取得できます。それ以上の接続は拒否されます。

GetClip 10 TPS [h] 該当なし 100 MB のサイズ制限 [h]

フラグメントの最大数:200 [h]

この API には、1 秒あたり25 件のトランザクション(TPS) というアカウントレベルの制限があります。

動画再生プロトコル API の制限

API セッションレベルの制限 フラグメントレベルの制限

GetDASHManifestPlaylist 5 TPS [h] プレイリストあたりの最大フラグメント数: 1000 [h]

GetHLSMasterPlaylist 5 TPS [h] 該当なし

GetHLSMediaPlaylist 5 TPS [h] プレイリストあたりの最大フラグメント数: 1000 [h]

GetMP4InitFragment 5 TPS [h] 該当なし

177

Page 184: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドメディアおよびアーカイブ済みメディア API の制限

API セッションレベルの制限 フラグメントレベルの制限

GetMP4MediaFragment 10 TPS [h] 該当なし

GetTSFragment 10 TPS [h] 該当なし

178

Page 185: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイド一般的な問題のトラブルシューティング

Kinesis ビデオストリーム のトラブルシューティング

次の情報を使用して、Amazon Kinesis ビデオストリーム で発生する一般的な問題をトラブルシューティングします。

トピック• 一般的な問題のトラブルシューティング (p. 179)• API の問題のトラブルシューティング (p. 179)• HLS の問題のトラブルシューティング (p. 181)• Java の問題のトラブルシューティング (p. 183)• プロデューサーライブラリの問題のトラブルシューティング (p. 183)• Stream Parser ライブラリの問題のトラブルシューティング (p. 188)

一般的な問題のトラブルシューティングこのセクションでは、Kinesis ビデオストリーム を操作するときに発生する可能性がある一般的な問題について説明します。

問題点• レイテンシーが高すぎる (p. 179)

レイテンシーが高すぎるレイテンシーは、Kinesis ビデオストリーム サービスに送信されるフラグメント継続時間が原因で発生する場合があります。プロデューサーとサービスの間のレイテンシーを減らす方法の 1 つとして、より短いフラグメント継続時間を作成するようにメディアパイプラインを設定します。

各フラグメントに送信されるフレームの数を減らし、各フラグメントの時間を減らすには、kinesis_video_gstreamer_sample_app.cpp の次の値を減らします。

g_object_set(G_OBJECT (data.encoder), "bframes", 0, "key-int-max", 45, "bitrate", 512, NULL);

Note

Mozilla Firefox ブラウザではビデオレンダリングを内部実装しているため、レイテンシーが高くなります。

API の問題のトラブルシューティングこのセクションでは、Kinesis ビデオストリーム を操作するときに発生する可能性がある API の問題について説明します。

179

Page 186: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドエラー:「未知のオプション」

問題点• エラー:「未知のオプション」 (p. 180)• エラー: "承認するサービス/オペレーション名を特定できませんでした" (p. 180)• エラー: "ストリームにフレームを配置できませんでした" (p. 180)• エラー: "最終 AckEvent が受信される前に、サービスによって接続が終了されました" (p. 181)• エラー: 「STATUS_STORE_OUT_OF_MEMORY」 (p. 181)

エラー:「未知のオプション」GetMedia と GetMediaForFragmentList は、次のエラーで失敗する場合があります。

Unknown options: <filename>.mkv

このエラーは、AWS CLI で output タイプを json に設定した場合に発生します。AWS CLI をデフォルトの出力タイプ (none) で再設定します。AWS CLI の設定については、AWS CLI Command Referenceの「設定」を参照してください。

エラー: "承認するサービス/オペレーション名を特定できませんでした"GetMedia は、次のエラーで失敗する場合があります。

Unable to determine service/operation name to be authorized

このエラーが発生する可能性があるのは、エンドポイントが適切に指定されていない場合です。エンドポイントを取得するときに、呼び出す API に応じて、必ず次のパラメータを GetDataEndpoint の呼び出しに含めます。

--api-name GET_MEDIA--api-name PUT_MEDIA--api-name GET_MEDIA_FOR_FRAGMENT_LIST--api-name LIST_FRAGMENTS

エラー: "ストリームにフレームを配置できませんでした"PutMedia は、次のエラーで失敗する場合があります。

Failed to put a frame in the stream

このエラーが発生する可能性があるのは、サービスで接続またはアクセス許可が利用できない場合です。AWS CLI で以下を実行し、ストリーム情報を取得できることを確認します。

aws kinesisvideo describe-stream --stream-name StreamName --endpoint https://ServiceEndpoint.kinesisvideo.region.amazonaws.com

呼び出しが失敗した場合、詳細については「AWS CLI エラーのトラブルシューティング」を参照してください。

180

Page 187: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドエラー: "最終 AckEvent が受信される前に、

サービスによって接続が終了されました"

エラー: "最終 AckEvent が受信される前に、サービスによって接続が終了されました"PutMedia は、次のエラーで失敗する場合があります。

com.amazonaws.SdkClientException: Service closed connection before final AckEvent was received

このエラーが発生する可能性があるのは、PushbackInputStream が不適切に実装されている場合です。unread() メソッドが正しく実装されていることを確認します。

エラー: 「STATUS_STORE_OUT_OF_MEMORY」PutMedia は、次のエラーで失敗する場合があります。

The content store is out of memory.

コンテンツストアに十分なサイズが割り当てられていない場合、このエラーが発生します。コンテンツストアのサイズを増やすには、StorageInfo.storageSize の値を増やします。詳細については、「StorageInfo (p. 109)」を参照してください。

HLS の問題のトラブルシューティングこのセクションでは、Kinesis ビデオストリーム で HTTP Live Streaming (HLS) を使用するときに発生する可能性がある問題について説明します。

問題点• HLS ストリーミングセッション URL の取得は成功するが、ビデオプレーヤーで再生が失敗す

る (p. 181)• プロデューサーとプレーヤー間のレイテンシーが高すぎる (p. 182)

HLS ストリーミングセッション URL の取得は成功するが、ビデオプレーヤーで再生が失敗するこの状況が発生するのは、HLS ストリーミングセッション URL は GetHLSStreamingSessionURL を使用して正常に取得できるが、この URL をビデオプレーヤーに指定したときに動画が再生されない場合です。

この状況のトラブルシューティングを行うには、以下を試します。

• Kinesis ビデオストリーム コンソールで動画ストリームが再生されるかどうかを確認します。コンソールに表示されたエラーを検討します。

• フラグメント継続時間が 1 秒未満の場合は、1 秒に増やします。フラグメント継続時間が短すぎると、動画フラグメントに対するリクエスト回数が多すぎて、サービスでプレーヤーがスロットイングされることがあります。

• 各 HLS ストリーミングセッション URL を 1 つのプレーヤーでのみ使用していることを確認します。1つの HLS ストリーミングセッション URL を複数のプレーヤーで使用している場合、サービスが受け取るリクエストが多すぎて、プレーヤーがスロットリングされることがあります。

181

Page 188: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドプロデューサーとプレーヤー間のレイテンシーが高すぎる

• HLS ストリーミングセッションに指定するすべてのオプションがプレーヤーでサポートされていることを確認します。以下のパラメータでさまざまな値の組み合わせを試します。• ContainerFormat

• PlaybackMode

• FragmentSelectorType

• DiscontinuityMode

• MaxMediaPlaylistFragmentResults

通常、一部のメディアプレーヤー (HTML5 やモバイルプレイヤーなど) は、fMP4 コンテナ形式の HLSのみをサポートします。その他のメディアプレーヤー (Flash やカスタムプレーヤーなど) は MPEG TSコンテナ形式の HLS のみをサポートする場合があります。トラブルシューティングを開始するには、最初に ContainerFormat パラメータを試してみることをお勧めします。

• 各フラグメントに一貫した数のトラックがあることを確認します。ストリーム内のフラグメントが、オーディオおよびビデオトラックの両方がある場合と、ビデオトラックのみがある場合とで変わらないことを確認します。また、エンコーダー設定 (解像度、フレームレートなど) が、各トラックのフラグメント間で変わらないことも確認します。

プロデューサーとプレーヤー間のレイテンシーが高すぎるこの状況が発生するのは、動画をキャプチャした時点から動画プレーヤーで再生した時点までのレイテンシーが高すぎる場合です。

動画は HLS を介してフラグメント単位で再生されます。そのため、レイテンシーをフラグメント継続時間未満にすることはできません。レイテンシーには、データのバッファリングと転送の所要時間も含まれます。ソリューションで 1 秒未満のレイテンシーが必要な場合は、代わりに GetMedia API を使用することを検討してください。

以下のパラメータを調整してレイテンシー全体を短縮できますが、それに伴って画質が低下したり、再バッファリング率が高くなったりする場合があります。

• フラグメント継続時間: フラグメント継続時間は、ストリームの区分間における動画の量であり、動画エンコーダーで生成されるキーフレームの頻度で制御されます。推奨される値は 1 秒です。フラグメント継続時間が短いほど、動画データをサービスに転送する前にフラグメントが完了するまで待機する時間が少なくなります。また、フラグメントが短いほど、サービスでの処理が高速になります。ただし、フラグメント継続時間が短すぎると、プレーヤーでコンテンツが不足するため、停止してコンテンツをバッファリングしなければならない確率が高くなります。フラグメント継続時間が 500 ミリ秒未満の場合、プロデューサーで作成されるリクエストが多すぎて、サービスでスロットリングされることがあります。

• ビットレート: 動画ストリームのビットレートが低いほど、読み取り、書き込み、および転送にかかる時間は短くなります。ただし、通常、動画ストリームのビットレートが低いほど、画質は低下します。

• メディアプレイリストのフラグメント数: レイテンシーの影響を受けやすいプレーヤーは、メディアプレイリストから最新のフラグメントだけをロードします。ほとんどのプレーヤーは、逆に最も古いフラグメントから開始します。プレイリスト内のフラグメント数を減らすことで、古いフラグメントと新しいフラグメントとの分離時間が短縮されます。プレイリストのサイズが小さいほど、プレイリストへの新しいフラグメントの追加が遅れたり、プレーヤーでの更新されたプレイリストの取得が遅れたりした場合に、フラグメントが再生中にスキップされる可能性が高くなります。フラグメント数は 3〜5 個とし、プレイリストから最新のフラグメントのみをロードするように設定したプレーヤーを使用することをお勧めします。

• プレーヤーのバッファサイズ: ほとんどの動画プレーヤーでは最小バッファ期間 (通常はデフォルトの10 秒) を設定できます。最も低いレイテンシーの場合、この値は 0 秒に設定できます。ただし、この場合、フラグメントの生成が遅れると、プレーヤーには遅延を吸収するバッファがないため、プレーヤーは再バッファリングすることになります。

182

Page 189: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドJava の問題のトラブルシューティング

• プレーヤーの「キャッチアップ」: 通常、動画プレーヤーは、バッファが満杯になった場合 (遅延したフラグメントのためにフラグメントのバックログを再生する場合など)、自動的に動画バッファの先頭まで再生をキャッチアップさせることはありません。カスタムプレーヤーでは、これを避けるためにフレームをドロップするか、再生スピードを速くして (1.1 倍など)、バッファの先頭までキャッチアップできます。プレーヤーのキャッチアップに伴って、再生が途切れたり、速度が増したりします。また、バッファサイズが短いと、再バッファリングの回数が増える場合があります。

Java の問題のトラブルシューティングこのセクションでは、Kinesis ビデオストリーム を操作するときに発生する一般的な Java の問題のトラブルシューティング方法について説明します。

問題点• Java ログの有効化 (p. 183)

Java ログの有効化Java サンプルおよびライブラリの問題をトラブルシューティングするには、デバッグログを有効にして確認すると便利です。デバッグログを有効にするには、次の操作を行います。

1. log4j を pom.xml ノードの dependencies ファイルに追加します。

<dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.17</version></dependency>

2. target/classes ディレクトリで、次の内容で log4j.properties というファイルを作成します。

# Root logger optionlog4j.rootLogger=DEBUG, stdout

# Redirect log messages to consolelog4j.appender.stdout=org.apache.log4j.ConsoleAppenderlog4j.appender.stdout.Target=System.outlog4j.appender.stdout.layout=org.apache.log4j.PatternLayoutlog4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n

log4j.logger.org.apache.http.wire=DEBUG

デバッグログが、IDE コンソールに出力されます。

プロデューサーライブラリの問題のトラブルシューティング

このセクションでは、プロデューサーライブラリ (p. 47) を使用するときに発生する可能性がある問題について説明します。

問題点

183

Page 190: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドプロデューサー SDK をコンパイルできない

• プロデューサー SDK をコンパイルできない (p. 184)• ビデオストリームはコンソールには表示されません。 (p. 184)• エラー: GStreamer デモアプリケーションを使用したデータのストリーミング時の "リクエストに含ま

れているセキュリティトークンが無効です" (p. 185)• エラー: 「Kinesis Video クライアントにフレームを送信できませんでした」 (p. 185)• GStreamer アプリケーションが、OS X で "ストリーミングが中止されました。ネゴシエーションされ

ていないという理由です" というメッセージで停止する (p. 185)• エラー: Raspberry Pi の GStreamer デモで Kinesis ビデオクライアントを作成するときの "ヒープを割

り当てできませんでした" (p. 186)• エラー: Raspberry Pi での GStreamer デモの実行時の "無効な命令" (p. 186)• カメラで Raspberry Pi のロードに失敗する (p. 186)• カメラが macOS High Sierra で見つからない (p. 187)• macOS High Sierra でコンパイルするときに、jni.h ファイルが見つかりません (p. 187)• GStreamer デモアプリケーションを実行中の Curl エラー (p. 187)• Raspberry Pi での実行時のタイムスタンプ/範囲アサーション (p. 187)• Raspberry Pi の gst_value_set_fraction_range_full でのアサーション (p. 187)• Android での STATUS_MKV_INVALID_ANNEXB_NALU_IN_FRAME_DATA(0x3200000d) エ

ラー (p. 187)• 最大フラグメント継続時間に達しました (p. 188)• IoT 認証の使用中に "無効なモノの名前が渡されました (Invalid thing name passed)" エラーが発

生 (p. 188)

プロデューサー SDK をコンパイルできないパスに必要なライブラリがあることを確認します。これを確認するには、次のコマンドを使用します。

$ env | grep LD_LIBRARY_PATHLD_LIBRARY_PATH=/home/local/awslabs/amazon-kinesis-video-streams-producer-sdk-cpp/kinesis-video-native-build/downloads/local/lib

ビデオストリームはコンソールには表示されません。コンソールで動画ストリームを表示するには、H.264 を使用して AvCC 形式でエンコードする必要があります。ストリームが表示されない場合は、以下の点を確認してください。

• 元のストリームが Annex-B 形式である場合、NAL 適応フラグ (p. 108) がNAL_ADAPTATION_ANNEXB_NALS | NAL_ADAPTATION_ANNEXB_CPD_NALS に設定されている。これは StreamDefinition コンストラクタのデフォルト値です。

• コーデックのプライベートデータを正しく提供しています。H.264 では、これはシーケンスパラメータセット (SPS) とピクチャパラメータセット (PPS) です。メディアソースに応じて、このデータはメディアソースから個別に取得されるか、フレームにエンコードされています。

多くの基本ストリームの形式は次のとおりです。ここで、Ab は Annex-B の開始コード (001 または0001) です。

Ab(Sps)Ab(Pps)Ab(I-frame)Ab(P/B-frame) Ab(P/B-frame)…. Ab(Sps)Ab(Pps)Ab(I-frame)Ab(P/B-frame) Ab(P/B-frame)

CPD (Codec Private Data) は、H.264 ではストリーム内の SPS および PPS であり、AvCC 形式に適応させることができます。メディアパイプラインから個別に CPD が提供される場合を除き、アプリケー

184

Page 191: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドエラー: GStreamer デモアプリケーションを使用したデータのストリーミング時の "リクエストに含まれているセキュリティトークンが無効です"

ションは最初の Idr フレーム (SPS/PPS が含まれている) を探してフレームから CPD を抽出し、2 つのNALU [Ab(Sps)Ab(Pps)] を抽出して StreamDefinition で CPD に設定できます。

エラー: GStreamer デモアプリケーションを使用したデータのストリーミング時の "リクエストに含まれているセキュリティトークンが無効です"このエラーが発生した場合は、認証情報に問題があります。以下について確認してください。

• 一時的なセキュリティ認証情報を使用している場合は、セッショントークンを指定する必要があります。

• 一時的な認証情報が失効していないことを確認します。• 適切な権限が設定されていることを確認します。• macOS では、Keychain にキャッシュされた認証情報がないことを確認します。

エラー: 「Kinesis Video クライアントにフレームを送信できませんでした」このエラーが発生した場合、タイムスタンプはソースストリームに正しく設定されません。次の操作を試してください。

• この問題を解決する最新の SDK サンプルを使用してください。• 高品質のストリームをより高いビットレートに設定し、カメラがソースストリーム内のジッタをサポー

トする場合は、そのジッタを修正します。

GStreamer アプリケーションが、OS X で "ストリーミングが中止されました。ネゴシエーションされていないという理由です" というメッセージで停止するOS X では、ストリーミングが停止し、次のメッセージが表示される場合があります。

Debugging information: gstbasesrc.c(2939): void gst_base_src_loop(GstPad *) (): /GstPipeline:test-pipeline/GstAutoVideoSrc:source/GstAVFVideoSrc:source-actual-src-avfvide:streaming stopped, reason not-negotiated (-4)

この回避策として、kinesis_video_gstreamer_sample_app.cpp で gst_caps_new_simple の呼び出しからフレームレートパラメータを削除します。

GstCaps *h264_caps = gst_caps_new_simple("video/x-h264", "profile", G_TYPE_STRING, "baseline", "stream-format", G_TYPE_STRING, "avc", "alignment", G_TYPE_STRING, "au", "width", GST_TYPE_INT_RANGE, 320, 1920, "height", GST_TYPE_INT_RANGE, 240, 1080, "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, 30, 1, NULL);

185

Page 192: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドエラー: Raspberry Pi の GStreamer デモ

で Kinesis ビデオクライアントを作成するときの "ヒープを割り当てできませんでした"

エラー: Raspberry Pi の GStreamer デモで Kinesis ビデオクライアントを作成するときの "ヒープを割り当てできませんでした"GStreamer サンプルアプリケーションは、512 MB の RAM を割り当てようとしますが、これがシステムで使用できない場合があります。KinesisVideoProducer.cpp で次の値を減らすことによって、この割り当てを減らすことができます。

device_info.storageInfo.storageSize = 512 * 1024 * 1024;

エラー: Raspberry Pi での GStreamer デモの実行時の"無効な命令"GStreamer デモを実行するときに、次のエラーが発生した場合は、正しいバージョンのデバイスに対してアプリケーションをコンパイルしたことを確認します(たとえば、Raspberry Pi 2 で実行しているときに、Raspberry Pi 3 に対してコンパイルしていないことを確認します)。

INFO - Initializing curl.Illegal instruction

カメラで Raspberry Pi のロードに失敗するカメラがロード済みかどうか確認するには、次のコマンドを実行します。

$ ls /dev/video*

何も見つからない場合は、次のコマンドを実行します。

$ vcgencmd get_camera

出力は次の例のようになります:

supported=1 detected=1

ドライバでカメラが検出されない場合は、次のコマンドを実行します。

1. 物理的なカメラの設定を確認し、適切に接続されていることを確認します。2. 以下を実行してファームウェアをアップグレードします。

$ sudo rpi-update

3. デバイスを再起動します。4. 以下を実行してドライバをロードします。

$ sudo modprobe bcm2835-v4l2

5. カメラが検出されたことを確認します。

$ ls /dev/video*

186

Page 193: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドカメラが macOS High Sierra で見つからない

カメラが macOS High Sierra で見つからないmacOS High Sierra で複数のカメラが利用できる場合、デモアプリケーションはカメラを見つけることができません。

macOS High Sierra でコンパイルするときに、jni.hファイルが見つかりませんこのエラーを解決するには、Xcode のインストールを最新バージョンに更新してください。

GStreamer デモアプリケーションを実行中の Curl エラーエラーを解決するには、GStreamer デモアプリケーションを実行するとき、この証明書ファイルを /etc/ssl/cert.pem にコピーします。

Raspberry Pi での実行時のタイムスタンプ/範囲アサーション実行時にタイムスタンプの範囲アサーションが発生した場合は、ファームウェアを更新し、デバイスを再起動します。

$ sudo rpi-update $ sudo reboot

Raspberry Pi の gst_value_set_fraction_range_full でのアサーションuv4l サービスが実行中の場合は、次のアサーションが表示されます。

gst_util_fraction_compare (numerator_start, denominator_start, numerator_end, denominator_end) < 0' failed

これが発生した場合は、uv4l サービスを停止し、アプリケーションを再起動します。

Android でのSTATUS_MKV_INVALID_ANNEXB_NALU_IN_FRAME_DATA(0x3200000d)エラーメディア・ストリームの NAL 適応フラグ (p. 108) が間違っている場合、次のエラーが表示されます。

putKinesisVideoFrame(): Failed to put a frame with status code 0x3200000d

このエラーが発生した場合は、メディアの .withNalAdaptationFlags フラグを正しく入力します (例 :NAL_ADAPTATION_ANNEXB_CPD_NALS)。このフラグを Android プロデューサーライブラリ (p. 52) の次の行に入力します。

187

Page 194: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイド最大フラグメント継続時間に達しました

https://github.com/awslabs/aws-sdk-android-samples/blob/master/AmazonKinesisVideoDemoApp/src/main/java/com/amazonaws/kinesisvideo/demoapp/fragment/StreamConfigurationFragment.java#L169

最大フラグメント継続時間に達しましたこのエラーは、ストリーム内のメディアフラグメントが最大フラグメント継続期間の制限を超えると発生します。デフォルトでは、Kinesis Video Streams のストリームの最大フラグメント期間は 10 秒に設定されています。

この問題を解決するには、以下の手順を実行します。

• ウェブカメラ/USB カメラを使用している場合は、次のいずれかの操作を行います。• キーフレームベースのフラグメンテーションを使用している場合は、10 秒以内にキーフレームを提供

するようにエンコーダを設定します。• キーフレームベースのフラグメンテーションを使用していない場合は、ステップ 2: コードを作成して

テストする (p. 61) でストリームを定義するときに、最大フラグメント期間の制限を 10 秒未満の値に設定します。

• GStreamer パイプラインでソフトウェアエンコーダ (x264 など) を使用している場合は、key-int-max属性を 10 秒以内の値に設定できます (たとえば、fps を 30 に設定してkey-int-max を 60 に設定し、キーフレームを 2 秒ごとに有効にします)。

• RPI カメラを使用している場合は、keyframe-interval 属性を 10 秒未満に設定してください。• IP (RTSP) カメラを使用している場合は、GOP サイズを 60 に設定してください。

IoT 認証の使用中に "無効なモノの名前が渡されました (Invalid thing name passed)" エラーが発生認証に IoT 認証情報を使用している場合にこのエラー (HTTP Error 403: Response:{"message":"Invalid thing name passed"}) を回避するには、stream-name の値 (kvssink 要素の必須パラメータ) を iot-thingname の値と同一にしてください。詳細については、GStreamer エレメントパラメータのリファレンス (p. 143)を参照してください。

Stream Parser ライブラリの問題のトラブルシューティング

このセクションでは、ストリームパーサーライブラリ (p. 128) を使用するときに発生する可能性がある問題について説明します。

問題点• ストリームから 1 つのフレームにアクセスできない (p. 188)• フラグメントのデコードエラー (p. 189)

ストリームから 1 つのフレームにアクセスできないコンシューマーアプリケーションでストリーミングソースから 1 つのフレームにアクセスするには、ストリームに正しいコーデックプライベートデータが含まれていることを確認する必要があります。ストリームのデータの形式の詳細については、「データモデル (p. 18)」を参照してください。

コーデックプライベートデータを使用してフレームにアクセスする方法については、GitHub ウェブサイトで KinesisVideoRendererExampleTest.java テストファイルを参照してください。

188

Page 195: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドフラグメントのデコードエラー

フラグメントのデコードエラーフラグメントが H.264 フォーマットで適切にエンコードされておらず、ブラウザがサポートしているレベルである場合、コンソールでストリームを再生するときに次のエラーが表示されることがあります。

Fragment Decoding ErrorThere was an error decoding the video data. Verify that the stream contains valid H.264 content

このような場合は、次の点を確認してください。

• フレームの解像度が、コーデックのプライベートデータで指定された解像度に一致している。• エンコードされたフレームの H.264 プロファイルとレベルが、コーデックのプライベートデータで指定

されたプロファイルとレベルに一致している。• ブラウザがプロファイル/レベルの組み合わせをサポートしている。現在のほとんどのブラウザは、すべ

てのプロファイルとレベルの組み合わせをサポートしています。• タイムスタンプは正確で正しい順序であり、重複するタイムスタンプは作成されない。• お使いのアプリケーションが H.264 形式を使用してフレームデータをエンコードしている。

189

Page 196: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイド

Amazon Kinesis Video Streams のドキュメント履歴

次の表に、Amazon Kinesis ビデオストリーム の前回のリリース以後に行われた、文書の重要な変更を示します。

• 最新の API バージョン: 2017 年 11 月 29 日• ドキュメント最新更新日: 2019 年 1 月 21 日

変更 説明 日付

開始方法: Kinesis ビデオストリーム にデータを送信する

カメラから Kinesis ビデオストリーム にメディアを送信するための基本チュートリアル詳細については、「ステップ 3: Kinesisビデオストリームにデータを送信する (p. 26)」を参照してください。

2019 年 1 月 21 日

Amazon SageMaker と統合するためのライブラリテンプレート

特定のオブジェクトが AmazonKinesis ビデオストリームに表示されるタイミングを AmazonSageMaker により識別する、Kinesis ビデオストリームのサンプルアプリケーション。詳細については、「AmazonSageMaker (p. 153)」を参照してください。

2018 年 11 月 19 日

ストリーミングメタデータ プロデューサー SDK は Kinesisビデオストリーム でのメタデータの埋め込みに使用できます。詳細については、「Kinesis ビデオストリーム を持つストリーミングメタデータの使用 (p. 15)」を参照してください。

2018 年 9 月 28 日

Windows 用 C++ プロデューサーSDK

C++ プロデューサー SDK は、現在、Microsoft Windows で利用できます。詳細については、「Windows で C++ プロデューサー SDK を使用する (p. 67)」を参照してください。

2018 年 8 月 30 日

C++ プロデューサー SDK ログ記録

C++ プロデューサー SDK アプリケーションのログ記録を設定できます。詳細については、「C++ プロデューサー SDK でのログ記録の使用 (p. 75)」を参照してください。

2018 年 7 月 18 日

190

Page 197: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイド

変更 説明 日付

HLS 動画ストリーミング HTTP ライブストリーミングを使用して Kinesis ビデオストリーム を表示できるようになりました。詳細については、「Kinesisビデオストリーム 再生 (p. 9)」を参照してください。

2018 年 7 月 13 日

RTSP ソースからのストリーミング

Docker コンテナ内で実行され RTSP ソースからビデオをストリーミングする Kinesisビデオストリーム 用のサンプルアプリケーション。詳細については、「RTSP およびDocker (p. 149)」を参照してください。

2018 年 20 月 6 日

C++ プロデューサー SDKGStreamer プラグイン

C++ プロデューサーライブラリ (p. 57) を GStreamer 送信先として使用する構築方法を示します。詳細については、「GStreamer (p. 137)」を参照してください。

2018 年 15 月 6 日

プロデューサー SDK コールバックのリファレンスドキュメント

Kinesis ビデオストリーム プロデューサーライブラリ (p. 47)で使用されるコールバックのリファレンスドキュメント。詳細については、「プロデューサーSDK コールバック (p. 122)」を参照してください。

2018 年 12 月 6 日

システム要件 プロデューサーデバイスと SDKのメモリ要件およびストレージ要件のドキュメントです。詳細については、「Kinesis ビデオストリーム システム要件 (p. 3)」を参照してください。

2018 年 5 月 30 日

CloudTrail のサポート CloudTrail を使用して API の使用状況を監視するためのドキュメントです。詳細については、「AWS CloudTrail を使用したKinesis ビデオストリーム APIコールのログ記録 (p. 170)」を参照してください。

2018 年 5 月 24 日

プロデューサー SDK 構造のリファレンスドキュメント

Kinesis ビデオストリーム プロデューサーライブラリ (p. 47)構造で使用される構造のリファレンスドキュメント。詳細については、「プロデューサーSDK の構造 (p. 109)」および「Kinesis ビデオストリームの構造 (p. 110)」を参照してください。

2018 年 5 月 7 日

191

Page 198: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイド

変更 説明 日付

レンダラーの例に関するドキュメント

レンダラーのアプリケーション例のドキュメントでは、Kinesisビデオストリーム からフレームをデコードして表示する方法を説明します。詳細については、「例: Kinesis ビデオストリームフラグメントの解析およびレンダリング (p. 151)」を参照してください。

2018 年 3 月 15 日

プロデューサー SDK 制限の参照ドキュメント

オペレーションの制限についての情報は、「C++ プロデューサーライブラリ (p. 57)」を参照してください。詳細については、「プロデューサー SDK の制限 (p. 82)」を参照してください。

2018 年 3 月 13 日

Raspberry Pi 用 C++ プロデューサー SDK

Raspberry Pi デバイスで C++ プロデューサーライブラリ (p. 57)を設定して実行する手順です。詳細については、「Raspberry Piで C++ プロデューサー SDK を使用する (p. 69)」を参照してください。

2018 年 3 月 13 日

モニタリング Amazon CloudWatch およびAWS CloudTrail を使用したKinesis ビデオストリーム メトリクスと API コールのモニタリングに関する情報。詳細については、「Kinesis ビデオストリームのモニタリング (p. 159)」を参照してください。

2018 年 2 月 5 日

Network Abstraction Layer (NAL)適応フラグを参照

長時間のストリーミングビデオに NAL 適応フラグを設定するための情報。詳細については、「NAL 適応フラグ (p. 108)」を参照してください。

2018 年 1 月 15 日

ストリーミングビデオの Androidサポート

Kinesis ビデオストリームは、Android デバイスからストリーミングビデオをサポートするようになりました。詳細については、「Android プロデューサーライブラリ (p. 52)」を参照してください。

2018 年 1 月 12 日

192

Page 199: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイド

変更 説明 日付

Kinesis ビデオの例に関するドキュメント

Kinesis ビデオサンプルアプリケーションのドキュメントでは、Kinesis ビデオストリームパーサーライブラリ (p. 128) を使用する方法を示しています。詳細については、「KinesisVideoExample (p. 132)」を参照してください。

2018 年 1 月 9 日

Kinesis ビデオストリーム のドキュメント関連

これは Amazon Kinesis VideoStreams 開発者ガイドの最初の一般リリースです。

2017 年 11 月 29 日

193

Page 200: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドActions

API リファレンスこのセクションには、API リファレンスドキュメントが含まれています。

ActionsThe following actions are supported by Amazon Kinesis Video Streams:

• CreateSignalingChannel (p. 196)• CreateStream (p. 199)• DeleteSignalingChannel (p. 203)• DeleteStream (p. 205)• DescribeSignalingChannel (p. 208)• DescribeStream (p. 211)• GetDataEndpoint (p. 214)• GetSignalingChannelEndpoint (p. 217)• ListSignalingChannels (p. 220)• ListStreams (p. 223)• ListTagsForResource (p. 226)• ListTagsForStream (p. 229)• TagResource (p. 232)• TagStream (p. 234)• UntagResource (p. 237)• UntagStream (p. 239)• UpdateDataRetention (p. 242)• UpdateSignalingChannel (p. 245)• UpdateStream (p. 248)

The following actions are supported by Amazon Kinesis Video Streams Media:

• GetMedia (p. 251)• PutMedia (p. 255)

The following actions are supported by Amazon Kinesis Video Streams Archived Media:

• GetClip (p. 262)• GetDASHStreamingSessionURL (p. 266)• GetHLSStreamingSessionURL (p. 273)• GetMediaForFragmentList (p. 281)• ListFragments (p. 284)

Amazon Kinesis Video StreamsThe following actions are supported by Amazon Kinesis Video Streams:

194

Page 201: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams

• CreateSignalingChannel (p. 196)• CreateStream (p. 199)• DeleteSignalingChannel (p. 203)• DeleteStream (p. 205)• DescribeSignalingChannel (p. 208)• DescribeStream (p. 211)• GetDataEndpoint (p. 214)• GetSignalingChannelEndpoint (p. 217)• ListSignalingChannels (p. 220)• ListStreams (p. 223)• ListTagsForResource (p. 226)• ListTagsForStream (p. 229)• TagResource (p. 232)• TagStream (p. 234)• UntagResource (p. 237)• UntagStream (p. 239)• UpdateDataRetention (p. 242)• UpdateSignalingChannel (p. 245)• UpdateStream (p. 248)

195

Page 202: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams

CreateSignalingChannelService: Amazon Kinesis Video Streams

Creates a signaling channel.

CreateSignalingChannel is an asynchronous operation.

Request Syntax

POST /createSignalingChannel HTTP/1.1Content-type: application/json

{ "ChannelName": "string", "ChannelType": "string", "SingleMasterConfiguration": { "MessageTtlSeconds": number }, "Tags": [ { "Key": "string", "Value": "string" } ]}

URI Request Parameters

The request does not use any URI parameters.

Request Body

The request accepts the following data in JSON format.

ChannelName (p. 196)

A name for the signaling channel that you are creating. It must be unique for each AWS account andAWS Region.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 256.

Pattern: [a-zA-Z0-9_.-]+

Required: YesChannelType (p. 196)

A type of the signaling channel that you are creating. Currently, SINGLE_MASTER is the only supportedchannel type.

Type: String

Valid Values: SINGLE_MASTER

Required: NoSingleMasterConfiguration (p. 196)

A structure containing the configuration for the SINGLE_MASTER channel type.

196

Page 203: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams

Type: SingleMasterConfiguration (p. 294) object

Required: NoTags (p. 196)

A set of tags (key-value pairs) that you want to associate with this channel.

Type: Array of Tag (p. 298) objects

Array Members: Minimum number of 0 items. Maximum number of 50 items.

Required: No

Response Syntax

HTTP/1.1 200Content-type: application/json

{ "ChannelARN": "string"}

Response ElementsIf the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

ChannelARN (p. 197)

The Amazon Resource Name (ARN) of the created channel.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 1024.

Pattern: arn:aws:kinesisvideo:[a-z0-9-]+:[0-9]+:[a-z]+/[a-zA-Z0-9_.-]+/[0-9]+

ErrorsFor information about the errors that are common to all actions, see Common Errors (p. 311).

AccessDeniedException

You do not have required permissions to perform this operation.

HTTP Status Code: 401AccountChannelLimitExceededException

You have reached the maximum limit of active signaling channels for this AWS account in this region.

HTTP Status Code: 400ClientLimitExceededException

Kinesis Video Streams has throttled the request because you have exceeded the limit of allowed clientcalls. Try making the call later.

HTTP Status Code: 400

197

Page 204: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams

InvalidArgumentException

The value for this input parameter is invalid.

HTTP Status Code: 400ResourceInUseException

The signaling channel is currently not available for this operation.

HTTP Status Code: 400TagsPerResourceExceededLimitException

You have exceeded the limit of tags that you can associate with the resource. Kinesis video streamssupport up to 50 tags.

HTTP Status Code: 400

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS Command Line Interface• AWS SDK for .NET• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for JavaScript• AWS SDK for PHP V3• AWS SDK for Python• AWS SDK for Ruby V3

198

Page 205: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams

CreateStreamService: Amazon Kinesis Video Streams

Creates a new Kinesis video stream.

When you create a new stream, Kinesis Video Streams assigns it a version number. When you change thestream's metadata, Kinesis Video Streams updates the version.

CreateStream is an asynchronous operation.

For information about how the service works, see How it Works.

You must have permissions for the KinesisVideo:CreateStream action.

Request Syntax

POST /createStream HTTP/1.1Content-type: application/json

{ "DataRetentionInHours": number, "DeviceName": "string", "KmsKeyId": "string", "MediaType": "string", "StreamName": "string", "Tags": { "string" : "string" }}

URI Request ParametersThe request does not use any URI parameters.

Request BodyThe request accepts the following data in JSON format.

DataRetentionInHours (p. 199)

The number of hours that you want to retain the data in the stream. Kinesis Video Streams retains thedata in a data store that is associated with the stream.

The default value is 0, indicating that the stream does not persist data.

When the DataRetentionInHours value is 0, consumers can still consume the fragments thatremain in the service host buffer, which has a retention time limit of 5 minutes and a retention memorylimit of 200 MB. Fragments are removed from the buffer when either limit is reached.

Type: Integer

Valid Range: Minimum value of 0.

Required: NoDeviceName (p. 199)

The name of the device that is writing to the stream.Note

In the current implementation, Kinesis Video Streams does not use this name.

199

Page 206: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams

Type: String

Length Constraints: Minimum length of 1. Maximum length of 128.

Pattern: [a-zA-Z0-9_.-]+

Required: NoKmsKeyId (p. 199)

The ID of the AWS Key Management Service (AWS KMS) key that you want Kinesis Video Streams touse to encrypt stream data.

If no key ID is specified, the default, Kinesis Video-managed key (aws/kinesisvideo) is used.

For more information, see DescribeKey.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 2048.

Pattern: .+

Required: NoMediaType (p. 199)

The media type of the stream. Consumers of the stream can use this information when processingthe stream. For more information about media types, see Media Types. If you choose to specify theMediaType, see Naming Requirements for guidelines.

Example valid values include "video/h264" and "video/h264,audio/aac".

This parameter is optional; the default value is null (or empty in JSON).

Type: String

Length Constraints: Minimum length of 1. Maximum length of 128.

Pattern: [\w\-\.\+]+/[\w\-\.\+]+(,[\w\-\.\+]+/[\w\-\.\+]+)*

Required: NoStreamName (p. 199)

A name for the stream that you are creating.

The stream name is an identifier for the stream, and must be unique for each account and region.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 256.

Pattern: [a-zA-Z0-9_.-]+

Required: YesTags (p. 199)

A list of tags to associate with the specified stream. Each tag is a key-value pair (the value is optional).

Type: String to string map

Key Length Constraints: Minimum length of 1. Maximum length of 128.

200

Page 207: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams

Key Pattern: ^([\p{L}\p{Z}\p{N}_.:/=+\-@]*)$

Value Length Constraints: Minimum length of 0. Maximum length of 256.

Value Pattern: [\p{L}\p{Z}\p{N}_.:/=+\-@]*

Required: No

Response Syntax

HTTP/1.1 200Content-type: application/json

{ "StreamARN": "string"}

Response ElementsIf the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

StreamARN (p. 201)

The Amazon Resource Name (ARN) of the stream.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 1024.

Pattern: arn:aws:kinesisvideo:[a-z0-9-]+:[0-9]+:[a-z]+/[a-zA-Z0-9_.-]+/[0-9]+

ErrorsFor information about the errors that are common to all actions, see Common Errors (p. 311).

AccountStreamLimitExceededException

The number of streams created for the account is too high.

HTTP Status Code: 400ClientLimitExceededException

Kinesis Video Streams has throttled the request because you have exceeded the limit of allowed clientcalls. Try making the call later.

HTTP Status Code: 400DeviceStreamLimitExceededException

Not implemented.

HTTP Status Code: 400InvalidArgumentException

The value for this input parameter is invalid.

HTTP Status Code: 400

201

Page 208: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams

InvalidDeviceException

Not implemented.

HTTP Status Code: 400ResourceInUseException

The signaling channel is currently not available for this operation.

HTTP Status Code: 400TagsPerResourceExceededLimitException

You have exceeded the limit of tags that you can associate with the resource. Kinesis video streamssupport up to 50 tags.

HTTP Status Code: 400

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS Command Line Interface• AWS SDK for .NET• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for JavaScript• AWS SDK for PHP V3• AWS SDK for Python• AWS SDK for Ruby V3

202

Page 209: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams

DeleteSignalingChannelService: Amazon Kinesis Video Streams

Deletes a specified signaling channel. DeleteSignalingChannel is an asynchronous operation. If youdon't specify the channel's current version, the most recent version is deleted.

Request Syntax

POST /deleteSignalingChannel HTTP/1.1Content-type: application/json

{ "ChannelARN": "string", "CurrentVersion": "string"}

URI Request Parameters

The request does not use any URI parameters.

Request Body

The request accepts the following data in JSON format.

ChannelARN (p. 203)

The Amazon Resource Name (ARN) of the signaling channel that you want to delete.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 1024.

Pattern: arn:aws:kinesisvideo:[a-z0-9-]+:[0-9]+:[a-z]+/[a-zA-Z0-9_.-]+/[0-9]+

Required: YesCurrentVersion (p. 203)

The current version of the signaling channel that you want to delete. You can obtain the current versionby invoking the DescribeSignalingChannel or ListSignalingChannels API operations.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 64.

Pattern: [a-zA-Z0-9]+

Required: No

Response Syntax

HTTP/1.1 200

Response Elements

If the action is successful, the service sends back an HTTP 200 response with an empty HTTP body.

203

Page 210: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams

Errors

For information about the errors that are common to all actions, see Common Errors (p. 311).

AccessDeniedException

You do not have required permissions to perform this operation.

HTTP Status Code: 401ClientLimitExceededException

Kinesis Video Streams has throttled the request because you have exceeded the limit of allowed clientcalls. Try making the call later.

HTTP Status Code: 400InvalidArgumentException

The value for this input parameter is invalid.

HTTP Status Code: 400ResourceInUseException

The signaling channel is currently not available for this operation.

HTTP Status Code: 400ResourceNotFoundException

Amazon Kinesis Video Streams can't find the stream that you specified.

HTTP Status Code: 404VersionMismatchException

The stream version that you specified is not the latest version. To get the latest version, use theDescribeStream API.

HTTP Status Code: 400

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS Command Line Interface• AWS SDK for .NET• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for JavaScript• AWS SDK for PHP V3• AWS SDK for Python• AWS SDK for Ruby V3

204

Page 211: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams

DeleteStreamService: Amazon Kinesis Video Streams

Deletes a Kinesis video stream and the data contained in the stream.

This method marks the stream for deletion, and makes the data in the stream inaccessible immediately.

To ensure that you have the latest version of the stream before deleting it, you can specify the streamversion. Kinesis Video Streams assigns a version to each stream. When you update a stream, KinesisVideo Streams assigns a new version number. To get the latest stream version, use the DescribeStreamAPI.

This operation requires permission for the KinesisVideo:DeleteStream action.

Request Syntax

POST /deleteStream HTTP/1.1Content-type: application/json

{ "CurrentVersion": "string", "StreamARN": "string"}

URI Request ParametersThe request does not use any URI parameters.

Request BodyThe request accepts the following data in JSON format.

CurrentVersion (p. 205)

Optional: The version of the stream that you want to delete.

Specify the version as a safeguard to ensure that your are deleting the correct stream. To get thestream version, use the DescribeStream API.

If not specified, only the CreationTime is checked before deleting the stream.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 64.

Pattern: [a-zA-Z0-9]+

Required: NoStreamARN (p. 205)

The Amazon Resource Name (ARN) of the stream that you want to delete.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 1024.

Pattern: arn:aws:kinesisvideo:[a-z0-9-]+:[0-9]+:[a-z]+/[a-zA-Z0-9_.-]+/[0-9]+

Required: Yes

205

Page 212: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams

Response Syntax

HTTP/1.1 200

Response Elements

If the action is successful, the service sends back an HTTP 200 response with an empty HTTP body.

Errors

For information about the errors that are common to all actions, see Common Errors (p. 311).

ClientLimitExceededException

Kinesis Video Streams has throttled the request because you have exceeded the limit of allowed clientcalls. Try making the call later.

HTTP Status Code: 400InvalidArgumentException

The value for this input parameter is invalid.

HTTP Status Code: 400NotAuthorizedException

The caller is not authorized to perform this operation.

HTTP Status Code: 401ResourceInUseException

The signaling channel is currently not available for this operation.

HTTP Status Code: 400ResourceNotFoundException

Amazon Kinesis Video Streams can't find the stream that you specified.

HTTP Status Code: 404VersionMismatchException

The stream version that you specified is not the latest version. To get the latest version, use theDescribeStream API.

HTTP Status Code: 400

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS Command Line Interface• AWS SDK for .NET• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for JavaScript

206

Page 213: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams

• AWS SDK for PHP V3• AWS SDK for Python• AWS SDK for Ruby V3

207

Page 214: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams

DescribeSignalingChannelService: Amazon Kinesis Video Streams

Returns the most current information about the signaling channel. You must specify either the name or theAmazon Resource Name (ARN) of the channel that you want to describe.

Request Syntax

POST /describeSignalingChannel HTTP/1.1Content-type: application/json

{ "ChannelARN": "string", "ChannelName": "string"}

URI Request Parameters

The request does not use any URI parameters.

Request Body

The request accepts the following data in JSON format.

ChannelARN (p. 208)

The ARN of the signaling channel that you want to describe.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 1024.

Pattern: arn:aws:kinesisvideo:[a-z0-9-]+:[0-9]+:[a-z]+/[a-zA-Z0-9_.-]+/[0-9]+

Required: NoChannelName (p. 208)

The name of the signaling channel that you want to describe.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 256.

Pattern: [a-zA-Z0-9_.-]+

Required: No

Response Syntax

HTTP/1.1 200Content-type: application/json

{ "ChannelInfo": { "ChannelARN": "string", "ChannelName": "string", "ChannelStatus": "string", "ChannelType": "string",

208

Page 215: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams

"CreationTime": number, "SingleMasterConfiguration": { "MessageTtlSeconds": number }, "Version": "string" }}

Response Elements

If the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

ChannelInfo (p. 208)

A structure that encapsulates the specified signaling channel's metadata and properties.

Type: ChannelInfo (p. 289) object

Errors

For information about the errors that are common to all actions, see Common Errors (p. 311).

AccessDeniedException

You do not have required permissions to perform this operation.

HTTP Status Code: 401ClientLimitExceededException

Kinesis Video Streams has throttled the request because you have exceeded the limit of allowed clientcalls. Try making the call later.

HTTP Status Code: 400InvalidArgumentException

The value for this input parameter is invalid.

HTTP Status Code: 400ResourceNotFoundException

Amazon Kinesis Video Streams can't find the stream that you specified.

HTTP Status Code: 404

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS Command Line Interface• AWS SDK for .NET• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for JavaScript

209

Page 217: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams

DescribeStreamService: Amazon Kinesis Video Streams

Returns the most current information about the specified stream. You must specify either the StreamNameor the StreamARN.

Request Syntax

POST /describeStream HTTP/1.1Content-type: application/json

{ "StreamARN": "string", "StreamName": "string"}

URI Request Parameters

The request does not use any URI parameters.

Request Body

The request accepts the following data in JSON format.

StreamARN (p. 211)

The Amazon Resource Name (ARN) of the stream.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 1024.

Pattern: arn:aws:kinesisvideo:[a-z0-9-]+:[0-9]+:[a-z]+/[a-zA-Z0-9_.-]+/[0-9]+

Required: NoStreamName (p. 211)

The name of the stream.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 256.

Pattern: [a-zA-Z0-9_.-]+

Required: No

Response Syntax

HTTP/1.1 200Content-type: application/json

{ "StreamInfo": { "CreationTime": number, "DataRetentionInHours": number, "DeviceName": "string", "KmsKeyId": "string",

211

Page 218: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams

"MediaType": "string", "Status": "string", "StreamARN": "string", "StreamName": "string", "Version": "string" }}

Response Elements

If the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

StreamInfo (p. 211)

An object that describes the stream.

Type: StreamInfo (p. 295) object

Errors

For information about the errors that are common to all actions, see Common Errors (p. 311).

ClientLimitExceededException

Kinesis Video Streams has throttled the request because you have exceeded the limit of allowed clientcalls. Try making the call later.

HTTP Status Code: 400InvalidArgumentException

The value for this input parameter is invalid.

HTTP Status Code: 400NotAuthorizedException

The caller is not authorized to perform this operation.

HTTP Status Code: 401ResourceNotFoundException

Amazon Kinesis Video Streams can't find the stream that you specified.

HTTP Status Code: 404

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS Command Line Interface• AWS SDK for .NET• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for JavaScript

212

Page 220: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams

GetDataEndpointService: Amazon Kinesis Video Streams

Gets an endpoint for a specified stream for either reading or writing. Use this endpoint in your application toread from the specified stream (using the GetMedia or GetMediaForFragmentList operations) or writeto it (using the PutMedia operation).

Note

The returned endpoint does not have the API name appended. The client needs to add the APIname to the returned endpoint.

In the request, specify the stream either by StreamName or StreamARN.

Request Syntax

POST /getDataEndpoint HTTP/1.1Content-type: application/json

{ "APIName": "string", "StreamARN": "string", "StreamName": "string"}

URI Request ParametersThe request does not use any URI parameters.

Request BodyThe request accepts the following data in JSON format.

APIName (p. 214)

The name of the API action for which to get an endpoint.

Type: String

Valid Values: PUT_MEDIA | GET_MEDIA | LIST_FRAGMENTS |GET_MEDIA_FOR_FRAGMENT_LIST | GET_HLS_STREAMING_SESSION_URL |GET_DASH_STREAMING_SESSION_URL | GET_CLIP

Required: YesStreamARN (p. 214)

The Amazon Resource Name (ARN) of the stream that you want to get the endpoint for. You mustspecify either this parameter or a StreamName in the request.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 1024.

Pattern: arn:aws:kinesisvideo:[a-z0-9-]+:[0-9]+:[a-z]+/[a-zA-Z0-9_.-]+/[0-9]+

Required: NoStreamName (p. 214)

The name of the stream that you want to get the endpoint for. You must specify either this parameter ora StreamARN in the request.

214

Page 221: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams

Type: String

Length Constraints: Minimum length of 1. Maximum length of 256.

Pattern: [a-zA-Z0-9_.-]+

Required: No

Response Syntax

HTTP/1.1 200Content-type: application/json

{ "DataEndpoint": "string"}

Response Elements

If the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

DataEndpoint (p. 215)

The endpoint value. To read data from the stream or to write data to it, specify this endpoint in yourapplication.

Type: String

Errors

For information about the errors that are common to all actions, see Common Errors (p. 311).

ClientLimitExceededException

Kinesis Video Streams has throttled the request because you have exceeded the limit of allowed clientcalls. Try making the call later.

HTTP Status Code: 400InvalidArgumentException

The value for this input parameter is invalid.

HTTP Status Code: 400NotAuthorizedException

The caller is not authorized to perform this operation.

HTTP Status Code: 401ResourceNotFoundException

Amazon Kinesis Video Streams can't find the stream that you specified.

HTTP Status Code: 404

215

Page 223: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams

GetSignalingChannelEndpointService: Amazon Kinesis Video Streams

Provides an endpoint for the specified signaling channel to send and receive messages. This API uses theSingleMasterChannelEndpointConfiguration input parameter, which consists of the Protocolsand Role properties.

Protocols is used to determine the communication mechanism. For example, if you specify WSS as theprotocol, this API produces a secure websocket endpoint. If you specify HTTPS as the protocol, this APIgenerates an HTTPS endpoint.

Role determines the messaging permissions. A MASTER role results in this API generating an endpoint thata client can use to communicate with any of the viewers on the channel. A VIEWER role results in this APIgenerating an endpoint that a client can use to communicate only with a MASTER.

Request Syntax

POST /getSignalingChannelEndpoint HTTP/1.1Content-type: application/json

{ "ChannelARN": "string", "SingleMasterChannelEndpointConfiguration": { "Protocols": [ "string" ], "Role": "string" }}

URI Request ParametersThe request does not use any URI parameters.

Request BodyThe request accepts the following data in JSON format.

ChannelARN (p. 217)

The Amazon Resource Name (ARN) of the signalling channel for which you want to get an endpoint.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 1024.

Pattern: arn:aws:kinesisvideo:[a-z0-9-]+:[0-9]+:[a-z]+/[a-zA-Z0-9_.-]+/[0-9]+

Required: YesSingleMasterChannelEndpointConfiguration (p. 217)

A structure containing the endpoint configuration for the SINGLE_MASTER channel type.

Type: SingleMasterChannelEndpointConfiguration (p. 293) object

Required: No

Response Syntax

HTTP/1.1 200

217

Page 224: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams

Content-type: application/json

{ "ResourceEndpointList": [ { "Protocol": "string", "ResourceEndpoint": "string" } ]}

Response ElementsIf the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

ResourceEndpointList (p. 217)

A list of endpoints for the specified signaling channel.

Type: Array of ResourceEndpointListItem (p. 292) objects

ErrorsFor information about the errors that are common to all actions, see Common Errors (p. 311).

AccessDeniedException

You do not have required permissions to perform this operation.

HTTP Status Code: 401ClientLimitExceededException

Kinesis Video Streams has throttled the request because you have exceeded the limit of allowed clientcalls. Try making the call later.

HTTP Status Code: 400InvalidArgumentException

The value for this input parameter is invalid.

HTTP Status Code: 400ResourceInUseException

The signaling channel is currently not available for this operation.

HTTP Status Code: 400ResourceNotFoundException

Amazon Kinesis Video Streams can't find the stream that you specified.

HTTP Status Code: 404

See AlsoFor more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS Command Line Interface

218

Page 226: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams

ListSignalingChannelsService: Amazon Kinesis Video Streams

Returns an array of ChannelInfo objects. Each object describes a signaling channel. To retrieve onlythose channels that satisfy a specific condition, you can specify a ChannelNameCondition.

Request Syntax

POST /listSignalingChannels HTTP/1.1Content-type: application/json

{ "ChannelNameCondition": { "ComparisonOperator": "string", "ComparisonValue": "string" }, "MaxResults": number, "NextToken": "string"}

URI Request Parameters

The request does not use any URI parameters.

Request Body

The request accepts the following data in JSON format.

ChannelNameCondition (p. 220)

Optional: Returns only the channels that satisfy a specific condition.

Type: ChannelNameCondition (p. 291) object

Required: NoMaxResults (p. 220)

The maximum number of channels to return in the response. The default is 500.

Type: Integer

Valid Range: Minimum value of 1. Maximum value of 10000.

Required: NoNextToken (p. 220)

If you specify this parameter, when the result of a ListSignalingChannels operation is truncated,the call returns the NextToken in the response. To get another batch of channels, provide this token inyour next request.

Type: String

Length Constraints: Minimum length of 0. Maximum length of 512.

Pattern: [a-zA-Z0-9+/=]*

Required: No

220

Page 227: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams

Response Syntax

HTTP/1.1 200Content-type: application/json

{ "ChannelInfoList": [ { "ChannelARN": "string", "ChannelName": "string", "ChannelStatus": "string", "ChannelType": "string", "CreationTime": number, "SingleMasterConfiguration": { "MessageTtlSeconds": number }, "Version": "string" } ], "NextToken": "string"}

Response Elements

If the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

ChannelInfoList (p. 221)

An array of ChannelInfo objects.

Type: Array of ChannelInfo (p. 289) objectsNextToken (p. 221)

If the response is truncated, the call returns this element with a token. To get the next batch of streams,use this token in your next request.

Type: String

Length Constraints: Minimum length of 0. Maximum length of 512.

Pattern: [a-zA-Z0-9+/=]*

Errors

For information about the errors that are common to all actions, see Common Errors (p. 311).

AccessDeniedException

You do not have required permissions to perform this operation.

HTTP Status Code: 401ClientLimitExceededException

Kinesis Video Streams has throttled the request because you have exceeded the limit of allowed clientcalls. Try making the call later.

HTTP Status Code: 400

221

Page 229: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams

ListStreamsService: Amazon Kinesis Video Streams

Returns an array of StreamInfo objects. Each object describes a stream. To retrieve only streams thatsatisfy a specific condition, you can specify a StreamNameCondition.

Request Syntax

POST /listStreams HTTP/1.1Content-type: application/json

{ "MaxResults": number, "NextToken": "string", "StreamNameCondition": { "ComparisonOperator": "string", "ComparisonValue": "string" }}

URI Request Parameters

The request does not use any URI parameters.

Request Body

The request accepts the following data in JSON format.

MaxResults (p. 223)

The maximum number of streams to return in the response. The default is 10,000.

Type: Integer

Valid Range: Minimum value of 1. Maximum value of 10000.

Required: NoNextToken (p. 223)

If you specify this parameter, when the result of a ListStreams operation is truncated, the call returnsthe NextToken in the response. To get another batch of streams, provide this token in your nextrequest.

Type: String

Length Constraints: Minimum length of 0. Maximum length of 512.

Pattern: [a-zA-Z0-9+/=]*

Required: NoStreamNameCondition (p. 223)

Optional: Returns only streams that satisfy a specific condition. Currently, you can specify only theprefix of a stream name as a condition.

Type: StreamNameCondition (p. 297) object

Required: No

223

Page 230: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams

Response Syntax

HTTP/1.1 200Content-type: application/json

{ "NextToken": "string", "StreamInfoList": [ { "CreationTime": number, "DataRetentionInHours": number, "DeviceName": "string", "KmsKeyId": "string", "MediaType": "string", "Status": "string", "StreamARN": "string", "StreamName": "string", "Version": "string" } ]}

Response Elements

If the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

NextToken (p. 224)

If the response is truncated, the call returns this element with a token. To get the next batch of streams,use this token in your next request.

Type: String

Length Constraints: Minimum length of 0. Maximum length of 512.

Pattern: [a-zA-Z0-9+/=]*StreamInfoList (p. 224)

An array of StreamInfo objects.

Type: Array of StreamInfo (p. 295) objects

Errors

For information about the errors that are common to all actions, see Common Errors (p. 311).

ClientLimitExceededException

Kinesis Video Streams has throttled the request because you have exceeded the limit of allowed clientcalls. Try making the call later.

HTTP Status Code: 400InvalidArgumentException

The value for this input parameter is invalid.

HTTP Status Code: 400

224

Page 232: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams

ListTagsForResourceService: Amazon Kinesis Video Streams

Returns a list of tags associated with the specified signaling channel.

Request Syntax

POST /ListTagsForResource HTTP/1.1Content-type: application/json

{ "NextToken": "string", "ResourceARN": "string"}

URI Request ParametersThe request does not use any URI parameters.

Request BodyThe request accepts the following data in JSON format.

NextToken (p. 226)

If you specify this parameter and the result of a ListTagsForResource call is truncated, theresponse includes a token that you can use in the next request to fetch the next batch of tags.

Type: String

Length Constraints: Minimum length of 0. Maximum length of 512.

Pattern: [a-zA-Z0-9+/=]*

Required: NoResourceARN (p. 226)

The Amazon Resource Name (ARN) of the signaling channel for which you want to list tags.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 1024.

Pattern: arn:aws:kinesisvideo:[a-z0-9-]+:[0-9]+:[a-z]+/[a-zA-Z0-9_.-]+/[0-9]+

Required: Yes

Response Syntax

HTTP/1.1 200Content-type: application/json

{ "NextToken": "string", "Tags": { "string" : "string" }}

226

Page 233: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams

Response ElementsIf the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

NextToken (p. 226)

If you specify this parameter and the result of a ListTagsForResource call is truncated, theresponse includes a token that you can use in the next request to fetch the next set of tags.

Type: String

Length Constraints: Minimum length of 0. Maximum length of 512.

Pattern: [a-zA-Z0-9+/=]*Tags (p. 226)

A map of tag keys and values associated with the specified signaling channel.

Type: String to string map

Key Length Constraints: Minimum length of 1. Maximum length of 128.

Key Pattern: ^([\p{L}\p{Z}\p{N}_.:/=+\-@]*)$

Value Length Constraints: Minimum length of 0. Maximum length of 256.

Value Pattern: [\p{L}\p{Z}\p{N}_.:/=+\-@]*

ErrorsFor information about the errors that are common to all actions, see Common Errors (p. 311).

AccessDeniedException

You do not have required permissions to perform this operation.

HTTP Status Code: 401ClientLimitExceededException

Kinesis Video Streams has throttled the request because you have exceeded the limit of allowed clientcalls. Try making the call later.

HTTP Status Code: 400InvalidArgumentException

The value for this input parameter is invalid.

HTTP Status Code: 400ResourceNotFoundException

Amazon Kinesis Video Streams can't find the stream that you specified.

HTTP Status Code: 404

See AlsoFor more information about using this API in one of the language-specific AWS SDKs, see the following:

227

Page 235: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams

ListTagsForStreamService: Amazon Kinesis Video Streams

Returns a list of tags associated with the specified stream.

In the request, you must specify either the StreamName or the StreamARN.

Request Syntax

POST /listTagsForStream HTTP/1.1Content-type: application/json

{ "NextToken": "string", "StreamARN": "string", "StreamName": "string"}

URI Request Parameters

The request does not use any URI parameters.

Request Body

The request accepts the following data in JSON format.

NextToken (p. 229)

If you specify this parameter and the result of a ListTagsForStream call is truncated, the responseincludes a token that you can use in the next request to fetch the next batch of tags.

Type: String

Length Constraints: Minimum length of 0. Maximum length of 512.

Pattern: [a-zA-Z0-9+/=]*

Required: NoStreamARN (p. 229)

The Amazon Resource Name (ARN) of the stream that you want to list tags for.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 1024.

Pattern: arn:aws:kinesisvideo:[a-z0-9-]+:[0-9]+:[a-z]+/[a-zA-Z0-9_.-]+/[0-9]+

Required: NoStreamName (p. 229)

The name of the stream that you want to list tags for.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 256.

Pattern: [a-zA-Z0-9_.-]+

229

Page 236: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams

Required: No

Response Syntax

HTTP/1.1 200Content-type: application/json

{ "NextToken": "string", "Tags": { "string" : "string" }}

Response ElementsIf the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

NextToken (p. 230)

If you specify this parameter and the result of a ListTags call is truncated, the response includes atoken that you can use in the next request to fetch the next set of tags.

Type: String

Length Constraints: Minimum length of 0. Maximum length of 512.

Pattern: [a-zA-Z0-9+/=]*Tags (p. 230)

A map of tag keys and values associated with the specified stream.

Type: String to string map

Key Length Constraints: Minimum length of 1. Maximum length of 128.

Key Pattern: ^([\p{L}\p{Z}\p{N}_.:/=+\-@]*)$

Value Length Constraints: Minimum length of 0. Maximum length of 256.

Value Pattern: [\p{L}\p{Z}\p{N}_.:/=+\-@]*

ErrorsFor information about the errors that are common to all actions, see Common Errors (p. 311).

ClientLimitExceededException

Kinesis Video Streams has throttled the request because you have exceeded the limit of allowed clientcalls. Try making the call later.

HTTP Status Code: 400InvalidArgumentException

The value for this input parameter is invalid.

HTTP Status Code: 400

230

Page 237: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams

InvalidResourceFormatException

The format of the StreamARN is invalid.

HTTP Status Code: 400NotAuthorizedException

The caller is not authorized to perform this operation.

HTTP Status Code: 401ResourceNotFoundException

Amazon Kinesis Video Streams can't find the stream that you specified.

HTTP Status Code: 404

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS Command Line Interface• AWS SDK for .NET• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for JavaScript• AWS SDK for PHP V3• AWS SDK for Python• AWS SDK for Ruby V3

231

Page 238: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams

TagResourceService: Amazon Kinesis Video Streams

Adds one or more tags to a signaling channel. A tag is a key-value pair (the value is optional) that you candefine and assign to AWS resources. If you specify a tag that already exists, the tag value is replaced withthe value that you specify in the request. For more information, see Using Cost Allocation Tags in the AWSBilling and Cost Management User Guide.

Request Syntax

POST /TagResource HTTP/1.1Content-type: application/json

{ "ResourceARN": "string", "Tags": [ { "Key": "string", "Value": "string" } ]}

URI Request ParametersThe request does not use any URI parameters.

Request BodyThe request accepts the following data in JSON format.

ResourceARN (p. 232)

The Amazon Resource Name (ARN) of the signaling channel to which you want to add tags.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 1024.

Pattern: arn:aws:kinesisvideo:[a-z0-9-]+:[0-9]+:[a-z]+/[a-zA-Z0-9_.-]+/[0-9]+

Required: YesTags (p. 232)

A list of tags to associate with the specified signaling channel. Each tag is a key-value pair.

Type: Array of Tag (p. 298) objects

Array Members: Minimum number of 1 item. Maximum number of 50 items.

Required: Yes

Response Syntax

HTTP/1.1 200

Response ElementsIf the action is successful, the service sends back an HTTP 200 response with an empty HTTP body.

232

Page 239: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams

Errors

For information about the errors that are common to all actions, see Common Errors (p. 311).

AccessDeniedException

You do not have required permissions to perform this operation.

HTTP Status Code: 401ClientLimitExceededException

Kinesis Video Streams has throttled the request because you have exceeded the limit of allowed clientcalls. Try making the call later.

HTTP Status Code: 400InvalidArgumentException

The value for this input parameter is invalid.

HTTP Status Code: 400ResourceNotFoundException

Amazon Kinesis Video Streams can't find the stream that you specified.

HTTP Status Code: 404TagsPerResourceExceededLimitException

You have exceeded the limit of tags that you can associate with the resource. Kinesis video streamssupport up to 50 tags.

HTTP Status Code: 400

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS Command Line Interface• AWS SDK for .NET• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for JavaScript• AWS SDK for PHP V3• AWS SDK for Python• AWS SDK for Ruby V3

233

Page 240: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams

TagStreamService: Amazon Kinesis Video Streams

Adds one or more tags to a stream. A tag is a key-value pair (the value is optional) that you can define andassign to AWS resources. If you specify a tag that already exists, the tag value is replaced with the valuethat you specify in the request. For more information, see Using Cost Allocation Tags in the AWS Billingand Cost Management User Guide.

You must provide either the StreamName or the StreamARN.

This operation requires permission for the KinesisVideo:TagStream action.

Kinesis video streams support up to 50 tags.

Request Syntax

POST /tagStream HTTP/1.1Content-type: application/json

{ "StreamARN": "string", "StreamName": "string", "Tags": { "string" : "string" }}

URI Request ParametersThe request does not use any URI parameters.

Request BodyThe request accepts the following data in JSON format.

StreamARN (p. 234)

The Amazon Resource Name (ARN) of the resource that you want to add the tag or tags to.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 1024.

Pattern: arn:aws:kinesisvideo:[a-z0-9-]+:[0-9]+:[a-z]+/[a-zA-Z0-9_.-]+/[0-9]+

Required: NoStreamName (p. 234)

The name of the stream that you want to add the tag or tags to.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 256.

Pattern: [a-zA-Z0-9_.-]+

Required: NoTags (p. 234)

A list of tags to associate with the specified stream. Each tag is a key-value pair (the value is optional).

234

Page 241: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams

Type: String to string map

Key Length Constraints: Minimum length of 1. Maximum length of 128.

Key Pattern: ^([\p{L}\p{Z}\p{N}_.:/=+\-@]*)$

Value Length Constraints: Minimum length of 0. Maximum length of 256.

Value Pattern: [\p{L}\p{Z}\p{N}_.:/=+\-@]*

Required: Yes

Response Syntax

HTTP/1.1 200

Response Elements

If the action is successful, the service sends back an HTTP 200 response with an empty HTTP body.

Errors

For information about the errors that are common to all actions, see Common Errors (p. 311).

ClientLimitExceededException

Kinesis Video Streams has throttled the request because you have exceeded the limit of allowed clientcalls. Try making the call later.

HTTP Status Code: 400InvalidArgumentException

The value for this input parameter is invalid.

HTTP Status Code: 400InvalidResourceFormatException

The format of the StreamARN is invalid.

HTTP Status Code: 400NotAuthorizedException

The caller is not authorized to perform this operation.

HTTP Status Code: 401ResourceNotFoundException

Amazon Kinesis Video Streams can't find the stream that you specified.

HTTP Status Code: 404TagsPerResourceExceededLimitException

You have exceeded the limit of tags that you can associate with the resource. Kinesis video streamssupport up to 50 tags.

HTTP Status Code: 400

235

Page 243: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams

UntagResourceService: Amazon Kinesis Video Streams

Removes one or more tags from a signaling channel. In the request, specify only a tag key or keys; don'tspecify the value. If you specify a tag key that does not exist, it's ignored.

Request Syntax

POST /UntagResource HTTP/1.1Content-type: application/json

{ "ResourceARN": "string", "TagKeyList": [ "string" ]}

URI Request Parameters

The request does not use any URI parameters.

Request Body

The request accepts the following data in JSON format.

ResourceARN (p. 237)

The Amazon Resource Name (ARN) of the signaling channel from which you want to remove tags.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 1024.

Pattern: arn:aws:kinesisvideo:[a-z0-9-]+:[0-9]+:[a-z]+/[a-zA-Z0-9_.-]+/[0-9]+

Required: YesTagKeyList (p. 237)

A list of the keys of the tags that you want to remove.

Type: Array of strings

Array Members: Minimum number of 1 item. Maximum number of 50 items.

Length Constraints: Minimum length of 1. Maximum length of 128.

Pattern: ^([\p{L}\p{Z}\p{N}_.:/=+\-@]*)$

Required: Yes

Response Syntax

HTTP/1.1 200

Response Elements

If the action is successful, the service sends back an HTTP 200 response with an empty HTTP body.

237

Page 244: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams

Errors

For information about the errors that are common to all actions, see Common Errors (p. 311).

AccessDeniedException

You do not have required permissions to perform this operation.

HTTP Status Code: 401ClientLimitExceededException

Kinesis Video Streams has throttled the request because you have exceeded the limit of allowed clientcalls. Try making the call later.

HTTP Status Code: 400InvalidArgumentException

The value for this input parameter is invalid.

HTTP Status Code: 400ResourceNotFoundException

Amazon Kinesis Video Streams can't find the stream that you specified.

HTTP Status Code: 404

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS Command Line Interface• AWS SDK for .NET• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for JavaScript• AWS SDK for PHP V3• AWS SDK for Python• AWS SDK for Ruby V3

238

Page 245: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams

UntagStreamService: Amazon Kinesis Video Streams

Removes one or more tags from a stream. In the request, specify only a tag key or keys; don't specify thevalue. If you specify a tag key that does not exist, it's ignored.

In the request, you must provide the StreamName or StreamARN.

Request Syntax

POST /untagStream HTTP/1.1Content-type: application/json

{ "StreamARN": "string", "StreamName": "string", "TagKeyList": [ "string" ]}

URI Request ParametersThe request does not use any URI parameters.

Request BodyThe request accepts the following data in JSON format.

StreamARN (p. 239)

The Amazon Resource Name (ARN) of the stream that you want to remove tags from.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 1024.

Pattern: arn:aws:kinesisvideo:[a-z0-9-]+:[0-9]+:[a-z]+/[a-zA-Z0-9_.-]+/[0-9]+

Required: NoStreamName (p. 239)

The name of the stream that you want to remove tags from.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 256.

Pattern: [a-zA-Z0-9_.-]+

Required: NoTagKeyList (p. 239)

A list of the keys of the tags that you want to remove.

Type: Array of strings

Array Members: Minimum number of 1 item. Maximum number of 50 items.

Length Constraints: Minimum length of 1. Maximum length of 128.

Pattern: ^([\p{L}\p{Z}\p{N}_.:/=+\-@]*)$

239

Page 246: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams

Required: Yes

Response Syntax

HTTP/1.1 200

Response Elements

If the action is successful, the service sends back an HTTP 200 response with an empty HTTP body.

Errors

For information about the errors that are common to all actions, see Common Errors (p. 311).

ClientLimitExceededException

Kinesis Video Streams has throttled the request because you have exceeded the limit of allowed clientcalls. Try making the call later.

HTTP Status Code: 400InvalidArgumentException

The value for this input parameter is invalid.

HTTP Status Code: 400InvalidResourceFormatException

The format of the StreamARN is invalid.

HTTP Status Code: 400NotAuthorizedException

The caller is not authorized to perform this operation.

HTTP Status Code: 401ResourceNotFoundException

Amazon Kinesis Video Streams can't find the stream that you specified.

HTTP Status Code: 404

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS Command Line Interface• AWS SDK for .NET• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for JavaScript• AWS SDK for PHP V3• AWS SDK for Python• AWS SDK for Ruby V3

240

Page 247: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams

241

Page 248: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams

UpdateDataRetentionService: Amazon Kinesis Video Streams

Increases or decreases the stream's data retention period by the value that you specify. To indicatewhether you want to increase or decrease the data retention period, specify the Operation parameter inthe request body. In the request, you must specify either the StreamName or the StreamARN.

Note

The retention period that you specify replaces the current value.

This operation requires permission for the KinesisVideo:UpdateDataRetention action.

Changing the data retention period affects the data in the stream as follows:

• If the data retention period is increased, existing data is retained for the new retention period. Forexample, if the data retention period is increased from one hour to seven hours, all existing data isretained for seven hours.

• If the data retention period is decreased, existing data is retained for the new retention period. Forexample, if the data retention period is decreased from seven hours to one hour, all existing data isretained for one hour, and any data older than one hour is deleted immediately.

Request Syntax

POST /updateDataRetention HTTP/1.1Content-type: application/json

{ "CurrentVersion": "string", "DataRetentionChangeInHours": number, "Operation": "string", "StreamARN": "string", "StreamName": "string"}

URI Request ParametersThe request does not use any URI parameters.

Request BodyThe request accepts the following data in JSON format.

CurrentVersion (p. 242)

The version of the stream whose retention period you want to change. To get the version, call eitherthe DescribeStream or the ListStreams API.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 64.

Pattern: [a-zA-Z0-9]+

Required: YesDataRetentionChangeInHours (p. 242)

The retention period, in hours. The value you specify replaces the current value. The maximum valuefor this parameter is 87600 (ten years).

242

Page 249: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams

Type: Integer

Valid Range: Minimum value of 1.

Required: YesOperation (p. 242)

Indicates whether you want to increase or decrease the retention period.

Type: String

Valid Values: INCREASE_DATA_RETENTION | DECREASE_DATA_RETENTION

Required: YesStreamARN (p. 242)

The Amazon Resource Name (ARN) of the stream whose retention period you want to change.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 1024.

Pattern: arn:aws:kinesisvideo:[a-z0-9-]+:[0-9]+:[a-z]+/[a-zA-Z0-9_.-]+/[0-9]+

Required: NoStreamName (p. 242)

The name of the stream whose retention period you want to change.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 256.

Pattern: [a-zA-Z0-9_.-]+

Required: No

Response Syntax

HTTP/1.1 200

Response Elements

If the action is successful, the service sends back an HTTP 200 response with an empty HTTP body.

Errors

For information about the errors that are common to all actions, see Common Errors (p. 311).

ClientLimitExceededException

Kinesis Video Streams has throttled the request because you have exceeded the limit of allowed clientcalls. Try making the call later.

HTTP Status Code: 400InvalidArgumentException

The value for this input parameter is invalid.

243

Page 250: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams

HTTP Status Code: 400NotAuthorizedException

The caller is not authorized to perform this operation.

HTTP Status Code: 401ResourceInUseException

The signaling channel is currently not available for this operation.

HTTP Status Code: 400ResourceNotFoundException

Amazon Kinesis Video Streams can't find the stream that you specified.

HTTP Status Code: 404VersionMismatchException

The stream version that you specified is not the latest version. To get the latest version, use theDescribeStream API.

HTTP Status Code: 400

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS Command Line Interface• AWS SDK for .NET• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for JavaScript• AWS SDK for PHP V3• AWS SDK for Python• AWS SDK for Ruby V3

244

Page 251: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams

UpdateSignalingChannelService: Amazon Kinesis Video Streams

Updates the existing signaling channel. This is an asynchronous operation and takes time to complete.

If the MessageTtlSeconds value is updated (either increased or reduced), it only applies to newmessages sent via this channel after it's been updated. Existing messages are still expired as per theprevious MessageTtlSeconds value.

Request Syntax

POST /updateSignalingChannel HTTP/1.1Content-type: application/json

{ "ChannelARN": "string", "CurrentVersion": "string", "SingleMasterConfiguration": { "MessageTtlSeconds": number }}

URI Request ParametersThe request does not use any URI parameters.

Request BodyThe request accepts the following data in JSON format.

ChannelARN (p. 245)

The Amazon Resource Name (ARN) of the signaling channel that you want to update.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 1024.

Pattern: arn:aws:kinesisvideo:[a-z0-9-]+:[0-9]+:[a-z]+/[a-zA-Z0-9_.-]+/[0-9]+

Required: YesCurrentVersion (p. 245)

The current version of the signaling channel that you want to update.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 64.

Pattern: [a-zA-Z0-9]+

Required: YesSingleMasterConfiguration (p. 245)

The structure containing the configuration for the SINGLE_MASTER type of the signaling channel thatyou want to update.

Type: SingleMasterConfiguration (p. 294) object

Required: No

245

Page 252: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams

Response Syntax

HTTP/1.1 200

Response Elements

If the action is successful, the service sends back an HTTP 200 response with an empty HTTP body.

Errors

For information about the errors that are common to all actions, see Common Errors (p. 311).

AccessDeniedException

You do not have required permissions to perform this operation.

HTTP Status Code: 401ClientLimitExceededException

Kinesis Video Streams has throttled the request because you have exceeded the limit of allowed clientcalls. Try making the call later.

HTTP Status Code: 400InvalidArgumentException

The value for this input parameter is invalid.

HTTP Status Code: 400ResourceInUseException

The signaling channel is currently not available for this operation.

HTTP Status Code: 400ResourceNotFoundException

Amazon Kinesis Video Streams can't find the stream that you specified.

HTTP Status Code: 404VersionMismatchException

The stream version that you specified is not the latest version. To get the latest version, use theDescribeStream API.

HTTP Status Code: 400

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS Command Line Interface• AWS SDK for .NET• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for JavaScript

246

Page 254: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams

UpdateStreamService: Amazon Kinesis Video Streams

Updates stream metadata, such as the device name and media type.

You must provide the stream name or the Amazon Resource Name (ARN) of the stream.

To make sure that you have the latest version of the stream before updating it, you can specify the streamversion. Kinesis Video Streams assigns a version to each stream. When you update a stream, KinesisVideo Streams assigns a new version number. To get the latest stream version, use the DescribeStreamAPI.

UpdateStream is an asynchronous operation, and takes time to complete.

Request Syntax

POST /updateStream HTTP/1.1Content-type: application/json

{ "CurrentVersion": "string", "DeviceName": "string", "MediaType": "string", "StreamARN": "string", "StreamName": "string"}

URI Request Parameters

The request does not use any URI parameters.

Request Body

The request accepts the following data in JSON format.

CurrentVersion (p. 248)

The version of the stream whose metadata you want to update.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 64.

Pattern: [a-zA-Z0-9]+

Required: YesDeviceName (p. 248)

The name of the device that is writing to the stream.

Note

In the current implementation, Kinesis Video Streams does not use this name.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 128.

Pattern: [a-zA-Z0-9_.-]+

248

Page 255: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams

Required: NoMediaType (p. 248)

The stream's media type. Use MediaType to specify the type of content that the stream contains to theconsumers of the stream. For more information about media types, see Media Types. If you choose tospecify the MediaType, see Naming Requirements.

To play video on the console, you must specify the correct video type. For example, if the video in thestream is H.264, specify video/h264 as the MediaType.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 128.

Pattern: [\w\-\.\+]+/[\w\-\.\+]+(,[\w\-\.\+]+/[\w\-\.\+]+)*

Required: NoStreamARN (p. 248)

The ARN of the stream whose metadata you want to update.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 1024.

Pattern: arn:aws:kinesisvideo:[a-z0-9-]+:[0-9]+:[a-z]+/[a-zA-Z0-9_.-]+/[0-9]+

Required: NoStreamName (p. 248)

The name of the stream whose metadata you want to update.

The stream name is an identifier for the stream, and must be unique for each account and region.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 256.

Pattern: [a-zA-Z0-9_.-]+

Required: No

Response Syntax

HTTP/1.1 200

Response Elements

If the action is successful, the service sends back an HTTP 200 response with an empty HTTP body.

Errors

For information about the errors that are common to all actions, see Common Errors (p. 311).

ClientLimitExceededException

Kinesis Video Streams has throttled the request because you have exceeded the limit of allowed clientcalls. Try making the call later.

249

Page 256: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams Media

HTTP Status Code: 400InvalidArgumentException

The value for this input parameter is invalid.

HTTP Status Code: 400NotAuthorizedException

The caller is not authorized to perform this operation.

HTTP Status Code: 401ResourceInUseException

The signaling channel is currently not available for this operation.

HTTP Status Code: 400ResourceNotFoundException

Amazon Kinesis Video Streams can't find the stream that you specified.

HTTP Status Code: 404VersionMismatchException

The stream version that you specified is not the latest version. To get the latest version, use theDescribeStream API.

HTTP Status Code: 400

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS Command Line Interface• AWS SDK for .NET• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for JavaScript• AWS SDK for PHP V3• AWS SDK for Python• AWS SDK for Ruby V3

Amazon Kinesis Video Streams MediaThe following actions are supported by Amazon Kinesis Video Streams Media:

• GetMedia (p. 251)• PutMedia (p. 255)

250

Page 257: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams Media

GetMediaService: Amazon Kinesis Video Streams Media

Use this API to retrieve media content from a Kinesis video stream. In the request, you identify the streamname or stream Amazon Resource Name (ARN), and the starting chunk. Kinesis Video Streams thenreturns a stream of chunks in order by fragment number.

Note

You must first call the GetDataEndpoint API to get an endpoint. Then send the GetMediarequests to this endpoint using the --endpoint-url parameter.

When you put media data (fragments) on a stream, Kinesis Video Streams stores each incoming fragmentand related metadata in what is called a "chunk." For more information, see PutMedia. The GetMedia APIreturns a stream of these chunks starting from the chunk that you specify in the request.

The following limits apply when using the GetMedia API:

• A client can call GetMedia up to five times per second per stream.• Kinesis Video Streams sends media data at a rate of up to 25 megabytes per second (or 200 megabits

per second) during a GetMedia session.

Note

If an error is thrown after invoking a Kinesis Video Streams media API, in addition to the HTTPstatus code and the response body, it includes the following pieces of information:

• x-amz-ErrorType HTTP header – contains a more specific error type in addition to what theHTTP status code provides.

• x-amz-RequestId HTTP header – if you want to report an issue to AWS, the support team canbetter diagnose the problem if given the Request Id.

Both the HTTP status code and the ErrorType header can be utilized to make programmaticdecisions about whether errors are retry-able and under what conditions, as well as provideinformation on what actions the client programmer might need to take in order to successfully tryagain.For more information, see the Errors section at the bottom of this topic, as well as Common Errors.

Request Syntax

POST /getMedia HTTP/1.1Content-type: application/json

{ "StartSelector": { "AfterFragmentNumber": "string", "ContinuationToken": "string", "StartSelectorType": "string", "StartTimestamp": number }, "StreamARN": "string", "StreamName": "string"}

URI Request Parameters

The request does not use any URI parameters.

251

Page 258: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams Media

Request Body

The request accepts the following data in JSON format.

StartSelector (p. 251)

Identifies the starting chunk to get from the specified stream.

Type: StartSelector (p. 299) object

Required: YesStreamARN (p. 251)

The ARN of the stream from where you want to get the media content. If you don't specify thestreamARN, you must specify the streamName.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 1024.

Pattern: arn:aws:kinesisvideo:[a-z0-9-]+:[0-9]+:[a-z]+/[a-zA-Z0-9_.-]+/[0-9]+

Required: NoStreamName (p. 251)

The Kinesis video stream name from where you want to get the media content. If you don't specify thestreamName, you must specify the streamARN.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 256.

Pattern: [a-zA-Z0-9_.-]+

Required: No

Response Syntax

HTTP/1.1 200Content-Type: ContentType

Payload

Response Elements

If the action is successful, the service sends back an HTTP 200 response.

The response returns the following HTTP headers.

ContentType (p. 252)

The content type of the requested media.

Length Constraints: Minimum length of 1. Maximum length of 128.

Pattern: ^[a-zA-Z0-9_\.\-]+$

The response returns the following as the HTTP body.

252

Page 259: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams Media

Payload (p. 252)

The payload Kinesis Video Streams returns is a sequence of chunks from the specified stream. Formore information about the chunks, see PutMedia. The chunks that Kinesis Video Streams returns inthe GetMedia call also include the following additional Matroska (MKV) tags:• AWS_KINESISVIDEO_CONTINUATION_TOKEN (UTF-8 string) - In the event your GetMedia call

terminates, you can use this continuation token in your next request to get the next chunk where thelast request terminated.

• AWS_KINESISVIDEO_MILLIS_BEHIND_NOW (UTF-8 string) - Client applications can use this tagvalue to determine how far behind the chunk returned in the response is from the latest chunk on thestream.

• AWS_KINESISVIDEO_FRAGMENT_NUMBER - Fragment number returned in the chunk.• AWS_KINESISVIDEO_SERVER_TIMESTAMP - Server timestamp of the fragment.• AWS_KINESISVIDEO_PRODUCER_TIMESTAMP - Producer timestamp of the fragment.

The following tags will be present if an error occurs:• AWS_KINESISVIDEO_ERROR_CODE - String description of an error that caused GetMedia to stop.• AWS_KINESISVIDEO_ERROR_ID: Integer code of the error.

The error codes are as follows:• 3002 - Error writing to the stream• 4000 - Requested fragment is not found• 4500 - Access denied for the stream's KMS key• 4501 - Stream's KMS key is disabled• 4502 - Validation error on the stream's KMS key• 4503 - KMS key specified in the stream is unavailable• 4504 - Invalid usage of the KMS key specified in the stream• 4505 - Invalid state of the KMS key specified in the stream• 4506 - Unable to find the KMS key specified in the stream• 5000 - Internal error

Errors

For information about the errors that are common to all actions, see Common Errors (p. 311).

ClientLimitExceededException

Kinesis Video Streams has throttled the request because you have exceeded the limit of allowed clientcalls. Try making the call later.

HTTP Status Code: 400ConnectionLimitExceededException

Kinesis Video Streams has throttled the request because you have exceeded the limit of allowed clientconnections.

HTTP Status Code: 400InvalidArgumentException

The value for this input parameter is invalid.

HTTP Status Code: 400

253

Page 260: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams Media

InvalidEndpointException

Caller used wrong endpoint to write data to a stream. On receiving such an exception, the user mustcall GetDataEndpoint with APIName set to PUT_MEDIA and use the endpoint from response toinvoke the next PutMedia call.

HTTP Status Code: 400NotAuthorizedException

The caller is not authorized to perform an operation on the given stream, or the token has expired.

HTTP Status Code: 401ResourceNotFoundException

Status Code: 404, The stream with the given name does not exist.

HTTP Status Code: 404

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS Command Line Interface• AWS SDK for .NET• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for JavaScript• AWS SDK for PHP V3• AWS SDK for Python• AWS SDK for Ruby V3

254

Page 261: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams Media

PutMediaService: Amazon Kinesis Video Streams Media

Use this API to send media data to a Kinesis video stream.

Note

Before using this API, you must call the GetDataEndpoint API to get an endpoint. You thenspecify the endpoint in your PutMedia request.

In the request, you use the HTTP headers to provide parameter information, for example, stream name,timestamp, and whether the timestamp value is absolute or relative to when the producer started recording.You use the request body to send the media data. Kinesis Video Streams supports only the Matroska(MKV) container format for sending media data using this API.

You have the following options for sending data using this API:

• Send media data in real time: For example, a security camera can send frames in real time as itgenerates them. This approach minimizes the latency between the video recording and data sent onthe wire. This is referred to as a continuous producer. In this case, a consumer application can read thestream in real time or when needed.

• Send media data offline (in batches): For example, a body camera might record video for hours andstore it on the device. Later, when you connect the camera to the docking port, the camera can start aPutMedia session to send data to a Kinesis video stream. In this scenario, latency is not an issue.

When using this API, note the following considerations:

• You must specify either streamName or streamARN, but not both.• To be able to play the media on the console or via HLS, track 1 of each fragment should contain h.264

encoded video, the CodecID in the fragment metadata should be "V_MPEG/ISO/AVC", and the fragmentmetadata should include AVCC formatted h.264 codec private data. Optionally, track 2 of each fragmentshould contain AAC encoded audio, the CodecID in the fragment metadata should be "A_AAC", and thefragment metadata should include AAC codec private data.

• You might find it easier to use a single long-running PutMedia session and send a large number ofmedia data fragments in the payload. For each fragment received, Kinesis Video Streams sends oneor more acknowledgements. Potential network considerations might cause you to not get all theseacknowledgements as they are generated.

• You might choose multiple consecutive PutMedia sessions, each with fewer fragments to ensure thatyou get all acknowledgements from the service in real time.

Note

If you send data to the same stream on multiple simultaneous PutMedia sessions, the mediafragments get interleaved on the stream. You should make sure that this is OK in your applicationscenario.

The following limits apply when using the PutMedia API:

• A client can call PutMedia up to five times per second per stream.• A client can send up to five fragments per second per stream.• Kinesis Video Streams reads media data at a rate of up to 12.5 MB/second, or 100 Mbps during aPutMedia session.

Note the following constraints. In these cases, Kinesis Video Streams sends the Error acknowledgement inthe response.

255

Page 262: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams Media

• Fragments that have time codes spanning longer than 10 seconds and that contain more than 50 MB ofdata are not allowed.

• Fragments containing more than three tracks are not allowed. Each frame in every fragment must havethe same track number as one of the tracks defined in the fragment header. Additionally, every fragmentmust contain at least one frame for each track defined in the fragment header.

• Each fragment must contain at least one frame for each track defined in the fragment metadata.• The earliest frame timestamp in a fragment must be after the latest frame timestamp in the previous

fragment.• An MKV stream containing more than one MKV segment or containing disallowed MKV elements (liketrack*) also results in the Error acknowledgement.

Kinesis Video Streams stores each incoming fragment and related metadata in what is called a "chunk."The fragment metadata includes the following:

• The MKV headers provided at the start of the PutMedia request• The following Kinesis Video Streams-specific metadata for the fragment:

• server_timestamp - Timestamp when Kinesis Video Streams started receiving the fragment.• producer_timestamp - Timestamp, when the producer started recording the fragment. Kinesis

Video Streams uses three pieces of information received in the request to calculate this value.• The fragment timecode value received in the request body along with the fragment.• Two request headers: producerStartTimestamp (when the producer started recording) andfragmentTimeCodeType (whether the fragment timecode in the payload is absolute or relative).

Kinesis Video Streams then computes the producer_timestamp for the fragment as follows:

If fragmentTimeCodeType is relative, then

producer_timestamp = producerStartTimeStamp + fragment timecode

If fragmentTimeCodeType is absolute, then

producer_timestamp = fragment timecode (converted to milliseconds)• Unique fragment number assigned by Kinesis Video Streams.

Note

When you make the GetMedia request, Kinesis Video Streams returns a stream of these chunks.The client can process the metadata as needed.

Note

This operation is only available for the AWS SDK for Java. It is not supported in AWS SDKs forother languages.

Note

Kinesis Video Streams does not parse and validate the codec private data during ingestion andarchival via the PutMedia API. KVS extracts and validates the necessary information from thecodec private data for MPEG-TS and MP4 fragment packaging when consuming the stream viathe HLS APIs.

Note

If an error is thrown after invoking a Kinesis Video Streams media API, in addition to the HTTPstatus code and the response body, it includes the following pieces of information:

256

Page 263: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams Media

• x-amz-ErrorType HTTP header – contains a more specific error type in addition to what theHTTP status code provides.

• x-amz-RequestId HTTP header – if you want to report an issue to AWS, the support team canbetter diagnose the problem if given the Request Id.

Both the HTTP status code and the ErrorType header can be utilized to make programmaticdecisions about whether errors are retry-able and under what conditions, as well as provideinformation on what actions the client programmer might need to take in order to successfully tryagain.For more information, see the Errors section at the bottom of this topic, as well as Common Errors.

Request Syntax

POST /putMedia HTTP/1.1x-amzn-stream-name: StreamNamex-amzn-stream-arn: StreamARNx-amzn-fragment-timecode-type: FragmentTimecodeTypex-amzn-producer-start-timestamp: ProducerStartTimestamp

Payload

URI Request Parameters

The request requires the following URI parameters.

FragmentTimecodeType (p. 257)

You pass this value as the x-amzn-fragment-timecode-type HTTP header.

Indicates whether timecodes in the fragments (payload, HTTP request body) are absolute or relativeto producerStartTimestamp. Kinesis Video Streams uses this information to compute theproducer_timestamp for the fragment received in the request, as described in the API overview.

Valid Values: ABSOLUTE | RELATIVEProducerStartTimestamp (p. 257)

You pass this value as the x-amzn-producer-start-timestamp HTTP header.

This is the producer timestamp at which the producer started recording the media (not the timestamp ofthe specific fragments in the request).

StreamARN (p. 257)

You pass this value as the x-amzn-stream-arn HTTP header.

Amazon Resource Name (ARN) of the Kinesis video stream where you want to write the mediacontent. If you don't specify the streamARN, you must specify the streamName.

Length Constraints: Minimum length of 1. Maximum length of 1024.

Pattern: arn:aws:kinesisvideo:[a-z0-9-]+:[0-9]+:[a-z]+/[a-zA-Z0-9_.-]+/[0-9]+StreamName (p. 257)

You pass this value as the x-amzn-stream-name HTTP header.

Name of the Kinesis video stream where you want to write the media content. If you don't specify thestreamName, you must specify the streamARN.

257

Page 264: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams Media

Length Constraints: Minimum length of 1. Maximum length of 256.

Pattern: [a-zA-Z0-9_.-]+

Request Body

The request accepts the following binary data.

Payload (p. 257)

The media content to write to the Kinesis video stream. In the current implementation, Kinesis VideoStreams supports only the Matroska (MKV) container format with a single MKV segment. A segmentcan contain one or more clusters.

Note

Each MKV cluster maps to a Kinesis video stream fragment. Whatever cluster duration youchoose becomes the fragment duration.

Response Syntax

HTTP/1.1 200

Payload

Response Elements

If the action is successful, the service sends back an HTTP 200 response.

The response returns the following as the HTTP body.

Payload (p. 258)

After Kinesis Video Streams successfully receives a PutMedia request, the service validates therequest headers. The service then starts reading the payload and first sends an HTTP 200 response.

The service then returns a stream containing a series of JSON objects (Acknowledgement objects)separated by newlines. The acknowledgements are received on the same connection on whichthe media data is sent. There can be many acknowledgements for a PutMedia request. EachAcknowledgement consists of the following key-value pairs:• AckEventType - Event type the acknowledgement represents.

• Buffering: Kinesis Video Streams has started receiving the fragment. Kinesis Video Streams sendsthe first Buffering acknowledgement when the first byte of fragment data is received.

• Received: Kinesis Video Streams received the entire fragment. If you did not configure thestream to persist the data, the producer can stop buffering the fragment upon receiving thisacknowledgement.

• Persisted: Kinesis Video Streams has persisted the fragment (for example, to Amazon S3). Youget this acknowledgement if you configured the stream to persist the data. After you receive thisacknowledgement, the producer can stop buffering the fragment.

• Error: Kinesis Video Streams ran into an error while processing the fragment. You can review theerror code and determine the next course of action.

• Idle: The PutMedia session is in-progress. However, Kinesis Video Streams is currently notreceiving data. Kinesis Video Streams sends this acknowledgement periodically for up to 30seconds after the last received data. If no data is received within the 30 seconds, Kinesis VideoStreams closes the request.

258

Page 265: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams Media

Note

This acknowledgement can help a producer determine if the PutMedia connection isalive, even if it is not sending any data.

• FragmentTimeCode - Fragment timecode for which acknowledgement is sent.

The element can be missing if the AckEventType is Idle.• FragmentNumber - Kinesis Video Streams-generated fragment number for which the

acknowledgement is sent.• ErrorId and ErrorCode - If the AckEventType is ErrorId, this field provides corresponding error

code. The following is the list of error codes:• 4000 - Error reading the data stream.• 4001 - Fragment size is greater than maximum limit, 50 MB, allowed.• 4002 - Fragment duration is greater than maximum limit, 10 seconds, allowed.• 4003 - Connection duration is greater than maximum allowed threshold.• 4004 - Fragment timecode is less than the timecode previous time code (within a PutMedia call,

you cannot send fragments out of order).• 4005 - More than one track is found in MKV. (deprecated)• 4006 - Failed to parse the input stream as valid MKV format.• 4007 - Invalid producer timestamp.• 4008 - Stream no longer exists (deleted).• 4009 - Fragment metadata limit reached.• 4010 - The track number in an MKV frame did not match the tracks in the MKV header.• 4011 - The fragment did not contain any frames for at least one of the tracks in the MKV header.• 4012 - More than the allowed number of tracks found in the input MKV.• 4500 - Access to the stream's specified KMS key is denied.• 4501 - The stream's specified KMS key is disabled.• 4502 - The stream's specified KMS key failed validation.• 4503 - The stream's specified KMS key is unavailable.• 4504 - Invalid usage of the stream's specified KMS key.• 4505 - The stream's specified KMS key is in an invalid state.• 4506 - The stream's specified KMS key is not found.• 5000 - Internal service error• 5001 - Kinesis Video Streams failed to persist fragments to the data store.

Note

The producer, while sending the payload for a long running PutMedia request, should readthe response for acknowledgements. A producer might receive chunks of acknowledgementsat the same time, due to buffering on an intermediate proxy server. A producer that wants toreceive timely acknowledgements can send fewer fragments in each PutMedia request.

Errors

For information about the errors that are common to all actions, see Common Errors (p. 311).

ClientLimitExceededException

Kinesis Video Streams has throttled the request because you have exceeded the limit of allowed clientcalls. Try making the call later.

259

Page 266: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams Media

HTTP Status Code: 400ConnectionLimitExceededException

Kinesis Video Streams has throttled the request because you have exceeded the limit of allowed clientconnections.

HTTP Status Code: 400InvalidArgumentException

The value for this input parameter is invalid.

HTTP Status Code: 400InvalidEndpointException

Caller used wrong endpoint to write data to a stream. On receiving such an exception, the user mustcall GetDataEndpoint with APIName set to PUT_MEDIA and use the endpoint from response toinvoke the next PutMedia call.

HTTP Status Code: 400NotAuthorizedException

The caller is not authorized to perform an operation on the given stream, or the token has expired.

HTTP Status Code: 401ResourceNotFoundException

Status Code: 404, The stream with the given name does not exist.

HTTP Status Code: 404

Example

Acknowledgement Format

The format of the acknowledgement is as follows:

{ Acknowledgement : { "EventType": enum "FragmentTimecode": Long, "FragmentNumber": Long, "ErrorId" : String }}

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS Command Line Interface• AWS SDK for .NET• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java

260

Page 267: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams Archived Media

• AWS SDK for JavaScript• AWS SDK for PHP V3• AWS SDK for Python• AWS SDK for Ruby V3

Amazon Kinesis Video Streams Archived MediaThe following actions are supported by Amazon Kinesis Video Streams Archived Media:

• GetClip (p. 262)• GetDASHStreamingSessionURL (p. 266)• GetHLSStreamingSessionURL (p. 273)• GetMediaForFragmentList (p. 281)• ListFragments (p. 284)

261

Page 268: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams Archived Media

GetClipService: Amazon Kinesis Video Streams Archived Media

Downloads an MP4 file (clip) containing the archived, on-demand media from the specified video streamover the specified time range.

Both the StreamName and the StreamARN parameters are optional, but you must specify either theStreamName or the StreamARN when invoking this API operation.

As a prerequsite to using GetCLip API, you must obtain an endpoint using GetDataEndpoint, specifyingGET_CLIP for the APIName parameter.

An Amazon Kinesis video stream has the following requirements for providing data through MP4:

• The media must contain h.264 or h.265 encoded video and, optionally, AAC or G.711 encoded audio.Specifically, the codec ID of track 1 should be V_MPEG/ISO/AVC (for h.264) or V_MPEGH/ISO/HEVC(for H.265). Optionally, the codec ID of track 2 should be A_AAC (for AAC) or A_MS/ACM (for G.711).

• Data retention must be greater than 0.• The video track of each fragment must contain codec private data in the Advanced Video Coding (AVC)

for H.264 format and HEVC for H.265 format. For more information, see MPEG-4 specification ISO/IEC14496-15. For information about adapting stream data to a given format, see NAL Adaptation Flags.

• The audio track (if present) of each fragment must contain codec private data in the AAC format (AACspecification ISO/IEC 13818-7) or the MS Wave format.

You can monitor the amount of outgoing data by monitoring the GetClip.OutgoingBytes AmazonCloudWatch metric. For information about using CloudWatch to monitor Kinesis Video Streams, seeMonitoring Kinesis Video Streams. For pricing information, see Amazon Kinesis Video Streams Pricing andAWS Pricing. Charges for outgoing AWS data apply.

Request Syntax

POST /getClip HTTP/1.1Content-type: application/json

{ "ClipFragmentSelector": { "FragmentSelectorType": "string", "TimestampRange": { "EndTimestamp": number, "StartTimestamp": number } }, "StreamARN": "string", "StreamName": "string"}

URI Request Parameters

The request does not use any URI parameters.

Request Body

The request accepts the following data in JSON format.

ClipFragmentSelector (p. 262)

The time range of the requested clip and the source of the timestamps.

262

Page 269: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams Archived Media

Type: ClipFragmentSelector (p. 301) object

Required: YesStreamARN (p. 262)

The Amazon Resource Name (ARN) of the stream for which to retrieve the media clip.

You must specify either the StreamName or the StreamARN.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 1024.

Pattern: arn:aws:kinesisvideo:[a-z0-9-]+:[0-9]+:[a-z]+/[a-zA-Z0-9_.-]+/[0-9]+

Required: NoStreamName (p. 262)

The name of the stream for which to retrieve the media clip.

You must specify either the StreamName or the StreamARN.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 256.

Pattern: [a-zA-Z0-9_.-]+

Required: No

Response Syntax

HTTP/1.1 200Content-Type: ContentType

Payload

Response Elements

If the action is successful, the service sends back an HTTP 200 response.

The response returns the following HTTP headers.

ContentType (p. 263)

The content type of the media in the requested clip.

Length Constraints: Minimum length of 1. Maximum length of 128.

Pattern: ^[a-zA-Z0-9_\.\-]+$

The response returns the following as the HTTP body.

Payload (p. 263)

Traditional MP4 file that contains the media clip from the specified video stream. The output will containthe first 100 MB or the first 200 fragments from the specified start timestamp. For more information, seeKinesis Video Streams Limits.

263

Page 270: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams Archived Media

ErrorsFor information about the errors that are common to all actions, see Common Errors (p. 311).

ClientLimitExceededException

Kinesis Video Streams has throttled the request because you have exceeded the limit of allowed clientcalls. Try making the call later.

HTTP Status Code: 400InvalidArgumentException

A specified parameter exceeds its restrictions, is not supported, or can't be used.

HTTP Status Code: 400InvalidCodecPrivateDataException

The codec private data in at least one of the tracks of the video stream is not valid for this operation.

HTTP Status Code: 400InvalidMediaFrameException

One or more frames in the requested clip could not be parsed based on the specified codec.

HTTP Status Code: 400MissingCodecPrivateDataException

No codec private data was found in at least one of tracks of the video stream.

HTTP Status Code: 400NoDataRetentionException

A streaming session was requested for a stream that does not retain data (that is, has aDataRetentionInHours of 0).

HTTP Status Code: 400NotAuthorizedException

Status Code: 403, The caller is not authorized to perform an operation on the given stream, or thetoken has expired.

HTTP Status Code: 401ResourceNotFoundException

GetMedia throws this error when Kinesis Video Streams can't find the stream that you specified.

GetHLSStreamingSessionURL and GetDASHStreamingSessionURL throw this error if asession with a PlaybackMode of ON_DEMAND or LIVE_REPLAYis requested for a stream that has nofragments within the requested time range, or if a session with a PlaybackMode of LIVE is requestedfor a stream that has no fragments within the last 30 seconds.

HTTP Status Code: 404UnsupportedStreamMediaTypeException

The type of the media (for example, h.264 or h.265 video or ACC or G.711 audio) could not bedetermined from the codec IDs of the tracks in the first fragment for a playback session. The codec IDfor track 1 should be V_MPEG/ISO/AVC and, optionally, the codec ID for track 2 should be A_AAC.

HTTP Status Code: 400

264

Page 272: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams Archived Media

GetDASHStreamingSessionURLService: Amazon Kinesis Video Streams Archived Media

Retrieves an MPEG Dynamic Adaptive Streaming over HTTP (DASH) URL for the stream. You can thenopen the URL in a media player to view the stream contents.

Both the StreamName and the StreamARN parameters are optional, but you must specify either theStreamName or the StreamARN when invoking this API operation.

An Amazon Kinesis video stream has the following requirements for providing data through MPEG-DASH:

• The media must contain h.264 or h.265 encoded video and, optionally, AAC or G.711 encoded audio.Specifically, the codec ID of track 1 should be V_MPEG/ISO/AVC (for h.264) or V_MPEGH/ISO/HEVC(for H.265). Optionally, the codec ID of track 2 should be A_AAC (for AAC) or A_MS/ACM (for G.711).

• Data retention must be greater than 0.• The video track of each fragment must contain codec private data in the Advanced Video Coding (AVC)

for H.264 format and HEVC for H.265 format. For more information, see MPEG-4 specification ISO/IEC14496-15. For information about adapting stream data to a given format, see NAL Adaptation Flags.

• The audio track (if present) of each fragment must contain codec private data in the AAC format (AACspecification ISO/IEC 13818-7) or the MS Wave format.

The following procedure shows how to use MPEG-DASH with Kinesis Video Streams:

1. Get an endpoint using GetDataEndpoint, specifying GET_DASH_STREAMING_SESSION_URL for theAPIName parameter.

2. Retrieve the MPEG-DASH URL using GetDASHStreamingSessionURL. Kinesis Video Streamscreates an MPEG-DASH streaming session to be used for accessing content in a stream using theMPEG-DASH protocol. GetDASHStreamingSessionURL returns an authenticated URL (that includesan encrypted session token) for the session's MPEG-DASH manifest (the root resource needed forstreaming with MPEG-DASH).

Note

Don't share or store this token where an unauthorized entity could access it. The token providesaccess to the content of the stream. Safeguard the token with the same measures that youwould use with your AWS credentials.

The media that is made available through the manifest consists only of the requested stream, timerange, and format. No other media data (such as frames outside the requested window or alternatebitrates) is made available.

3. Provide the URL (containing the encrypted session token) for the MPEG-DASH manifest to a mediaplayer that supports the MPEG-DASH protocol. Kinesis Video Streams makes the initialization fragmentand media fragments available through the manifest URL. The initialization fragment contains the codecprivate data for the stream, and other data needed to set up the video or audio decoder and renderer.The media fragments contain encoded video frames or encoded audio samples.

4. The media player receives the authenticated URL and requests stream metadata and media datanormally. When the media player requests data, it calls the following actions:• GetDASHManifest: Retrieves an MPEG DASH manifest, which contains the metadata for the media

that you want to playback.• GetMP4InitFragment: Retrieves the MP4 initialization fragment. The media player typically loads the

initialization fragment before loading any media fragments. This fragment contains the "fytp" and"moov" MP4 atoms, and the child atoms that are needed to initialize the media player decoder.

The initialization fragment does not correspond to a fragment in a Kinesis video stream. It containsonly the codec private data for the stream and respective track, which the media player needs todecode the media frames.

266

Page 273: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams Archived Media

• GetMP4MediaFragment: Retrieves MP4 media fragments. These fragments contain the "moof" and"mdat" MP4 atoms and their child atoms, containing the encoded fragment's media frames and theirtimestamps.

Note

After the first media fragment is made available in a streaming session, any fragments thatdon't contain the same codec private data cause an error to be returned when those differentmedia fragments are loaded. Therefore, the codec private data should not change betweenfragments in a session. This also means that the session fails if the fragments in a streamchange from having only video to having both audio and video.

Data retrieved with this action is billable. See Pricing for details.

Note

The following restrictions apply to MPEG-DASH sessions:

• A streaming session URL should not be shared between players. The service might throttle asession if multiple media players are sharing it. For connection limits, see Kinesis Video StreamsLimits.

• A Kinesis video stream can have a maximum of ten active MPEG-DASH streaming sessions. Ifa new session is created when the maximum number of sessions is already active, the oldest(earliest created) session is closed. The number of active GetMedia connections on a Kinesisvideo stream does not count against this limit, and the number of active MPEG-DASH sessionsdoes not count against the active GetMedia connection limit.

Note

The maximum limits for active HLS and MPEG-DASH streaming sessions areindependent of each other.

You can monitor the amount of data that the media player consumes by monitoring theGetMP4MediaFragment.OutgoingBytes Amazon CloudWatch metric. For information about usingCloudWatch to monitor Kinesis Video Streams, see Monitoring Kinesis Video Streams. For pricinginformation, see Amazon Kinesis Video Streams Pricing and AWS Pricing. Charges for both HLS sessionsand outgoing AWS data apply.

For more information about HLS, see HTTP Live Streaming on the Apple Developer site.

Important

If an error is thrown after invoking a Kinesis Video Streams archived media API, in addition to theHTTP status code and the response body, it includes the following pieces of information:

• x-amz-ErrorType HTTP header – contains a more specific error type in addition to what theHTTP status code provides.

• x-amz-RequestId HTTP header – if you want to report an issue to AWS, the support team canbetter diagnose the problem if given the Request Id.

Both the HTTP status code and the ErrorType header can be utilized to make programmaticdecisions about whether errors are retry-able and under what conditions, as well as provideinformation on what actions the client programmer might need to take in order to successfully tryagain.For more information, see the Errors section at the bottom of this topic, as well as Common Errors.

267

Page 274: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams Archived Media

Request Syntax

POST /getDASHStreamingSessionURL HTTP/1.1Content-type: application/json

{ "DASHFragmentSelector": { "FragmentSelectorType": "string", "TimestampRange": { "EndTimestamp": number, "StartTimestamp": number } }, "DisplayFragmentNumber": "string", "DisplayFragmentTimestamp": "string", "Expires": number, "MaxManifestFragmentResults": number, "PlaybackMode": "string", "StreamARN": "string", "StreamName": "string"}

URI Request ParametersThe request does not use any URI parameters.

Request BodyThe request accepts the following data in JSON format.

DASHFragmentSelector (p. 268)

The time range of the requested fragment and the source of the timestamps.

This parameter is required if PlaybackMode is ON_DEMAND or LIVE_REPLAY. This parameter isoptional if PlaybackMode is LIVE. If PlaybackMode is LIVE, the FragmentSelectorType can beset, but the TimestampRange should not be set. If PlaybackMode is ON_DEMAND or LIVE_REPLAY,both FragmentSelectorType and TimestampRange must be set.

Type: DASHFragmentSelector (p. 303) object

Required: NoDisplayFragmentNumber (p. 268)

Fragments are identified in the manifest file based on their sequence number in the session. IfDisplayFragmentNumber is set to ALWAYS, the Kinesis Video Streams fragment number is added toeach S element in the manifest file with the attribute name “kvs:fn”. These fragment numbers can beused for logging or for use with other APIs (e.g. GetMedia and GetMediaForFragmentList). Acustom MPEG-DASH media player is necessary to leverage these this custom attribute.

The default value is NEVER.

Type: String

Valid Values: ALWAYS | NEVER

Required: NoDisplayFragmentTimestamp (p. 268)

Per the MPEG-DASH specification, the wall-clock time of fragments in the manifest file can be derivedusing attributes in the manifest itself. However, typically, MPEG-DASH compatible media players do

268

Page 275: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams Archived Media

not properly handle gaps in the media timeline. Kinesis Video Streams adjusts the media timeline inthe manifest file to enable playback of media with discontinuities. Therefore, the wall-clock time derivedfrom the manifest file may be inaccurate. If DisplayFragmentTimestamp is set to ALWAYS, the accuratefragment timestamp is added to each S element in the manifest file with the attribute name “kvs:ts”. Acustom MPEG-DASH media player is necessary to leverage this custom attribute.

The default value is NEVER. When DASHFragmentSelector (p. 303) is SERVER_TIMESTAMP, thetimestamps will be the server start timestamps. Similarly, when DASHFragmentSelector (p. 303) isPRODUCER_TIMESTAMP, the timestamps will be the producer start timestamps.

Type: String

Valid Values: ALWAYS | NEVER

Required: NoExpires (p. 268)

The time in seconds until the requested session expires. This value can be between 300 (5 minutes)and 43200 (12 hours).

When a session expires, no new calls to GetDashManifest, GetMP4InitFragment, orGetMP4MediaFragment can be made for that session.

The default is 300 (5 minutes).

Type: Integer

Valid Range: Minimum value of 300. Maximum value of 43200.

Required: NoMaxManifestFragmentResults (p. 268)

The maximum number of fragments that are returned in the MPEG-DASH manifest.

When the PlaybackMode is LIVE, the most recent fragments are returned up to this value. When thePlaybackMode is ON_DEMAND, the oldest fragments are returned, up to this maximum number.

When there are a higher number of fragments available in a live MPEG-DASH manifest, video playersoften buffer content before starting playback. Increasing the buffer size increases the playback latency,but it decreases the likelihood that rebuffering will occur during playback. We recommend that a liveMPEG-DASH manifest have a minimum of 3 fragments and a maximum of 10 fragments.

The default is 5 fragments if PlaybackMode is LIVE or LIVE_REPLAY, and 1,000 if PlaybackModeis ON_DEMAND.

The maximum value of 1,000 fragments corresponds to more than 16 minutes of video on streams with1-second fragments, and more than 2 1/2 hours of video on streams with 10-second fragments.

Type: Long

Valid Range: Minimum value of 1. Maximum value of 1000.

Required: NoPlaybackMode (p. 268)

Whether to retrieve live, live replay, or archived, on-demand data.

Features of the three types of sessions include the following:• LIVE : For sessions of this type, the MPEG-DASH manifest is continually updated with the latest

fragments as they become available. We recommend that the media player retrieve a new manifest

269

Page 276: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams Archived Media

on a one-second interval. When this type of session is played in a media player, the user interfacetypically displays a "live" notification, with no scrubber control for choosing the position in theplayback window to display.

Note

In LIVE mode, the newest available fragments are included in an MPEG-DASH manifest,even if there is a gap between fragments (that is, if a fragment is missing). A gap like thismight cause a media player to halt or cause a jump in playback. In this mode, fragments arenot added to the MPEG-DASH manifest if they are older than the newest fragment in theplaylist. If the missing fragment becomes available after a subsequent fragment is added tothe manifest, the older fragment is not added, and the gap is not filled.

• LIVE_REPLAY : For sessions of this type, the MPEG-DASH manifest is updated similarly to howit is updated for LIVE mode except that it starts by including fragments from a given start time.Instead of fragments being added as they are ingested, fragments are added as the duration ofthe next fragment elapses. For example, if the fragments in the session are two seconds long,then a new fragment is added to the manifest every two seconds. This mode is useful to be able tostart playback from when an event is detected and continue live streaming media that has not yetbeen ingested as of the time of the session creation. This mode is also useful to stream previouslyarchived media without being limited by the 1,000 fragment limit in the ON_DEMAND mode.

• ON_DEMAND : For sessions of this type, the MPEG-DASH manifest contains all the fragments forthe session, up to the number that is specified in MaxMediaPlaylistFragmentResults. Themanifest must be retrieved only once for each session. When this type of session is played in amedia player, the user interface typically displays a scrubber control for choosing the position in theplayback window to display.

In all playback modes, if FragmentSelectorType is PRODUCER_TIMESTAMP, and if there aremultiple fragments with the same start timestamp, the fragment that has the larger fragment number(that is, the newer fragment) is included in the MPEG-DASH manifest. The other fragments are notincluded. Fragments that have different timestamps but have overlapping durations are still included inthe MPEG-DASH manifest. This can lead to unexpected behavior in the media player.

The default is LIVE.

Type: String

Valid Values: LIVE | LIVE_REPLAY | ON_DEMAND

Required: NoStreamARN (p. 268)

The Amazon Resource Name (ARN) of the stream for which to retrieve the MPEG-DASH manifestURL.

You must specify either the StreamName or the StreamARN.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 1024.

Pattern: arn:aws:kinesisvideo:[a-z0-9-]+:[0-9]+:[a-z]+/[a-zA-Z0-9_.-]+/[0-9]+

Required: NoStreamName (p. 268)

The name of the stream for which to retrieve the MPEG-DASH manifest URL.

You must specify either the StreamName or the StreamARN.

Type: String

270

Page 277: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams Archived Media

Length Constraints: Minimum length of 1. Maximum length of 256.

Pattern: [a-zA-Z0-9_.-]+

Required: No

Response Syntax

HTTP/1.1 200Content-type: application/json

{ "DASHStreamingSessionURL": "string"}

Response Elements

If the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

DASHStreamingSessionURL (p. 271)

The URL (containing the session token) that a media player can use to retrieve the MPEG-DASHmanifest.

Type: String

Errors

For information about the errors that are common to all actions, see Common Errors (p. 311).

ClientLimitExceededException

Kinesis Video Streams has throttled the request because you have exceeded the limit of allowed clientcalls. Try making the call later.

HTTP Status Code: 400InvalidArgumentException

A specified parameter exceeds its restrictions, is not supported, or can't be used.

HTTP Status Code: 400InvalidCodecPrivateDataException

The codec private data in at least one of the tracks of the video stream is not valid for this operation.

HTTP Status Code: 400MissingCodecPrivateDataException

No codec private data was found in at least one of tracks of the video stream.

HTTP Status Code: 400NoDataRetentionException

A streaming session was requested for a stream that does not retain data (that is, has aDataRetentionInHours of 0).

271

Page 278: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams Archived Media

HTTP Status Code: 400NotAuthorizedException

Status Code: 403, The caller is not authorized to perform an operation on the given stream, or thetoken has expired.

HTTP Status Code: 401ResourceNotFoundException

GetMedia throws this error when Kinesis Video Streams can't find the stream that you specified.

GetHLSStreamingSessionURL and GetDASHStreamingSessionURL throw this error if asession with a PlaybackMode of ON_DEMAND or LIVE_REPLAYis requested for a stream that has nofragments within the requested time range, or if a session with a PlaybackMode of LIVE is requestedfor a stream that has no fragments within the last 30 seconds.

HTTP Status Code: 404UnsupportedStreamMediaTypeException

The type of the media (for example, h.264 or h.265 video or ACC or G.711 audio) could not bedetermined from the codec IDs of the tracks in the first fragment for a playback session. The codec IDfor track 1 should be V_MPEG/ISO/AVC and, optionally, the codec ID for track 2 should be A_AAC.

HTTP Status Code: 400

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS Command Line Interface• AWS SDK for .NET• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for JavaScript• AWS SDK for PHP V3• AWS SDK for Python• AWS SDK for Ruby V3

272

Page 279: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams Archived Media

GetHLSStreamingSessionURLService: Amazon Kinesis Video Streams Archived Media

Retrieves an HTTP Live Streaming (HLS) URL for the stream. You can then open the URL in a browser ormedia player to view the stream contents.

Both the StreamName and the StreamARN parameters are optional, but you must specify either theStreamName or the StreamARN when invoking this API operation.

An Amazon Kinesis video stream has the following requirements for providing data through HLS:

• The media must contain h.264 or h.265 encoded video and, optionally, AAC encoded audio. Specifically,the codec ID of track 1 should be V_MPEG/ISO/AVC (for h.264) or V_MPEG/ISO/HEVC (for h.265).Optionally, the codec ID of track 2 should be A_AAC.

• Data retention must be greater than 0.• The video track of each fragment must contain codec private data in the Advanced Video Coding (AVC)

for H.264 format or HEVC for H.265 format (MPEG-4 specification ISO/IEC 14496-15). For informationabout adapting stream data to a given format, see NAL Adaptation Flags.

• The audio track (if present) of each fragment must contain codec private data in the AAC format (AACspecification ISO/IEC 13818-7).

Kinesis Video Streams HLS sessions contain fragments in the fragmented MPEG-4 form (also called fMP4or CMAF) or the MPEG-2 form (also called TS chunks, which the HLS specification also supports). Formore information about HLS fragment types, see the HLS specification.

The following procedure shows how to use HLS with Kinesis Video Streams:

1. Get an endpoint using GetDataEndpoint, specifying GET_HLS_STREAMING_SESSION_URL for theAPIName parameter.

2. Retrieve the HLS URL using GetHLSStreamingSessionURL. Kinesis Video Streams createsan HLS streaming session to be used for accessing content in a stream using the HLS protocol.GetHLSStreamingSessionURL returns an authenticated URL (that includes an encrypted sessiontoken) for the session's HLS master playlist (the root resource needed for streaming with HLS).

Note

Don't share or store this token where an unauthorized entity could access it. The token providesaccess to the content of the stream. Safeguard the token with the same measures that youwould use with your AWS credentials.

The media that is made available through the playlist consists only of the requested stream, time range,and format. No other media data (such as frames outside the requested window or alternate bitrates) ismade available.

3. Provide the URL (containing the encrypted session token) for the HLS master playlist to a media playerthat supports the HLS protocol. Kinesis Video Streams makes the HLS media playlist, initializationfragment, and media fragments available through the master playlist URL. The initialization fragmentcontains the codec private data for the stream, and other data needed to set up the video or audiodecoder and renderer. The media fragments contain H.264-encoded video frames or AAC-encodedaudio samples.

4. The media player receives the authenticated URL and requests stream metadata and media datanormally. When the media player requests data, it calls the following actions:• GetHLSMasterPlaylist: Retrieves an HLS master playlist, which contains a URL for theGetHLSMediaPlaylist action for each track, and additional metadata for the media player,including estimated bitrate and resolution.

• GetHLSMediaPlaylist: Retrieves an HLS media playlist, which contains a URL to access the MP4initialization fragment with the GetMP4InitFragment action, and URLs to access the MP4 media

273

Page 280: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams Archived Media

fragments with the GetMP4MediaFragment actions. The HLS media playlist also contains metadataabout the stream that the player needs to play it, such as whether the PlaybackMode is LIVEor ON_DEMAND. The HLS media playlist is typically static for sessions with a PlaybackType ofON_DEMAND. The HLS media playlist is continually updated with new fragments for sessions with aPlaybackType of LIVE. There is a distinct HLS media playlist for the video track and the audio track(if applicable) that contains MP4 media URLs for the specific track.

• GetMP4InitFragment: Retrieves the MP4 initialization fragment. The media player typically loads theinitialization fragment before loading any media fragments. This fragment contains the "fytp" and"moov" MP4 atoms, and the child atoms that are needed to initialize the media player decoder.

The initialization fragment does not correspond to a fragment in a Kinesis video stream. It containsonly the codec private data for the stream and respective track, which the media player needs todecode the media frames.

• GetMP4MediaFragment: Retrieves MP4 media fragments. These fragments contain the "moof" and"mdat" MP4 atoms and their child atoms, containing the encoded fragment's media frames and theirtimestamps.

Note

After the first media fragment is made available in a streaming session, any fragments thatdon't contain the same codec private data cause an error to be returned when those differentmedia fragments are loaded. Therefore, the codec private data should not change betweenfragments in a session. This also means that the session fails if the fragments in a streamchange from having only video to having both audio and video.

Data retrieved with this action is billable. See Pricing for details.• GetTSFragment: Retrieves MPEG TS fragments containing both initialization and media data for all

tracks in the stream.

Note

If the ContainerFormat is MPEG_TS, this API is used instead of GetMP4InitFragmentand GetMP4MediaFragment to retrieve stream media.

Data retrieved with this action is billable. For more information, see Kinesis Video Streams pricing.

Note

The following restrictions apply to HLS sessions:

• A streaming session URL should not be shared between players. The service might throttle asession if multiple media players are sharing it. For connection limits, see Kinesis Video StreamsLimits.

• A Kinesis video stream can have a maximum of ten active HLS streaming sessions. If a newsession is created when the maximum number of sessions is already active, the oldest (earliestcreated) session is closed. The number of active GetMedia connections on a Kinesis videostream does not count against this limit, and the number of active HLS sessions does not countagainst the active GetMedia connection limit.

Note

The maximum limits for active HLS and MPEG-DASH streaming sessions areindependent of each other.

You can monitor the amount of data that the media player consumes by monitoring theGetMP4MediaFragment.OutgoingBytes Amazon CloudWatch metric. For information about usingCloudWatch to monitor Kinesis Video Streams, see Monitoring Kinesis Video Streams. For pricing

274

Page 281: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams Archived Media

information, see Amazon Kinesis Video Streams Pricing and AWS Pricing. Charges for both HLS sessionsand outgoing AWS data apply.

For more information about HLS, see HTTP Live Streaming on the Apple Developer site.Important

If an error is thrown after invoking a Kinesis Video Streams archived media API, in addition to theHTTP status code and the response body, it includes the following pieces of information:

• x-amz-ErrorType HTTP header – contains a more specific error type in addition to what theHTTP status code provides.

• x-amz-RequestId HTTP header – if you want to report an issue to AWS, the support team canbetter diagnose the problem if given the Request Id.

Both the HTTP status code and the ErrorType header can be utilized to make programmaticdecisions about whether errors are retry-able and under what conditions, as well as provideinformation on what actions the client programmer might need to take in order to successfully tryagain.For more information, see the Errors section at the bottom of this topic, as well as Common Errors.

Request Syntax

POST /getHLSStreamingSessionURL HTTP/1.1Content-type: application/json

{ "ContainerFormat": "string", "DiscontinuityMode": "string", "DisplayFragmentTimestamp": "string", "Expires": number, "HLSFragmentSelector": { "FragmentSelectorType": "string", "TimestampRange": { "EndTimestamp": number, "StartTimestamp": number } }, "MaxMediaPlaylistFragmentResults": number, "PlaybackMode": "string", "StreamARN": "string", "StreamName": "string"}

URI Request ParametersThe request does not use any URI parameters.

Request BodyThe request accepts the following data in JSON format.

ContainerFormat (p. 275)

Specifies which format should be used for packaging the media. Specifying the FRAGMENTED_MP4container format packages the media into MP4 fragments (fMP4 or CMAF). This is the recommendedpackaging because there is minimal packaging overhead. The other container format option isMPEG_TS. HLS has supported MPEG TS chunks since it was released and is sometimes the onlysupported packaging on older HLS players. MPEG TS typically has a 5-25 percent packagingoverhead. This means MPEG TS typically requires 5-25 percent more bandwidth and cost than fMP4.

275

Page 282: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams Archived Media

The default is FRAGMENTED_MP4.

Type: String

Valid Values: FRAGMENTED_MP4 | MPEG_TS

Required: NoDiscontinuityMode (p. 275)

Specifies when flags marking discontinuities between fragments are added to the media playlists.

Media players typically build a timeline of media content to play, based on the timestamps ofeach fragment. This means that if there is any overlap or gap between fragments (as is typical ifHLSFragmentSelector (p. 308) is set to SERVER_TIMESTAMP), the media player timeline will alsohave small gaps between fragments in some places, and will overwrite frames in other places. Gapsin the media player timeline can cause playback to stall and overlaps can cause playback to be jittery.When there are discontinuity flags between fragments, the media player is expected to reset thetimeline, resulting in the next fragment being played immediately after the previous fragment.

The following modes are supported:• ALWAYS: a discontinuity marker is placed between every fragment in the HLS media playlist. It is

recommended to use a value of ALWAYS if the fragment timestamps are not accurate.• NEVER: no discontinuity markers are placed anywhere. It is recommended to use a value of NEVER to

ensure the media player timeline most accurately maps to the producer timestamps.• ON_DISCONTIUNITY: a discontinuity marker is placed between fragments that have a gap or

overlap of more than 50 milliseconds. For most playback scenarios, it is recommended to usea value of ON_DISCONTINUITY so that the media player timeline is only reset when there is asignificant issue with the media timeline (e.g. a missing fragment).

The default is ALWAYS when HLSFragmentSelector (p. 308) is set to SERVER_TIMESTAMP, andNEVER when it is set to PRODUCER_TIMESTAMP.

Type: String

Valid Values: ALWAYS | NEVER | ON_DISCONTINUITY

Required: NoDisplayFragmentTimestamp (p. 275)

Specifies when the fragment start timestamps should be included in the HLS media playlist. Typically,media players report the playhead position as a time relative to the start of the first fragment in theplayback session. However, when the start timestamps are included in the HLS media playlist,some media players might report the current playhead as an absolute time based on the fragmenttimestamps. This can be useful for creating a playback experience that shows viewers the wall-clocktime of the media.

The default is NEVER. When HLSFragmentSelector (p. 308) is SERVER_TIMESTAMP, thetimestamps will be the server start timestamps. Similarly, when HLSFragmentSelector (p. 308) isPRODUCER_TIMESTAMP, the timestamps will be the producer start timestamps.

Type: String

Valid Values: ALWAYS | NEVER

Required: NoExpires (p. 275)

The time in seconds until the requested session expires. This value can be between 300 (5 minutes)and 43200 (12 hours).

276

Page 283: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams Archived Media

When a session expires, no new calls to GetHLSMasterPlaylist, GetHLSMediaPlaylist,GetMP4InitFragment, GetMP4MediaFragment, or GetTSFragment can be made for that session.

The default is 300 (5 minutes).

Type: Integer

Valid Range: Minimum value of 300. Maximum value of 43200.

Required: NoHLSFragmentSelector (p. 275)

The time range of the requested fragment and the source of the timestamps.

This parameter is required if PlaybackMode is ON_DEMAND or LIVE_REPLAY. This parameter isoptional if PlaybackMode is LIVE. If PlaybackMode is LIVE, the FragmentSelectorType can beset, but the TimestampRange should not be set. If PlaybackMode is ON_DEMAND or LIVE_REPLAY,both FragmentSelectorType and TimestampRange must be set.

Type: HLSFragmentSelector (p. 308) object

Required: NoMaxMediaPlaylistFragmentResults (p. 275)

The maximum number of fragments that are returned in the HLS media playlists.

When the PlaybackMode is LIVE, the most recent fragments are returned up to this value. When thePlaybackMode is ON_DEMAND, the oldest fragments are returned, up to this maximum number.

When there are a higher number of fragments available in a live HLS media playlist, video playersoften buffer content before starting playback. Increasing the buffer size increases the playback latency,but it decreases the likelihood that rebuffering will occur during playback. We recommend that a liveHLS media playlist have a minimum of 3 fragments and a maximum of 10 fragments.

The default is 5 fragments if PlaybackMode is LIVE or LIVE_REPLAY, and 1,000 if PlaybackModeis ON_DEMAND.

The maximum value of 1,000 fragments corresponds to more than 16 minutes of video on streams with1-second fragments, and more than 2 1/2 hours of video on streams with 10-second fragments.

Type: Long

Valid Range: Minimum value of 1. Maximum value of 1000.

Required: NoPlaybackMode (p. 275)

Whether to retrieve live, live replay, or archived, on-demand data.

Features of the three types of sessions include the following:• LIVE : For sessions of this type, the HLS media playlist is continually updated with the latest

fragments as they become available. We recommend that the media player retrieve a new playliston a one-second interval. When this type of session is played in a media player, the user interfacetypically displays a "live" notification, with no scrubber control for choosing the position in theplayback window to display.

Note

In LIVE mode, the newest available fragments are included in an HLS media playlist, evenif there is a gap between fragments (that is, if a fragment is missing). A gap like this might

277

Page 284: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams Archived Media

cause a media player to halt or cause a jump in playback. In this mode, fragments are notadded to the HLS media playlist if they are older than the newest fragment in the playlist.If the missing fragment becomes available after a subsequent fragment is added to theplaylist, the older fragment is not added, and the gap is not filled.

• LIVE_REPLAY : For sessions of this type, the HLS media playlist is updated similarly to how it isupdated for LIVE mode except that it starts by including fragments from a given start time. Insteadof fragments being added as they are ingested, fragments are added as the duration of the nextfragment elapses. For example, if the fragments in the session are two seconds long, then a newfragment is added to the media playlist every two seconds. This mode is useful to be able to startplayback from when an event is detected and continue live streaming media that has not yet beeningested as of the time of the session creation. This mode is also useful to stream previouslyarchived media without being limited by the 1,000 fragment limit in the ON_DEMAND mode.

• ON_DEMAND : For sessions of this type, the HLS media playlist contains all the fragments for thesession, up to the number that is specified in MaxMediaPlaylistFragmentResults. The playlistmust be retrieved only once for each session. When this type of session is played in a media player,the user interface typically displays a scrubber control for choosing the position in the playbackwindow to display.

In all playback modes, if FragmentSelectorType is PRODUCER_TIMESTAMP, and if there aremultiple fragments with the same start timestamp, the fragment that has the larger fragment number(that is, the newer fragment) is included in the HLS media playlist. The other fragments are notincluded. Fragments that have different timestamps but have overlapping durations are still included inthe HLS media playlist. This can lead to unexpected behavior in the media player.

The default is LIVE.

Type: String

Valid Values: LIVE | LIVE_REPLAY | ON_DEMAND

Required: NoStreamARN (p. 275)

The Amazon Resource Name (ARN) of the stream for which to retrieve the HLS master playlist URL.

You must specify either the StreamName or the StreamARN.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 1024.

Pattern: arn:aws:kinesisvideo:[a-z0-9-]+:[0-9]+:[a-z]+/[a-zA-Z0-9_.-]+/[0-9]+

Required: NoStreamName (p. 275)

The name of the stream for which to retrieve the HLS master playlist URL.

You must specify either the StreamName or the StreamARN.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 256.

Pattern: [a-zA-Z0-9_.-]+

Required: No

278

Page 285: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams Archived Media

Response Syntax

HTTP/1.1 200Content-type: application/json

{ "HLSStreamingSessionURL": "string"}

Response Elements

If the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

HLSStreamingSessionURL (p. 279)

The URL (containing the session token) that a media player can use to retrieve the HLS masterplaylist.

Type: String

Errors

For information about the errors that are common to all actions, see Common Errors (p. 311).

ClientLimitExceededException

Kinesis Video Streams has throttled the request because you have exceeded the limit of allowed clientcalls. Try making the call later.

HTTP Status Code: 400InvalidArgumentException

A specified parameter exceeds its restrictions, is not supported, or can't be used.

HTTP Status Code: 400InvalidCodecPrivateDataException

The codec private data in at least one of the tracks of the video stream is not valid for this operation.

HTTP Status Code: 400MissingCodecPrivateDataException

No codec private data was found in at least one of tracks of the video stream.

HTTP Status Code: 400NoDataRetentionException

A streaming session was requested for a stream that does not retain data (that is, has aDataRetentionInHours of 0).

HTTP Status Code: 400NotAuthorizedException

Status Code: 403, The caller is not authorized to perform an operation on the given stream, or thetoken has expired.

279

Page 286: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams Archived Media

HTTP Status Code: 401ResourceNotFoundException

GetMedia throws this error when Kinesis Video Streams can't find the stream that you specified.

GetHLSStreamingSessionURL and GetDASHStreamingSessionURL throw this error if asession with a PlaybackMode of ON_DEMAND or LIVE_REPLAYis requested for a stream that has nofragments within the requested time range, or if a session with a PlaybackMode of LIVE is requestedfor a stream that has no fragments within the last 30 seconds.

HTTP Status Code: 404UnsupportedStreamMediaTypeException

The type of the media (for example, h.264 or h.265 video or ACC or G.711 audio) could not bedetermined from the codec IDs of the tracks in the first fragment for a playback session. The codec IDfor track 1 should be V_MPEG/ISO/AVC and, optionally, the codec ID for track 2 should be A_AAC.

HTTP Status Code: 400

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS Command Line Interface• AWS SDK for .NET• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for JavaScript• AWS SDK for PHP V3• AWS SDK for Python• AWS SDK for Ruby V3

280

Page 287: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams Archived Media

GetMediaForFragmentListService: Amazon Kinesis Video Streams Archived Media

Gets media for a list of fragments (specified by fragment number) from the archived data in an AmazonKinesis video stream.

Note

You must first call the GetDataEndpoint API to get an endpoint. Then send theGetMediaForFragmentList requests to this endpoint using the --endpoint-url parameter.

The following limits apply when using the GetMediaForFragmentList API:

• A client can call GetMediaForFragmentList up to five times per second per stream.• Kinesis Video Streams sends media data at a rate of up to 25 megabytes per second (or 200 megabits

per second) during a GetMediaForFragmentList session.

Important

If an error is thrown after invoking a Kinesis Video Streams archived media API, in addition to theHTTP status code and the response body, it includes the following pieces of information:

• x-amz-ErrorType HTTP header – contains a more specific error type in addition to what theHTTP status code provides.

• x-amz-RequestId HTTP header – if you want to report an issue to AWS, the support team canbetter diagnose the problem if given the Request Id.

Both the HTTP status code and the ErrorType header can be utilized to make programmaticdecisions about whether errors are retry-able and under what conditions, as well as provideinformation on what actions the client programmer might need to take in order to successfully tryagain.For more information, see the Errors section at the bottom of this topic, as well as Common Errors.

Request Syntax

POST /getMediaForFragmentList HTTP/1.1Content-type: application/json

{ "Fragments": [ "string" ], "StreamName": "string"}

URI Request ParametersThe request does not use any URI parameters.

Request BodyThe request accepts the following data in JSON format.

Fragments (p. 281)

A list of the numbers of fragments for which to retrieve media. You retrieve these values withListFragments (p. 284).

Type: Array of strings

281

Page 288: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams Archived Media

Array Members: Minimum number of 1 item. Maximum number of 1000 items.

Length Constraints: Minimum length of 1. Maximum length of 128.

Pattern: ^[0-9]+$

Required: YesStreamName (p. 281)

The name of the stream from which to retrieve fragment media.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 256.

Pattern: [a-zA-Z0-9_.-]+

Required: Yes

Response Syntax

HTTP/1.1 200Content-Type: ContentType

Payload

Response Elements

If the action is successful, the service sends back an HTTP 200 response.

The response returns the following HTTP headers.

ContentType (p. 282)

The content type of the requested media.

Length Constraints: Minimum length of 1. Maximum length of 128.

Pattern: ^[a-zA-Z0-9_\.\-]+$

The response returns the following as the HTTP body.

Payload (p. 282)

The payload that Kinesis Video Streams returns is a sequence of chunks from the specified stream.For information about the chunks, see PutMedia. The chunks that Kinesis Video Streams returns in theGetMediaForFragmentList call also include the following additional Matroska (MKV) tags:• AWS_KINESISVIDEO_FRAGMENT_NUMBER - Fragment number returned in the chunk.• AWS_KINESISVIDEO_SERVER_SIDE_TIMESTAMP - Server-side timestamp of the fragment.• AWS_KINESISVIDEO_PRODUCER_SIDE_TIMESTAMP - Producer-side timestamp of the fragment.

The following tags will be included if an exception occurs:• AWS_KINESISVIDEO_FRAGMENT_NUMBER - The number of the fragment that threw the

exception• AWS_KINESISVIDEO_EXCEPTION_ERROR_CODE - The integer code of the exception• AWS_KINESISVIDEO_EXCEPTION_MESSAGE - A text description of the exception

282

Page 289: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams Archived Media

Errors

For information about the errors that are common to all actions, see Common Errors (p. 311).

ClientLimitExceededException

Kinesis Video Streams has throttled the request because you have exceeded the limit of allowed clientcalls. Try making the call later.

HTTP Status Code: 400InvalidArgumentException

A specified parameter exceeds its restrictions, is not supported, or can't be used.

HTTP Status Code: 400NotAuthorizedException

Status Code: 403, The caller is not authorized to perform an operation on the given stream, or thetoken has expired.

HTTP Status Code: 401ResourceNotFoundException

GetMedia throws this error when Kinesis Video Streams can't find the stream that you specified.

GetHLSStreamingSessionURL and GetDASHStreamingSessionURL throw this error if asession with a PlaybackMode of ON_DEMAND or LIVE_REPLAYis requested for a stream that has nofragments within the requested time range, or if a session with a PlaybackMode of LIVE is requestedfor a stream that has no fragments within the last 30 seconds.

HTTP Status Code: 404

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS Command Line Interface• AWS SDK for .NET• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for JavaScript• AWS SDK for PHP V3• AWS SDK for Python• AWS SDK for Ruby V3

283

Page 290: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams Archived Media

ListFragmentsService: Amazon Kinesis Video Streams Archived Media

Returns a list of Fragment (p. 306) objects from the specified stream and timestamp range within thearchived data.

Listing fragments is eventually consistent. This means that even if the producer receives anacknowledgment that a fragment is persisted, the result might not be returned immediately from a requestto ListFragments. However, results are typically available in less than one second.

Note

You must first call the GetDataEndpoint API to get an endpoint. Then send theListFragments requests to this endpoint using the --endpoint-url parameter.Important

If an error is thrown after invoking a Kinesis Video Streams archived media API, in addition to theHTTP status code and the response body, it includes the following pieces of information:

• x-amz-ErrorType HTTP header – contains a more specific error type in addition to what theHTTP status code provides.

• x-amz-RequestId HTTP header – if you want to report an issue to AWS, the support team canbetter diagnose the problem if given the Request Id.

Both the HTTP status code and the ErrorType header can be utilized to make programmaticdecisions about whether errors are retry-able and under what conditions, as well as provideinformation on what actions the client programmer might need to take in order to successfully tryagain.For more information, see the Errors section at the bottom of this topic, as well as Common Errors.

Request Syntax

POST /listFragments HTTP/1.1Content-type: application/json

{ "FragmentSelector": { "FragmentSelectorType": "string", "TimestampRange": { "EndTimestamp": number, "StartTimestamp": number } }, "MaxResults": number, "NextToken": "string", "StreamName": "string"}

URI Request ParametersThe request does not use any URI parameters.

Request BodyThe request accepts the following data in JSON format.

FragmentSelector (p. 284)

Describes the timestamp range and timestamp origin for the range of fragments to return.

284

Page 291: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams Archived Media

Type: FragmentSelector (p. 307) object

Required: NoMaxResults (p. 284)

The total number of fragments to return. If the total number of fragments available is more than thevalue specified in max-results, then a ListFragments:NextToken (p. 286) is provided in the outputthat you can use to resume pagination.

Type: Long

Valid Range: Minimum value of 1. Maximum value of 1000.

Required: NoNextToken (p. 284)

A token to specify where to start paginating. This is the ListFragments:NextToken (p. 286) from apreviously truncated response.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 4096.

Pattern: [a-zA-Z0-9+/]+={0,2}

Required: NoStreamName (p. 284)

The name of the stream from which to retrieve a fragment list.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 256.

Pattern: [a-zA-Z0-9_.-]+

Required: Yes

Response Syntax

HTTP/1.1 200Content-type: application/json

{ "Fragments": [ { "FragmentLengthInMilliseconds": number, "FragmentNumber": "string", "FragmentSizeInBytes": number, "ProducerTimestamp": number, "ServerTimestamp": number } ], "NextToken": "string"}

Response Elements

If the action is successful, the service sends back an HTTP 200 response.

285

Page 292: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams Archived Media

The following data is returned in JSON format by the service.

Fragments (p. 285)

A list of archived Fragment (p. 306) objects from the stream that meet the selector criteria. Resultsare in no specific order, even across pages.

Type: Array of Fragment (p. 306) objectsNextToken (p. 285)

If the returned list is truncated, the operation returns this token to use to retrieve the next page ofresults. This value is null when there are no more results to return.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 4096.

Pattern: [a-zA-Z0-9+/]+={0,2}

Errors

For information about the errors that are common to all actions, see Common Errors (p. 311).

ClientLimitExceededException

Kinesis Video Streams has throttled the request because you have exceeded the limit of allowed clientcalls. Try making the call later.

HTTP Status Code: 400InvalidArgumentException

A specified parameter exceeds its restrictions, is not supported, or can't be used.

HTTP Status Code: 400NotAuthorizedException

Status Code: 403, The caller is not authorized to perform an operation on the given stream, or thetoken has expired.

HTTP Status Code: 401ResourceNotFoundException

GetMedia throws this error when Kinesis Video Streams can't find the stream that you specified.

GetHLSStreamingSessionURL and GetDASHStreamingSessionURL throw this error if asession with a PlaybackMode of ON_DEMAND or LIVE_REPLAYis requested for a stream that has nofragments within the requested time range, or if a session with a PlaybackMode of LIVE is requestedfor a stream that has no fragments within the last 30 seconds.

HTTP Status Code: 404

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS Command Line Interface• AWS SDK for .NET

286

Page 293: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドData Types

• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for JavaScript• AWS SDK for PHP V3• AWS SDK for Python• AWS SDK for Ruby V3

Data TypesThe following data types are supported by Amazon Kinesis Video Streams:

• ChannelInfo (p. 289)• ChannelNameCondition (p. 291)• ResourceEndpointListItem (p. 292)• SingleMasterChannelEndpointConfiguration (p. 293)• SingleMasterConfiguration (p. 294)• StreamInfo (p. 295)• StreamNameCondition (p. 297)• Tag (p. 298)

The following data types are supported by Amazon Kinesis Video Streams Media:

• StartSelector (p. 299)

The following data types are supported by Amazon Kinesis Video Streams Archived Media:

• ClipFragmentSelector (p. 301)• ClipTimestampRange (p. 302)• DASHFragmentSelector (p. 303)• DASHTimestampRange (p. 304)• Fragment (p. 306)• FragmentSelector (p. 307)• HLSFragmentSelector (p. 308)• HLSTimestampRange (p. 309)• TimestampRange (p. 311)

Amazon Kinesis Video StreamsThe following data types are supported by Amazon Kinesis Video Streams:

• ChannelInfo (p. 289)• ChannelNameCondition (p. 291)• ResourceEndpointListItem (p. 292)• SingleMasterChannelEndpointConfiguration (p. 293)• SingleMasterConfiguration (p. 294)

287

Page 294: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams

• StreamInfo (p. 295)• StreamNameCondition (p. 297)• Tag (p. 298)

288

Page 295: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams

ChannelInfoService: Amazon Kinesis Video Streams

A structure that encapsulates a signaling channel's metadata and properties.

Contents

ChannelARN

The Amazon Resource Name (ARN) of the signaling channel.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 1024.

Pattern: arn:aws:kinesisvideo:[a-z0-9-]+:[0-9]+:[a-z]+/[a-zA-Z0-9_.-]+/[0-9]+

Required: NoChannelName

The name of the signaling channel.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 256.

Pattern: [a-zA-Z0-9_.-]+

Required: NoChannelStatus

Current status of the signaling channel.

Type: String

Valid Values: CREATING | ACTIVE | UPDATING | DELETING

Required: NoChannelType

The type of the signaling channel.

Type: String

Valid Values: SINGLE_MASTER

Required: NoCreationTime

The time at which the signaling channel was created.

Type: Timestamp

Required: NoSingleMasterConfiguration

A structure that contains the configuration for the SINGLE_MASTER channel type.

Type: SingleMasterConfiguration (p. 294) object

289

Page 296: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams

Required: NoVersion

The current version of the signaling channel.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 64.

Pattern: [a-zA-Z0-9]+

Required: No

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for Ruby V3

290

Page 297: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams

ChannelNameConditionService: Amazon Kinesis Video Streams

An optional input parameter for the ListSignalingChannels API. When this parameter is specifiedwhile invoking ListSignalingChannels, the API returns only the channels that satisfy a conditionspecified in ChannelNameCondition.

Contents

ComparisonOperator

A comparison operator. Currently, you can only specify the BEGINS_WITH operator, which findssignaling channels whose names begin with a given prefix.

Type: String

Valid Values: BEGINS_WITH

Required: NoComparisonValue

A value to compare.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 256.

Pattern: [a-zA-Z0-9_.-]+

Required: No

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for Ruby V3

291

Page 298: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams

ResourceEndpointListItemService: Amazon Kinesis Video Streams

An object that describes the endpoint of the signaling channel returned by theGetSignalingChannelEndpoint API.

Contents

Protocol

The protocol of the signaling channel returned by the GetSignalingChannelEndpoint API.

Type: String

Valid Values: WSS | HTTPS

Required: NoResourceEndpoint

The endpoint of the signaling channel returned by the GetSignalingChannelEndpoint API.

Type: String

Required: No

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for Ruby V3

292

Page 299: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams

SingleMasterChannelEndpointConfigurationService: Amazon Kinesis Video Streams

An object that contains the endpoint configuration for the SINGLE_MASTER channel type.

Contents

Protocols

This property is used to determine the nature of communication over this SINGLE_MASTER signalingchannel. If WSS is specified, this API returns a websocket endpoint. If HTTPS is specified, this APIreturns an HTTPS endpoint.

Type: Array of strings

Array Members: Minimum number of 1 item. Maximum number of 5 items.

Valid Values: WSS | HTTPS

Required: NoRole

This property is used to determine messaging permissions in this SINGLE_MASTER signaling channel.If MASTER is specified, this API returns an endpoint that a client can use to receive offers from andsend answers to any of the viewers on this signaling channel. If VIEWER is specified, this API returnsan endpoint that a client can use only to send offers to another MASTER client on this signaling channel.

Type: String

Valid Values: MASTER | VIEWER

Required: No

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for Ruby V3

293

Page 300: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams

SingleMasterConfigurationService: Amazon Kinesis Video Streams

A structure that contains the configuration for the SINGLE_MASTER channel type.

Contents

MessageTtlSeconds

The period of time a signaling channel retains underlivered messages before they are discarded.

Type: Integer

Valid Range: Minimum value of 5. Maximum value of 120.

Required: No

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for Ruby V3

294

Page 301: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams

StreamInfoService: Amazon Kinesis Video Streams

An object describing a Kinesis video stream.

Contents

CreationTime

A time stamp that indicates when the stream was created.

Type: Timestamp

Required: NoDataRetentionInHours

How long the stream retains data, in hours.

Type: Integer

Valid Range: Minimum value of 0.

Required: NoDeviceName

The name of the device that is associated with the stream.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 128.

Pattern: [a-zA-Z0-9_.-]+

Required: NoKmsKeyId

The ID of the AWS Key Management Service (AWS KMS) key that Kinesis Video Streams uses toencrypt data on the stream.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 2048.

Pattern: .+

Required: NoMediaType

The MediaType of the stream.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 128.

Pattern: [\w\-\.\+]+/[\w\-\.\+]+(,[\w\-\.\+]+/[\w\-\.\+]+)*

Required: NoStatus

The status of the stream.

295

Page 302: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams

Type: String

Valid Values: CREATING | ACTIVE | UPDATING | DELETING

Required: NoStreamARN

The Amazon Resource Name (ARN) of the stream.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 1024.

Pattern: arn:aws:kinesisvideo:[a-z0-9-]+:[0-9]+:[a-z]+/[a-zA-Z0-9_.-]+/[0-9]+

Required: NoStreamName

The name of the stream.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 256.

Pattern: [a-zA-Z0-9_.-]+

Required: NoVersion

The version of the stream.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 64.

Pattern: [a-zA-Z0-9]+

Required: No

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for Ruby V3

296

Page 303: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams

StreamNameConditionService: Amazon Kinesis Video Streams

Specifies the condition that streams must satisfy to be returned when you list streams (see theListStreams API). A condition has a comparison operation and a value. Currently, you can specify onlythe BEGINS_WITH operator, which finds streams whose names start with a given prefix.

Contents

ComparisonOperator

A comparison operator. Currently, you can specify only the BEGINS_WITH operator, which findsstreams whose names start with a given prefix.

Type: String

Valid Values: BEGINS_WITH

Required: NoComparisonValue

A value to compare.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 256.

Pattern: [a-zA-Z0-9_.-]+

Required: No

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for Ruby V3

297

Page 304: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams Media

TagService: Amazon Kinesis Video Streams

A key and value pair that is associated with the specified signaling channel.

Contents

Key

The key of the tag that is associated with the specified signaling channel.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 128.

Pattern: ^([\p{L}\p{Z}\p{N}_.:/=+\-@]*)$

Required: YesValue

The value of the tag that is associated with the specified signaling channel.

Type: String

Length Constraints: Minimum length of 0. Maximum length of 256.

Pattern: [\p{L}\p{Z}\p{N}_.:/=+\-@]*

Required: Yes

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for Ruby V3

Amazon Kinesis Video Streams MediaThe following data types are supported by Amazon Kinesis Video Streams Media:

• StartSelector (p. 299)

298

Page 305: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams Media

StartSelectorService: Amazon Kinesis Video Streams Media

Identifies the chunk on the Kinesis video stream where you want the GetMedia API to start returningmedia data. You have the following options to identify the starting chunk:

• Choose the latest (or oldest) chunk.• Identify a specific chunk. You can identify a specific chunk either by providing a fragment number or

timestamp (server or producer).• Each chunk's metadata includes a continuation token as a Matroska (MKV) tag

(AWS_KINESISVIDEO_CONTINUATION_TOKEN). If your previous GetMedia request terminated, youcan use this tag value in your next GetMedia request. The API then starts returning chunks startingwhere the last API ended.

Contents

AfterFragmentNumber

Specifies the fragment number from where you want the GetMedia API to start returning thefragments.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 128.

Pattern: ^[0-9]+$

Required: NoContinuationToken

Continuation token that Kinesis Video Streams returned in the previous GetMedia response. TheGetMedia API then starts with the chunk identified by the continuation token.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 128.

Pattern: ^[a-zA-Z0-9_\.\-]+$

Required: NoStartSelectorType

Identifies the fragment on the Kinesis video stream where you want to start getting the data from.• NOW - Start with the latest chunk on the stream.• EARLIEST - Start with earliest available chunk on the stream.• FRAGMENT_NUMBER - Start with the chunk after a specific fragment. You must also specify theAfterFragmentNumber parameter.

• PRODUCER_TIMESTAMP or SERVER_TIMESTAMP - Start with the chunk containing afragment with the specified producer or server timestamp. You specify the timestamp by addingStartTimestamp.

• CONTINUATION_TOKEN - Read using the specified continuation token.

Note

If you choose the NOW, EARLIEST, or CONTINUATION_TOKEN as thestartSelectorType, you don't provide any additional information in the startSelector.

299

Page 306: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams Archived Media

Type: String

Valid Values: FRAGMENT_NUMBER | SERVER_TIMESTAMP | PRODUCER_TIMESTAMP | NOW |EARLIEST | CONTINUATION_TOKEN

Required: YesStartTimestamp

A timestamp value. This value is required if you choose the PRODUCER_TIMESTAMP or theSERVER_TIMESTAMP as the startSelectorType. The GetMedia API then starts with the chunkcontaining the fragment that has the specified timestamp.

Type: Timestamp

Required: No

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for Ruby V3

Amazon Kinesis Video Streams Archived MediaThe following data types are supported by Amazon Kinesis Video Streams Archived Media:

• ClipFragmentSelector (p. 301)• ClipTimestampRange (p. 302)• DASHFragmentSelector (p. 303)• DASHTimestampRange (p. 304)• Fragment (p. 306)• FragmentSelector (p. 307)• HLSFragmentSelector (p. 308)• HLSTimestampRange (p. 309)• TimestampRange (p. 311)

300

Page 307: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams Archived Media

ClipFragmentSelectorService: Amazon Kinesis Video Streams Archived Media

Describes the timestamp range and timestamp origin of a range of fragments.

Fragments that have duplicate producer timestamps are deduplicated. This means that if producers areproducing a stream of fragments with producer timestamps that are approximately equal to the true clocktime, the clip will contain all of the fragments within the requested timestamp range. If some fragments areingested within the same time range and very different points in time, only the oldest ingested collection offragments are returned.

Contents

FragmentSelectorType

The origin of the timestamps to use (Server or Producer).

Type: String

Valid Values: PRODUCER_TIMESTAMP | SERVER_TIMESTAMP

Required: YesTimestampRange

The range of timestamps to return.

Type: ClipTimestampRange (p. 302) object

Required: Yes

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for Ruby V3

301

Page 308: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams Archived Media

ClipTimestampRangeService: Amazon Kinesis Video Streams Archived Media

The range of timestamps for which to return fragments.

The values in the ClipTimestampRange are inclusive. Fragments that begin before the start timebut continue past it, or fragments that begin before the end time but continue past it, are included in thesession.

Contents

EndTimestamp

The end of the timestamp range for the requested media.

This value must be within 3 hours of the specified StartTimestamp, and it must be later than theStartTimestamp value. If FragmentSelectorType for the request is SERVER_TIMESTAMP, thisvalue must be in the past.

This value is inclusive. The EndTimestamp is compared to the (starting) timestamp of the fragment.Fragments that start before the EndTimestamp value and continue past it are included in the session.

Type: Timestamp

Required: YesStartTimestamp

The starting timestamp in the range of timestamps for which to return fragments.

This value is inclusive. Fragments that start before the StartTimestamp and continue past it areincluded in the session. If FragmentSelectorType is SERVER_TIMESTAMP, the StartTimestampmust be later than the stream head.

Type: Timestamp

Required: Yes

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for Ruby V3

302

Page 309: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams Archived Media

DASHFragmentSelectorService: Amazon Kinesis Video Streams Archived Media

Contains the range of timestamps for the requested media, and the source of the timestamps.

Contents

FragmentSelectorType

The source of the timestamps for the requested media.

When FragmentSelectorType is set to PRODUCER_TIMESTAMP andGetDASHStreamingSessionURL:PlaybackMode (p. 269) is ON_DEMAND orLIVE_REPLAY, the first fragment ingested with a producer timestamp within the specifiedFragmentSelector:TimestampRange (p. 307) is included in the media playlist. In addition, thefragments with producer timestamps within the TimestampRange ingested immediately following thefirst fragment (up to the GetDASHStreamingSessionURL:MaxManifestFragmentResults (p. 269) value)are included.

Fragments that have duplicate producer timestamps are deduplicated. This means that if producersare producing a stream of fragments with producer timestamps that are approximately equal to the trueclock time, the MPEG-DASH manifest will contain all of the fragments within the requested timestamprange. If some fragments are ingested within the same time range and very different points in time, onlythe oldest ingested collection of fragments are returned.

When FragmentSelectorType is set to PRODUCER_TIMESTAMP andGetDASHStreamingSessionURL:PlaybackMode (p. 269) is LIVE, the producer timestamps are usedin the MP4 fragments and for deduplication. But the most recently ingested fragments based on servertimestamps are included in the MPEG-DASH manifest. This means that even if fragments ingested inthe past have producer timestamps with values now, they are not included in the HLS media playlist.

The default is SERVER_TIMESTAMP.

Type: String

Valid Values: PRODUCER_TIMESTAMP | SERVER_TIMESTAMP

Required: NoTimestampRange

The start and end of the timestamp range for the requested media.

This value should not be present if PlaybackType is LIVE.

Type: DASHTimestampRange (p. 304) object

Required: No

See AlsoFor more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for Ruby V3

303

Page 310: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams Archived Media

DASHTimestampRangeService: Amazon Kinesis Video Streams Archived Media

The start and end of the timestamp range for the requested media.

This value should not be present if PlaybackType is LIVE.

Note

The values in the DASHimestampRange are inclusive. Fragments that begin before the start timebut continue past it, or fragments that begin before the end time but continue past it, are includedin the session.

Contents

EndTimestamp

The end of the timestamp range for the requested media. This value must be within 3 hours of thespecified StartTimestamp, and it must be later than the StartTimestamp value.

If FragmentSelectorType for the request is SERVER_TIMESTAMP, this value must be in the past.

The EndTimestamp value is required for ON_DEMAND mode, but optional for LIVE_REPLAY mode. Ifthe EndTimestamp is not set for LIVE_REPLAY mode then the session will continue to include newlyingested fragments until the session expires.

Note

This value is inclusive. The EndTimestamp is compared to the (starting) timestamp of thefragment. Fragments that start before the EndTimestamp value and continue past it areincluded in the session.

Type: Timestamp

Required: NoStartTimestamp

The start of the timestamp range for the requested media.

If the DASHTimestampRange value is specified, the StartTimestamp value is required.

Note

This value is inclusive. Fragments that start before the StartTimestamp and continue pastit are included in the session. If FragmentSelectorType is SERVER_TIMESTAMP, theStartTimestamp must be later than the stream head.

Type: Timestamp

Required: No

See AlsoFor more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for Ruby V3

304

Page 311: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams Archived Media

305

Page 312: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams Archived Media

FragmentService: Amazon Kinesis Video Streams Archived Media

Represents a segment of video or other time-delimited data.

Contents

FragmentLengthInMilliseconds

The playback duration or other time value associated with the fragment.

Type: Long

Required: NoFragmentNumber

The unique identifier of the fragment. This value monotonically increases based on the ingestion order.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 128.

Pattern: ^[0-9]+$

Required: NoFragmentSizeInBytes

The total fragment size, including information about the fragment and contained media data.

Type: Long

Required: NoProducerTimestamp

The timestamp from the producer corresponding to the fragment.

Type: Timestamp

Required: NoServerTimestamp

The timestamp from the AWS server corresponding to the fragment.

Type: Timestamp

Required: No

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for Ruby V3

306

Page 313: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams Archived Media

FragmentSelectorService: Amazon Kinesis Video Streams Archived Media

Describes the timestamp range and timestamp origin of a range of fragments.

Only fragments with a start timestamp greater than or equal to the given start time and less than or equal tothe end time are returned. For example, if a stream contains fragments with the following start timestamps:

• 00:00:00• 00:00:02• 00:00:04• 00:00:06

A fragment selector range with a start time of 00:00:01 and end time of 00:00:04 would return the fragmentswith start times of 00:00:02 and 00:00:04.

Contents

FragmentSelectorType

The origin of the timestamps to use (Server or Producer).

Type: String

Valid Values: PRODUCER_TIMESTAMP | SERVER_TIMESTAMP

Required: YesTimestampRange

The range of timestamps to return.

Type: TimestampRange (p. 311) object

Required: Yes

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for Ruby V3

307

Page 314: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams Archived Media

HLSFragmentSelectorService: Amazon Kinesis Video Streams Archived Media

Contains the range of timestamps for the requested media, and the source of the timestamps.

Contents

FragmentSelectorType

The source of the timestamps for the requested media.

When FragmentSelectorType is set to PRODUCER_TIMESTAMP andGetHLSStreamingSessionURL:PlaybackMode (p. 277) is ON_DEMAND or LIVE_REPLAY,the first fragment ingested with a producer timestamp within the specifiedFragmentSelector:TimestampRange (p. 307) is included in the media playlist. In addition, thefragments with producer timestamps within the TimestampRange ingested immediately following thefirst fragment (up to the GetHLSStreamingSessionURL:MaxMediaPlaylistFragmentResults (p. 277)value) are included.

Fragments that have duplicate producer timestamps are deduplicated. This means that if producersare producing a stream of fragments with producer timestamps that are approximately equal to the trueclock time, the HLS media playlists will contain all of the fragments within the requested timestamprange. If some fragments are ingested within the same time range and very different points in time, onlythe oldest ingested collection of fragments are returned.

When FragmentSelectorType is set to PRODUCER_TIMESTAMP andGetHLSStreamingSessionURL:PlaybackMode (p. 277) is LIVE, the producer timestamps are used inthe MP4 fragments and for deduplication. But the most recently ingested fragments based on servertimestamps are included in the HLS media playlist. This means that even if fragments ingested in thepast have producer timestamps with values now, they are not included in the HLS media playlist.

The default is SERVER_TIMESTAMP.

Type: String

Valid Values: PRODUCER_TIMESTAMP | SERVER_TIMESTAMP

Required: NoTimestampRange

The start and end of the timestamp range for the requested media.

This value should not be present if PlaybackType is LIVE.

Type: HLSTimestampRange (p. 309) object

Required: No

See AlsoFor more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for Ruby V3

308

Page 315: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams Archived Media

HLSTimestampRangeService: Amazon Kinesis Video Streams Archived Media

The start and end of the timestamp range for the requested media.

This value should not be present if PlaybackType is LIVE.

Note

The values in the HLSTimestampRange are inclusive. Fragments that begin before the start timebut continue past it, or fragments that begin before the end time but continue past it, are includedin the session.

Contents

EndTimestamp

The end of the timestamp range for the requested media. This value must be within 3 hours of thespecified StartTimestamp, and it must be later than the StartTimestamp value.

If FragmentSelectorType for the request is SERVER_TIMESTAMP, this value must be in the past.

The EndTimestamp value is required for ON_DEMAND mode, but optional for LIVE_REPLAY mode. Ifthe EndTimestamp is not set for LIVE_REPLAY mode then the session will continue to include newlyingested fragments until the session expires.

Note

This value is inclusive. The EndTimestamp is compared to the (starting) timestamp of thefragment. Fragments that start before the EndTimestamp value and continue past it areincluded in the session.

Type: Timestamp

Required: NoStartTimestamp

The start of the timestamp range for the requested media.

If the HLSTimestampRange value is specified, the StartTimestamp value is required.

Note

This value is inclusive. Fragments that start before the StartTimestamp and continue pastit are included in the session. If FragmentSelectorType is SERVER_TIMESTAMP, theStartTimestamp must be later than the stream head.

Type: Timestamp

Required: No

See AlsoFor more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for Ruby V3

309

Page 316: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドAmazon Kinesis Video Streams Archived Media

310

Page 317: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドCommon Errors

TimestampRangeService: Amazon Kinesis Video Streams Archived Media

The range of timestamps for which to return fragments.

Contents

EndTimestamp

The ending timestamp in the range of timestamps for which to return fragments.

Type: Timestamp

Required: YesStartTimestamp

The starting timestamp in the range of timestamps for which to return fragments.

Type: Timestamp

Required: Yes

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following:

• AWS SDK for C++• AWS SDK for Go• AWS SDK for Java• AWS SDK for Ruby V3

Common ErrorsThis section lists the errors common to the API actions of all AWS services. For errors specific to an APIaction for this service, see the topic for that API action.

AccessDeniedException

You do not have sufficient access to perform this action.

HTTP Status Code: 400IncompleteSignature

The request signature does not conform to AWS standards.

HTTP Status Code: 400InternalFailure

The request processing has failed because of an unknown error, exception or failure.

HTTP Status Code: 500InvalidAction

The action or operation requested is invalid. Verify that the action is typed correctly.

311

Page 318: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドCommon Errors

HTTP Status Code: 400InvalidClientTokenId

The X.509 certificate or AWS access key ID provided does not exist in our records.

HTTP Status Code: 403InvalidParameterCombination

Parameters that must not be used together were used together.

HTTP Status Code: 400InvalidParameterValue

An invalid or out-of-range value was supplied for the input parameter.

HTTP Status Code: 400InvalidQueryParameter

The AWS query string is malformed or does not adhere to AWS standards.

HTTP Status Code: 400MalformedQueryString

The query string contains a syntax error.

HTTP Status Code: 404MissingAction

The request is missing an action or a required parameter.

HTTP Status Code: 400MissingAuthenticationToken

The request must contain either a valid (registered) AWS access key ID or X.509 certificate.

HTTP Status Code: 403MissingParameter

A required parameter for the specified action is not supplied.

HTTP Status Code: 400OptInRequired

The AWS access key ID needs a subscription for the service.

HTTP Status Code: 403RequestExpired

The request reached the service more than 15 minutes after the date stamp on the request or morethan 15 minutes after the request expiration date (such as for pre-signed URLs), or the date stamp onthe request is more than 15 minutes in the future.

HTTP Status Code: 400ServiceUnavailable

The request has failed due to a temporary failure of the server.

HTTP Status Code: 503

312

Page 319: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドCommon Parameters

ThrottlingException

The request was denied due to request throttling.

HTTP Status Code: 400ValidationError

The input fails to satisfy the constraints specified by an AWS service.

HTTP Status Code: 400

Common ParametersThe following list contains the parameters that all actions use for signing Signature Version 4 requests witha query string. Any action-specific parameters are listed in the topic for that action. For more informationabout Signature Version 4, see Signature Version 4 Signing Process in the Amazon Web Services GeneralReference.

Action

The action to be performed.

Type: string

Required: YesVersion

The API version that the request is written for, expressed in the format YYYY-MM-DD.

Type: string

Required: YesX-Amz-Algorithm

The hash algorithm that you used to create the request signature.

Condition: Specify this parameter when you include authentication information in a query string insteadof in the HTTP authorization header.

Type: string

Valid Values: AWS4-HMAC-SHA256

Required: ConditionalX-Amz-Credential

The credential scope value, which is a string that includes your access key, the date, the region youare targeting, the service you are requesting, and a termination string ("aws4_request"). The value isexpressed in the following format: access_key/YYYYMMDD/region/service/aws4_request.

For more information, see Task 2: Create a String to Sign for Signature Version 4 in the Amazon WebServices General Reference.

Condition: Specify this parameter when you include authentication information in a query string insteadof in the HTTP authorization header.

Type: string

313

Page 320: Amazon Kinesis Video Streams - 開発者ガイド...Amazon Kinesis Video Streams 開発者ガイド Amazon Kinesis ビデオストリーム と は? Amazon Kinesis ビデオストリーム

Amazon Kinesis Video Streams 開発者ガイドCommon Parameters

Required: ConditionalX-Amz-Date

The date that is used to create the signature. The format must be ISO 8601 basic format(YYYYMMDD'T'HHMMSS'Z'). For example, the following date time is a valid X-Amz-Date value:20120325T120000Z.

Condition: X-Amz-Date is optional for all requests; it can be used to override the date used for signingrequests. If the Date header is specified in the ISO 8601 basic format, X-Amz-Date is not required.When X-Amz-Date is used, it always overrides the value of the Date header. For more information, seeHandling Dates in Signature Version 4 in the Amazon Web Services General Reference.

Type: string

Required: ConditionalX-Amz-Security-Token

The temporary security token that was obtained through a call to AWS Security Token Service (AWSSTS). For a list of services that support temporary security credentials from AWS Security TokenService, go to AWS Services That Work with IAM in the IAM User Guide.

Condition: If you're using temporary security credentials from the AWS Security Token Service, youmust include the security token.

Type: string

Required: ConditionalX-Amz-Signature

Specifies the hex-encoded signature that was calculated from the string to sign and the derived signingkey.

Condition: Specify this parameter when you include authentication information in a query string insteadof in the HTTP authorization header.

Type: string

Required: ConditionalX-Amz-SignedHeaders

Specifies all the HTTP headers that were included as part of the canonical request. For moreinformation about specifying signed headers, see Task 1: Create a Canonical Request For SignatureVersion 4 in the Amazon Web Services General Reference.

Condition: Specify this parameter when you include authentication information in a query string insteadof in the HTTP authorization header.

Type: string

Required: Conditional

314