- 印刷する
- PDF
Live Station の概要
- 印刷する
- PDF
概要
Live Stationは、ライブ放送サービスの構築に必要なすべての機能を提供する動画エンコードプラットフォームです。
Live Stationを通して単一の RTMPオリジナルストリームをウェブインターフェースにより簡単かつスピーディーに複数の Multi-bitrate出力ストリームを作り出すことができ、動画を HLS、DASHでパケット化して送信できます。
一つの高画質ライブ動画を様々な画質に変換する機能だけでなく、リアルタイム DVR(Digital Video Recorder、デジタルビデオレコーダ)機能を提供します。また、これにより作成された動画ファイルを利用して再配信サービスを構築することもできます。
それと同時に、ライブメディア動画を手軽に他のプラットフォームへ同時配信できる Re-Stream機能も提供します。YouTube、Twitch、Afreeca TVなど様々な放送プラットフォームで同時に動画を配信でき、配信状況を Live Stationでまとめて管理できます。
共通設定
Live Station API URL
https://livestation.apigw.ntruss.com/api/v2
リクエストヘッダ
ヘッダ名 | 要否 | 説明 |
---|---|---|
x-ncp-apigw-timestamp | YES | 1970年1月1日00:00:00協定世界時(UTC)からの経過時間をミリ秒(Millisecond)で表し、API Gatewayサーバとの時間差が5分以上の場合は無効なリクエストとみなすx-ncp-apigw-timestamp:{Timestamp} |
x-ncp-iam-access-key | YES | NAVERクラウドプラットフォームポータルで発行した Access Key ID値x-ncp-iam-access-key:{Sub Account Access Key} |
x-ncp-apigw-signature-v2 | YES | Access Key ID値と Secret Keyで暗号化した署名x-ncp-apigw-signature-v2:{API Gateway Signature} |
Content-Type | YES | Request body content typeを application/jsonに指定Content-Type: application/json |
x-ncp-region_code | YES | リージョンコード(KR) |
認証ヘッダ
Live Station APIをご利用いただくために、API Gateway認証が必要です。
API Gatewayの認証関連の詳細なガイドは、NAVERクラウドプラットフォーム APIをご参照ください。
AUTHPARAMSを作成する
AUTHPARAMSのリクエスト例
curl -i -X GET \
-H "x-ncp-apigw-timestamp:1505290625682" \
-H "x-ncp-iam-access-key:D78BB444D6D3C84CA38A" \
-H "x-ncp-apigw-signature-v2:WTPItrmMIfLUk/UyUIyoQbA/z5hq9o3G8eQMolUzTEo=" \
-H "x-ncp-region_code:KR" \
'https://livestation.apigw.ntruss.com/api/v2/channels'
Signature作成(改行文字は\nを使用)
リクエストに合わせて StringToSignを作成し、SecretKeyで HmacSHA256アルゴリズムに暗号化した後、Base64にエンコードします。
この値を
x-ncp-apigw-signature-v2
として使用します。リクエスト StringToSign GET /api/v2/channels?pageNo=1
x-ncp-apigw-timestamp={timestamp}
x-ncp-iam-access-key={accesskey}
x-ncp-apigw-signature-v2={signature}GET /api/v2/channels?pageNo=1
{timeStamp}
{accessKey}
サンプルコード
public String makeSignature() {
String space = " "; // 空白
String newLine = "\n"; // 改行
String method = "GET"; // HTTPメソッド
String url = "/api/v2/channels?pageNo=1"; // ドメインを除く「/」以下の全体 url(クエリ文字列を含む)
String accessKey = "{accessKey}"; // access key id (from portal or Sub Account)
String secretKey = "{secretKey}"; // secret key (from portal or Sub Account)
String timestamp = String.valueOf(System.currentTimeMillis()); // 現在のタイムスタンプ(epoch、millisecond)
String message = new StringBuilder()
.append(method)
.append(space)
.append(url)
.append(newLine)
.append(timestamp)
.append(newLine)
.append(accessKey)
.toString();
SecretKeySpec signingKey = new SecretKeySpec(secretKey.getBytes("UTF-8"), "HmacSHA256");
Mac mac = Mac.getInstance("HmacSHA256");
mac.init(signingKey);
byte[] rawHmac = mac.doFinal(message.getBytes("UTF-8"));
String encodeBase64String = Base64.encodeBase64String(rawHmac);
return encodeBase64String;
}
/*
https://code.google.com/archive/p/crypto-js/
https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/crypto-js/CryptoJS%20v3.1.2.zip
*/
/*
CryptoJS v3.1.2
code.google.com/p/crypto-js
(c) 2009-2013 by Jeff Mott. All rights reserved.
code.google.com/p/crypto-js/wiki/License
*/
<script type="text/javascript" src="./CryptoJS/rollups/hmac-sha256.js"></script>
<script type="text/javascript" src="./CryptoJS/components/enc-base64.js"></script>
function makeSignature(secretKey, method, url, timestamp, accessKey) {
var space = " ";
var newLine = "\n";
var hmac = CryptoJS.algo.HMAC.create(CryptoJS.algo.SHA256, secretKey); // secret key
hmac.update(method); // HTTPメソッド
hmac.update(space); // 空白
hmac.update(url); // ドメインを除く「/」以下の全体 url(クエリ文字列を含む)
hmac.update(newLine); // 改行
hmac.update(timestamp); // 現在のタイムスタンプ(epoch、millisecond)
hmac.update(newLine); // 改行
hmac.update(accessKey); // access key (from portal or iam)
var hash = hmac.finalize();
return hash.toString(CryptoJS.enc.Base64);
}
import sys
import os
import hashlib
import hmac
import base64
import requests
import time
def make_signature():
timestamp = int(time.time() * 1000)
timestamp = str(timestamp) # 現在のタイムスタンプ(epoch、millisecond)
access_key = "{accessKey}" # access key id (from portal or Sub Account)
secret_key = "{secretKey}" # secret key (from portal or Sub Account)
secret_key = bytes(secret_key, 'UTF-8')
method = "GET" # HTTPメソッド
uri = "/api/v2/channels?pageNo=1" # ドメインを除く「/」以下の全体 url(クエリ文字列を含む)
message = method + " " + uri + "\n" + timestamp + "\n"
+ access_key
message = bytes(message, 'UTF-8')
signingKey = base64.b64encode(hmac.new(secret_key, message, digestmod=hashlib.sha256).digest())
return signingKey
function makeSignature() {
nl=$'\\n'
TIMESTAMP=$(echo $(date +%s000)) # 現在のタイムスタンプ(epoch、millisecond)
ACCESSKEY="{accessKey}" # access key id (from portal or Sub Account)
SECRETKEY="{secretKey}" # secret key (from portal or Sub Account)
METHOD="GET" # HTTPメソッド
URI="/api/v2/channels?pageNo=1" # ドメインを除く「/」以下の全体 url(クエリ文字列を含む)
SIG="$METHOD"' '"$URI"${nl}
SIG+="$TIMESTAMP"${nl}
SIG+="$ACCESSKEY"
SIGNATURE=$(echo -n -e "$SIG"|iconv -t utf8 |openssl dgst -sha256 -hmac $SECRETKEY -binary|openssl enc -base64)
}
Live Station APIリクエストの構成
Header
x-ncp-apigw-timestamp:{Timestamp}
x-ncp-iam-access-key:{Sub Account Access Key}
x-ncp-apigw-signature-v2:{API Gateway Signature}
x-ncp-region_code:KR
Content-Type:application/json
Body
Json Object
URL
https://livestation.apigw.ntruss.com/api/v2/{action}
Live Station APIリクエストのサンプル
curl -i -s -X POST \
-H "Content-Type:application/json" \
-H "x-ncp-apigw-timestamp:1521787414578" \
-H "x-ncp-iam-access-key:6uxz1nKkcYwUjWRG5Q1V7NsW0i5jErlu2NjBXXgy" \
-H "x-ncp-apigw-signature-v2:iJFK773KH0WwQ79PasqJ+ZGixtpDQ/abS57WGQdld2M=" \
-H "x-ncp-region_code:KR" \
"https://livestation.apigw.ntruss.com/api/v2/channles"\
-d "{ \"name\": \"api-guide\", \"qualitySetId\": 1234, \"cdnType\": \"CDN_PLUS\" }"
Live Station API Content-Type
Live Station API HTTP Requestと Response Bodyを通じて転送される全データの Content-typeは、application/json
を利用します。