Live Station 개요
    • PDF

    Live Station 개요

    • PDF

    Article Summary

    개요

    Live Station은 실시간 라이브 방송 서비스 구축에 필요한 모든 기능을 제공하는 영상 인코딩 플랫폼입니다.
    Live Station을 통해 단일 RTMP 원본 스트림을 웹 인터페이스를 통하여 쉽고 빠르게 여러 개의 Multi-bitrate 출력 스트림을 만들어낼 수 있으며, 영상을 HLS, DASH 로 패킷화하여 전송할 수 있습니다.
    하나의 고화질 라이브 영상을 다양한 화질로 변환하는 기능뿐만 아니라 실시간 DVR(Digital Video Recorder, 디지털 비디오 레코더) 기능을 제공하며, 이를 통해 생성된 동영상 파일을 이용해 방송 다시보기 서비스를 구축할 수도 있습니다.

    아울러 라이브 미디어 영상을 손쉽게 타 플랫폼으로 동시 송출 가능한 Re-Stream 기능도 제공합니다. YouTube, Twitch, 아프리카 TV 등 다양한 방송 플랫폼으로 동시에 영상 송출을 할 수 있으며 송출 상태를 Live Station에서 한번에 관리할 수 있습니다.

    공통 설정

    Live Station API URL

    https://livestation.apigw.ntruss.com/api/v2
    

    요청 헤더

    헤더명필수 여부설명
    x-ncp-apigw-timestampYES1970년 1월 1일 00:00:00 협정 세계시(UTC)부터의 경과 시간을 밀리초(Millisecond)로 나타내며 API Gateway 서버와 시간 차가 5분 이상 나는 경우 유효하지 않은 요청으로 간주
    x-ncp-apigw-timestamp:{Timestamp}
    x-ncp-iam-access-keyYES네이버 클라우드 플랫폼 포털에서 발급받은 Access Key ID 값
    x-ncp-iam-access-key:{Sub Account Access Key}
    x-ncp-apigw-signature-v2YESAccess Key ID 값과 Secret Key로 암호화한 서명
    x-ncp-apigw-signature-v2:{API Gateway Signature}
    Content-TypeYESRequest body content type을 application/json으로 지정
    Content-Type: application/json
    x-ncp-region_codeYES리전 코드 (KR)

    인증 헤더

    Live Station API를 사용하기 위해서는 API Gateway 인증이 필요합니다.

    상세한 API Gateway 인증 관련 가이드는 NAVER Cloud Platform 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을 사용합니다.


    이 문서가 도움이 되었습니까?

    What's Next
    Changing your password will log you out immediately. Use the new password to log back in.
    First name must have atleast 2 characters. Numbers and special characters are not allowed.
    Last name must have atleast 1 characters. Numbers and special characters are not allowed.
    Enter a valid email
    Enter a valid password
    Your profile has been successfully updated.