日本熟妇hd丰满老熟妇,中文字幕一区二区三区在线不卡 ,亚洲成片在线观看,免费女同在线一区二区

創(chuàng)建HLS標(biāo)準(zhǔn)加密工作流

更新時(shí)間:

視頻加密旨在通過(guò)對(duì)視頻內(nèi)容進(jìn)行深度安全處理,確保視頻數(shù)據(jù)不被非法獲取和傳播,可有效防止視頻泄露和盜鏈問(wèn)題,廣泛用于在線教育及財(cái)經(jīng)等對(duì)內(nèi)容安全性要求高的領(lǐng)域。本文提供Python SDK創(chuàng)建HLS標(biāo)準(zhǔn)加密工作流相關(guān)功能的示例代碼。

簡(jiǎn)介

示例調(diào)用API,創(chuàng)建HLS標(biāo)準(zhǔn)加密工作流。創(chuàng)建HLS標(biāo)準(zhǔn)加密工作流到播放加密視頻的完整步驟,參見HLS的加密與播放。MPS SDK,詳情參見安裝。

示例代碼

import os
import json

from urllib.parse import quote
from aliyunsdkcore.client import AcsClient
from aliyunsdkcore.acs_exception.exceptions import ClientException
from aliyunsdkcore.acs_exception.exceptions import ServerException
from aliyunsdkcore.auth.credentials import AccessKeyCredential
from aliyunsdkmts.request.v20140618.AddMediaWorkflowRequest import AddMediaWorkflowRequest

# 讀取環(huán)境變量中設(shè)置的ACCESS_KEY   ACCESS_KEY_SECRET信息
credentials = AccessKeyCredential(os.environ['ALIBABA_CLOUD_ACCESS_KEY_ID'], os.environ['ALIBABA_CLOUD_ACCESS_KEY_SECRET'])
# region_id 為調(diào)用的服務(wù)地域ID,支持的地域參考 http://bestwisewords.com/document_detail/43248.html
client = AcsClient(region_id = 'cn-shanghai', credential = credentials)

request = AddMediaWorkflowRequest()
request.set_Name("hls-transcode-workflow")

startActivity = {
    "Type": "Start",
    "Parameters": {
        "InputFile": {
            "Bucket": "<your input bucket>",
            "Location": "oss-cn-shanghai",
            "ObjectPrefix": "media/"
        },
        "PipelineId": "<PipelineId>"
    }
}

transcodeActivity = {
    "Type": "Transcode",
    "Parameters": {
        "Outputs": [
            {
                "OutputObject": quote("transcode/{ObjectPrefix}/{FileName}.{ExtName}"),
                "TemplateId": "<hls TemplateId>",
                "Encryption": {
                    "Type": "hls-aes-128",
                    "KeyUri": "<解密密鑰的URI #如http://example.aliyundoc.com>"
                }
            }
        ],
        "OutputLocation": "oss-cn-shanghai",
        "OutputBucket": "<your output bucket>"
    }
}

reportActivity = {
    "Type": "Report",
    "Parameters": {
    }
}
topology = {
    "Activities": {
        "Act-Start": startActivity,
        "transcodingNode": transcodeActivity,
        "reportNode": reportActivity
    },
    "Dependencies": {
        "Act-Start": ["transcodingNode"],
        "transcodingNode": ["reportNode"],
        "reportNode": []
    }
}

request.set_Topology(topology)

response = client.do_action_with_exception(request)
# 輸出打印
print(str(response, encoding='utf-8'))