VOD Station 개요
    • PDF

    VOD Station 개요

    • PDF

    Article Summary

    VOD Station은 Object Storage에 저장된 수많은 영상 파일을 쉽고 빠르게 HLS/DASH 프로토콜로 스트리밍할 수 있는 서비스입니다. HTTP API를 이용하여 VOD Station의 모든 기능을 제어할 수 있습니다.

    공통 설정

    VOD Station API URL

    https://vodstation.apigw.ntruss.com/api/fin-v1
    

    요청 헤더

    헤더명설명
    x-ncp-apigw-timestamp1970년 1월 1일 00:00:00 협정 세계시(UTC)부터의 경과 시간을 밀리초(Millisecond)로 나타내며
    API Gateway 서버와 시간 차가 5분 이상 나는 경우 유효하지 않은 요청으로 간주

    x-ncp-apigw-timestamp:{Timestamp}
    x-ncp-apigw-api-keyAPI Gateway에서 발급받은 키
    x-ncp-apigw-api-key:{API Gateway API Key}
    x-ncp-iam-access-key네이버 클라우드 플랫폼 포털에서 발급받은 Access Key ID
    x-ncp-iam-access-key:{Sub Account Access Key}
    x-ncp-apigw-signature-v2Access Key ID와 맵핑되는 Secret Key로 암호화한 서명
    HMAC 암호화 알고리즘은 HmacSHA256 사용
    x-ncp-apigw-signature-v2:{API Gateway Signature}
    Content-TypeRequest body가 포함된 요청의 경우 Content type을 application/json으로 요청
    Content-Type: application/json

    인증 헤더

    VOD 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-apigw-api-key:cstWXuw4wqp1EfuqDwZeMz5fh0epaTykRRRuy5Ra" \
       -H "x-ncp-iam-access-key:D78BB444D6D3C84CA38A" \
       -H "x-ncp-apigw-signature-v2:WTPItrmMIfLUk/UyUIyoQbA/z5hq9o3G8eQMolUzTEo=" \
     'https://vodstation.apigw.ntruss.com/api/fin-v1/channels'
    
    • Signature 생성(개행 문자는 \n을 사용)

      • 요청에 맞게 StringToSign을 생성하고 SecretKey로 HmacSHA256 알고리즘으로 암호화한 후 Base64로 인코딩합니다.

      • 이 값을 x-ncp-apigw-signature-v2로 사용합니다.

        요청StringToSign
        GET /api/fin-v1/channels?isPage=true
        x-ncp-apigw-timestamp={timestamp}
        x-ncp-apigw-api-key={apiKey}
        x-ncp-iam-access-key={accesskey}
        x-ncp-apigw-signature-v2={signature}
        GET /api/fin-v1/channels?isPage=true
        {timeStamp}
        {accessKey}
    • 샘플 코드

    public String makeSignature() {
        String space = " ";					// 공백
        String newLine = "\n";  				// 줄바꿈
        String method = "GET";  				// HTTP 메서드
        String url = "/api/fin-v1/channels?isPage=true";	// 도메인을 제외한 "/" 아래 전체 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/fin-v1/channels?isPage=true"			# 도메인을 제외한 "/" 아래 전체 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 +%s%N)/1000000)))	# 현재 타임스탬프 (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/fin-v1/channels?isPage=true"		# 도메인을 제외한 "/" 아래 전체 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)
    }
    

    VOD Station API 요청 구성

    Header
      x-ncp-apigw-timestamp:{Timestamp}
      x-ncp-apigw-api-key:{API Gateway API Key}
      x-ncp-iam-access-key:{Sub Account Access Key}
      x-ncp-apigw-signature-v2:{API Gateway Signature}
      Content-Type:application/json
    Body
      Json Object
    URL
      https://vodstation.apigw.ntruss.com/api/fin-v1/{action}
    

    VOD Station API 요청 샘플

    curl -i -s -X POST \
     -H "Content-Type:application/json" \
     -H "x-ncp-apigw-timestamp:1521787414578" \
     -H "x-ncp-apigw-api-key:6uxz1nKkcYwUjWRG5Q1V7NsW0i5jErlu2NjBXXgy" \
     -H "x-ncp-iam-access-key:6uxz1nKkcYwUjWRG5Q1V7NsW0i5jErlu2NjBXXgy" \
     -H "x-ncp-apigw-signature-v2:iJFK773KH0WwQ79PasqJ+ZGixtpDQ/abS57WGQdld2M=" \
     "https://vodstation.apigw.ntruss.com/api/fin-v1/channles"\
     -d "{ \"cdnTypeList\": [ \"cdn+\" ], \"createCdn\": true, \"name\": \"api-guide\", \"protocolList\": [ \"HLS\", \"DASH\" ], \"segmentDuration\": 5, \"storageBucketName\": \"guide\"}"
    

    VOD Station API Content-Type

    VOD Station API HTTP Request와 Response Body를 통해 전달되는 모든 데이터의 Content-type은 application/json을 사용합니다.

    사용 시나리오


    Step 1. Object Storage에 스트리밍할 영상 업로드

    VOD Station을 통해 스트리밍할 영상을 네이버 클라우드 플랫폼 Object Storage에 업로드합니다.

    VOD Station에서 지원하는 영상 컨테이너 포맷은 mp4입니다.

    만약 지원되지 않는 확장자 스트리밍이 필요하다면, 고객지원 > 문의하기로 문의 부탁드립니다.

    Object Storage에 대한 자세한 내용은 Object Storage 사용 가이드를 참고 부탁드립니다.

    Step 2. 인증키 생성

    API 인증키 생성

    VOD Station API는 네이버 클라우드 플랫폼 API Gateway를 통하여 제공되며, API Gateway에 등록된 API를 사용하기 위해서는 3가지 인증키(Access Key ID, Secret Key, API Key)를 발급받아야 합니다.

    API 인증키 발급에 대한 자세한 내용은 NAVER Cloud Platform API를 참고 부탁드립니다.

    • 인증키 생성
      • 네이버 클라우드 플랫폼 포털의 마이페이지 > 계정관리 > 인증키 관리 메뉴에서 신규 API 인증키 생성을 클릭하여 Access Key ID, Secret Key를 생성합니다.
      • 만약 Access Key ID, Secret Key가 있다면 해당 키를 사용합니다.
    • API Key 생성
      • Console의 API Gateway 메뉴에서 API Key 생성을 클릭하여 API Key를 생성합니다.

    Step 3. VOD Station 채널 생성

    VOD Station을 사용하기 위해 채널을 생성합니다.

    요청 예시

    POST https://vodstation.apigw.ntruss.com/api/fin-v1/channels
    
    {
      "cdnTypeList": [
        "cdn+"
      ],
      "createCdn": true,
      "name": "api-guide",
      "protocolList": [
      	"HLS", "DASH"
      ],
      "segmentDuration": 5,
      "storageBucketName": "vodstation-bucket"
    }
    

    응답 예시

    HTTP/1.1 200 OK
    Server: nginx
    Date: Wed, 12 Sep 2018 09:53:32 GMT
    Content-Type: application/json;charset=utf-8
    Connection: keep-alive
    Access-Control-Allow-Origin: *
    x-ncp-trace-id: 36c9k60om4p3238cpmc9gm4cj4
    
    {
      "content": {
        "id": "vs-20191227055342-vDVWH5l",
        "name": "api-guide",
        "channelStatus": "CREATING",
        "storageBucketName": "vodstation-bucket",
        "segmentDuration": 5,
        "protocolList": [
          "HLS",
          "DASH"
        ],
        "createTime": 1577426022,
        "cdnCreatedTime": 1577426022,
        "cdnStatus": "CREATING",
        "storageBucketStatus": "RUNNING"
      }
    }
    

    Step 4. VOD Station 연동 CDN 생성

    VOD Station 채널 생성 시 CDN을 함께 생성하지 않았다면, VOD Station 재생을 위해 별도 CDN 생성이 필요합니다.

    VOD Station 시작 가이드를 참고하여 CDN 생성을 부탁드립니다.

    Step 5. VOD Station 재생

    VOD Station 채널 생성 시 CDN을 함께 생성했다면, VOD Station 채널 정보 API를 통해 재생 정보를 획득할 수 있습니다.

    요청 예시

    GET https://vodstation.apigw.ntruss.com/api/fin-v1/channels/vs-20191227055342-vDVWH5l
    

    응답 예시

    HTTP/1.1 200 OK
    Server: nginx
    Date: Wed, 12 Sep 2018 10:20:21 GMT
    Content-Type: application/json;charset=utf-8
    Connection: keep-alive
    Access-Control-Allow-Origin: *
    x-ncp-trace-id: 3cc9hcpim4c9h62oj3cgo6ccr5
    
    {
      "content": {
        "id": "vs-20191227055342-vDVWH5l",
        "name": "apiTest",
        "channelStatus": "READY",
        "storageBucketName": "testvod",
        "segmentDuration": 5,
        "protocolList": [
          "HLS",
          "DASH"
        ],
        "createTime": 1577426022,
        "readyTime": 1577426040,
        "cdnCreatedTime": 1577426022,
        "playUrl": "https://klmawqyuoshq1111349.cdn.ntruss.com/[protocol]/[path]/[video filename]/index.m3u8",
        "cdnStatus": "RUNNING",
        "cdnDomain": "klmawqyuoshq1111349.cdn.ntruss.com",
        "cdnServiceName": "vscdn-vDVWH5l",
        "storageBucketStatus": "RUNNING",
        "originPath": "vs-k1.video.media.ntruss.com/vs-20191227055342-vDVWH5l/testvod"
      }
    }
    

    채널 정보 API 응답의 protocolList, playUrl , cdnDomain 정보를 활용하여 재생할 수 있습니다.

    상세한 재생 가이드는 VOD Station 스트리밍 가이드를 참고 부탁드립니다.


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

    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.