全部产品
Search
文档中心

媒体处理:查询媒体-使用OSS文件地址

更新时间:Jul 31, 2023

如果您不知道媒体ID(直播走工作流转点播),可以通过媒体的输入地址进行媒体信息的查询,接口为 QueryMediaListByURL

import os
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.QueryMediaListByURLRequest import QueryMediaListByURLRequest

# 读取环境变量中设置的ACCESS_KEY_ID和ACCESS_KEY_SECRET信息
credentials = AccessKeyCredential(os.environ['ALIBABA_CLOUD_ACCESS_KEY_ID'], os.environ['ALIBABA_CLOUD_ACCESS_KEY_SECRET'])
# region_id 为调用的服务地域ID,支持的地域参考 https://www.alibabacloud.com/help/zh/apsaravideo-for-media-processing/latest/service-regions
client = AcsClient(region_id = 'cn-shanghai', credential = credentials)
bucket_name = '<your bucket name>'

request = QueryMediaListByURLRequest()
request.set_accept_format('json')

request.set_FileURLs("http://" + bucket_name + ".oss-cn-shanghai.aliyuncs.com/mps-test/input/video.mp4")


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