logologo
售前咨询
点播云
文档中心
服务端API媒体处理提交媒体处理作业

提交媒体处理作业


请求参数

字段

类型

是否必填

示例

描述

Action

String

SubmitMediaProcessJobs

公共参数,本接口取值:SubmitMediaProcessJobs

ProcessSet

ProcessSet


处理参数

SpaceName

String

test

子空间名称

ProcessSet

字段

类型

是否必填

示例

描述

OperationSets

Array of OperationSet


Operation参数的集合

CallbackUrl

String

xxxx.com

回调URL

CallbackMethod

String

HTTP

回调方法默认HTTP,目前只支持HTTP

UserData

String

{\"userId\":\"34saf23423sdfs\"}

透传参数



OperationSet

字段

类型

是否必填

示例

描述

TemplateId

String

649c40c50660f1dd

媒体处理的模板

ProcessType

String

ImageProcessing

媒体处理的作业类型

可选:

  • 去除图片水印:ImageDelogo
  • 媒体特征分析:MediaFeatureAnalysis
  • 视频增强:VideoEnhance
  • 图片增强:ImageProcessing

InputFileSet

InputFileSet

{

 "Bucket": "inputTest",

 "Object": "xxx.mp4"

}

输入文件

OutputFileSet

OutputFileSet

{

 "Bucket": "outputTest",

 "Object": "yyy.mp4"

}

输出文件,对应1路转多路的outputkey,使用${outputId}站位符来支持多个档位,例如: out_${outputId}.mp4,最后可以转出out_480P.mp4,out_720P.mp4

ExtraParams

json

{

 "width": "100",

 "height": "80"

}

覆盖的参数,map结构,key和value都是String

  • ImageProcessing


{ 
"OutputFormat" : "png",
"Quality": "75",
"Width": "1920",
"Height": "1080",
"LongShortMode": true,
"ScaleMode": "fixed"
}


  • ImageDelogo


{ 
"Format" : "png"
}


  • MediaFeatureAnalysis


{ 
"Version" : "premium",
"InputFormat" : "Video",
"MediaFeatures" : ["ImageQuality"]
}


ExtraParams每种类型的参数定义:

  • ImageProcessing

字段

类型

是否必填

示例

描述

OutputFormat

String

jpg

输入文件支持格式(heif、heic)

输出文件的格式(jpg、jpeg、png、webp),首期只支持webp。

Quality

String

75

图片输出质量,默认值75(取值范围 [0-100] )

Width

String

1080

输出图片的宽,取值范围0或[256,4096]。

当longShortMode为true时代表长边大小限制,长边一定要大于等于短边的限制值(除非长边设置为0则表示长边等比缩放)。如果width为0,则高等比例缩放。

默认值:0

Height

String

720

输出图片的高,取值范围0或[256,4096]。

当longShortMode为true时代表短边大小限制。如果Height为0则Width进行等比例缩放。如果Height和Width均为0,则分辨率和原图保持一致。

默认值:0

LongShortMode

bool

true

是否开启长短边

开启时会根据图片横竖屏自适应,width代表长边,height代表短边

默认值:false

ScaleMode

String

fixed

取值如下所示:

  • contain:结果图宽高均不超过设置值,缩放图限制为设置宽高矩形容器内最大图;
  • fixed:结果图按照指定宽高进行强制缩放。如果宽高均为0则分辨率同源。
  • cover:结果图宽或高超过设置值,缩放图为延伸出设置宽高矩形容器框外最小图。

默认值:fixed


  • ImageDelogo

字段

类型

是否必填

示例

描述

Format

String

png

输出文件的格式(当前只支持png)

输入文件的格式不需要填写,支持格式如下:

png

  • MediaFeatureAnalysis

字段

类型

是否必填

示例

描述

InputFormat

String

Video

输入文件的格式:

Video: 视频

Audio: 音频

Image: 图片

Version

String

premium

目前分为两类版本:

  • basic
  • premium

默认值:basic

MediaFeatures

Array of String

["QualityFeature"]

要分析的特征列表,特征包括:

画质特征: QualityFeature

美学特征: AestheticsFeature

音频特征: AudioFeature


高级版本专属特征:

内容特征: ContentFeature

编码特征:CodingFeature

场景特征:SceneFeature


basic版本只可分析QualityFeature、AestheticsFeature、AudioFeature,

premium版本可以分析全部特征。

InputFileSet

字段

类型

是否必填

示例

描述

Bucket

String

inputTest

输入文件的桶

Object

String

xxx.mp4

输入文件的对象

Url

String

http://xxx.com/xxx.mp4

输入文件的url,Url与[Bucket和Object]必选其中一种输入文件类型

OutputFileSet

字段

类型

是否必填

示例

描述

Bucket

String

outputTest

输出文件的桶

Object

String

yyy.mp4

输出文件的对象


返回参数

公共部分参考 公共返回参数

参数名称

类型

示例

描述

JobInfos

Array of JobInfo


作业信息

JobInfo

参数名称

类型

示例

描述

JobId

String

40d309d3b2bf373cd3f08e5b5e1bddf720160816

作业ID

TemplateId

String

649c40c50660f1dd

媒体处理的模板


API示例

请求示例

curl -X POST 'https://vod.streamlakeapi.com/?Action=SubmitMediaProcessJobs' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-H <公共请求参数>

请求参数示例值

Content-Type: application/x-www-form-urlencoded
{
"MediaId": "649c40c50660f1dd",
"ProcessSet": {
"OperationSets": [
{
"TemplateId": "649c40c50660f1dd",
"OverrideParams": {
"width": "100",
"height": "80"
}
}
],
"CallbackUrl": "asfa.com",
"CallbackMethod": "HTTP",
"UserData": "{\"userId\":\"34saf23423sdfs\"}"
}
}

返回示例

HTTP/1.1 200 OK
Content-Type: application/json
{
"ResponseMeta": {
"RequestId": "CixgpmAFOYcAAAAAAAAAAw",
"ErrorCode": "",
"ErrorMessage": ""
},
"ResponseData": {
"JobInfos": [
{
"JobId": "40d309d3b2bf373cd3f08e5b5e1bddf720160816",
"TemplateId": "649c40c50660f1dd"
}
]
}
}


SDK示例

Java SDK

提交图片处理任务

SubmitMediaProcessJobsRequest request = new SubmitMediaProcessJobsRequest();
ProcessSet processSet = new ProcessSet();
List<OperationSet> operationSets = new ArrayList<>();
OperationSet operationSet = new OperationSet();
operationSet.setProcessType("ImageProcessing");
InputFileSet inputFileSet = new InputFileSet();
inputFileSet.setBucket("test_video");
inputFileSet.setObject("xingfang/0.heif");
OutputFileSet outputFileSet = new OutputFileSet();
outputFileSet.setBucket("test_video");
outputFileSet.setObject("ImageProcessingTestOutput/0-output.webp");
operationSet.setInputFileSet(inputFileSet);
operationSet.setOutputFileSet(outputFileSet);
Map<String, String> ext = new HashMap<>();
ext.put("OutputFormat", "webp");
ext.put("Quality", "75");
ext.put("LongShortMode", "true");
ext.put("Width", "0");
ext.put("Height", "2048");
ext.put("ScaleMode", "fixed");
operationSet.setExtraParams(ext);
operationSets.add(operationSet);
processSet.setOperationSets(operationSets);
request.processSet = processSet;
SubmitMediaProcessJobsResponse response = client.submitMediaProcessJobs(request);
System.out.println("response=" + response.getResponseMeta().getRequestId());

提交KVQ(特征分析)任务

SubmitMediaProcessJobsRequest request = new SubmitMediaProcessJobsRequest();
ProcessSet processSet = new ProcessSet();
List<OperationSet> operationSets = new ArrayList<>();
OperationSet operationSet = new OperationSet();
operationSet.setProcessType("MediaFeatureAnalysis");
processSet.setCallbackUrl("<回调地址>");
InputFileSet inputFileSet = new InputFileSet();
inputFileSet.setUrl("<源文件URL链接>");
operationSet.setInputFileSet(inputFileSet);
Map<String, String> ext = new HashMap<>();
ext.put("InputFormat", "Video");
ext.put("Version","premium");
ext.put("MediaFeatures", "[\"QualityFeature\",\"AestheticsFeature\",\"ContentFeature\",\"AudioFeature\",\"CodingFeature\",\"SceneFeature\"]");
operationSet.setExtraParams(ext);
operationSets.add(operationSet);
processSet.setOperationSets(operationSets);
request.processSet = processSet;
SubmitMediaProcessJobsResponse response = client.submitMediaProcessJobs(request);
System.out.println("response=" + response.getResponseMeta().getRequestId());


Python

提交去水印任务

req = models.SubmitMediaProcessJobsRequest()
process_set = {
"OperationSets": [
{
"ProcessType": "ImageDelogo",
"InputFileSet": {
"Bucket": "xxx",
"Object": "xx.png"
},
"OutputFileSet": {
"Bucket": "xxx",
"Object": "xx11.png"
}
}
],
"CallbackUrl": "asdfasdf.com",
"UserData": "123"
}
req.ProcessSet = json.dumps(process_set)

client = VodClient(credential, httpProfile)
resp = client.submit_media_process_jobs(req)

提交KVQ(特征分析)任务

		req = models.SubmitMediaProcessJobsRequest()
process_set = {
"OperationSets": [
{
"ProcessType": "MediaFeatureAnalysis",
"InputFileSet": {
"Url" : "https://cdnfile.corp.kuaishou.com/kc/files/a/post-test-materials/big_buck_bunny_720p_5mb.mp4"
},
"ExtraParams" : {
"InputFormat" : "Video",
"Version" : "premium",
"MediaFeatures" : ["QualityFeature","AestheticsFeature","ContentFeature","AudioFeature","CodingFeature","SceneFeature"]
}
}
],
"CallbackUrl": "asdfasdf.com",
"UserData": "123"
}
req.ProcessSet = json.dumps(process_set)

client = VodClient(credential, httpProfile)
resp = client.submit_media_process_jobs(req)

错误码

ErrorCode

ErrorMessage

说明

状态码

InvalidArgument

TemplateId is empty

TemplateId 是空

400

InvalidArgument

Height/Width and ShortEdge/LongEdge must be have a pair that's both greater than 0

Width/Height,ShortEdge/LongEdge必须有一对都大于0

400

InvalidArgument

MediaFeatures must be in QualityFeature|AestheticsFeature|AudioFeature when Version is basic

当指定版本为basic只能选择基础版的特征值。

400

上一篇:提交任务流下一篇:查询任务流状态
该篇文档内容是否对您有帮助?
有帮助没帮助