媒资库操作 -奇异果体育app竞彩官网下载
更新时间:2021-11-25
普通素材
用户上传音频/视频/图片到素材库,创作视频时可从素材中心导入
上传素材
使用如下代码可以上传一个视频/音频/图片到媒资库。
private void upload(bvwclient client) {
string bucket = "" ;
string key = "" ;
string title = "" ;
string mediatype = "video";
matlibuploadrequest request = new matlibuploadrequest(mediatype, title, bucket, key);
matlibuploadresponse response = client.upload2material(request);
}
上传媒资可以设置通知回调,在matlibuploadrequest定义notification通知名称即可。
查询素材
使用如下代码可以从媒资库查询一个素材。
private void getmaterial(bvwclient client) {
string materialid = "16c97461e978571b3202172b527f219f";
materialgetresponse response = client.getmaterial(materialid);
}
materialid在上传素材upload2material时返回。
搜索素材
使用如下代码可以从媒资库搜索指定条件的素材。
private void searchmaterial(bvwclient client) {
materialsearchrequest request = new materialsearchrequest();
request.settitlekeyword("keyword");
materialsearchresponse response = client.searchmaterial(request);
}
删除素材
使用如下代码可以从媒资库删除一个素材。
private void deletematerial(bvwclient client) {
string materialid = "16c97461e978571b3202172b527f219f";
materialbaseresponse response = client.deletematerial(materialid);
}
预置素材
预置素材分为音乐/贴图/背景/字幕/转场,除了系统自带的预置素材外,用户可以自定义音乐/贴图预置素材。创作视频时,不需要导入,可直接使用
上传预置素材
使用如下代码可以上传一个音乐/贴图预置素材到媒资库。
private void uploadmaterialpreset(bvwclient client) {
matlibuploadrequest request = new matlibuploadrequest();
request.setbucket("your-bucket");
request.setkey("your-key");
request.setmediatype("audio");
request.settitle("your-title");
materialpresetuploadresponse response = client.uploadmaterialpreset("music", request);
}
查询预置素材
使用如下代码可以查询一个指定预置素材。
private void getmaterialpreset(bvwclient client) {
string materialid = "89355c2e2bd5d22450d965d7381c0517";
materialpresetgetresponse response = client.getmaterialpreset(materialid);
}
搜索预置素材
使用如下代码可以从媒资库搜索指定条件的预置素材。
private void searchmaterialpreset(bvwclient client) {
materialpresetsearchrequest request = new materialpresetsearchrequest();
materialpresetsearchrequest
materialpresetsearchrequest response = client.materialpresetsearchrequest(request);
}
删除预置素材
使用如下代码可以删除一个指定预置素材。
private void deletematerialpreset(bvwclient client) {
string materialid = "89355c2e2bd5d22450d965d7381c0517";
materialbaseresponse response = client.deletematerialpreset(materialid);
}
媒资库设置
媒资库相关操作需要预先设置bucket。
创建媒资库设置
使用如下代码可以创建媒资库设置,设置媒资库交互中使用的默认bucket。
private void creatematlibconfig(bvwclient client) {
matlibconfigbaserequest request = new matlibconfigbaserequest("bucket name");
client.creatematlibconfig(request);
}
更新媒资库设置
使用如下代码可以更新媒资库设置,设置媒资库交互中使用的默认bucket。
private void updatematlibconfig(bvwclient client) {
matlibconfigbaserequest request = new matlibconfigbaserequest("bucket name");
client.updatematlibconfig(request);
}
查询媒资库设置
使用如下代码可以查询媒资库设置,设置媒资库交互中使用的默认bucket。
private void getmatlibconfig(bvwclient client) {
matlibconfiggetresponse respnse = client.getmatlibconfig();
}
智能配音
智能配音功能支持将一段文字按指定的发音类型转化为语音输出。
使用如下代码可以进行文字转语音。
private void text2audio(bvwclient client) {
text2audiorequest request = new text2audiorequest(lists.newarraylist(
"videoworks(原vod音视频点播服务)以媒资为核心,提供了音视图文件的上传、存储、管理、编辑、转码、ai处理(审核、理解、去重)、分发、播放等全生命周期的paas服务。",
"videoworks致力于成为百度智能云上所有音视频的统一入口,目前已集成了bos(对象存储)、cdn(内容分发)、mct(音视频转码)、vcr(视频内容审核)产品,后续会接入vca(视频内容分析)、智能编辑、智能去重等更多的音视频处理能力。",
"此外,videoworks引入了工作流(workflow)能力,用户可根据自身业务需求在console可视化灵活配置音视频的处理流程,一次任务下发即可按照既定流程处理完成,方便快捷。"
), per.base_duxiaomei);
text2audioresponse response = client.text2audio(request);
}
视频合成
视频合成功能支持讲一端视频编辑的timeline(不同媒体分类组成的时间轴数据)编码合成输出。
使用如下代码可以发起合成。
- 接收合成请求timeline的json字符串,直接发起合成。
private void createvideoedit(bvwclient client) {
string jsonstring = "{"
" \"bucket\":\"testbucket111\","
" \"title\":\"default\","
" \"cmd\":{"
" \"timeline\":{"
" \"video\":["
" {"
" \"key\": \"name\","
" \"list\": ["
" {"
" \"type\": \"image\","
" \"start\": 0,"
" \"end\": 10.5,"
" \"showstart\": 0,"
" \"showend\": 10.5,"
" \"width\": 1,"
" \"height\": 1,"
" \"xpos\": 0,"
" \"ypos\": 0,"
" \"duration\": 10.5,"
" \"extinfo\": {"
" \"style\": \"relief\","
" \"lightness\": 0,"
" \"contrast\": 0,"
" \"saturation\": 0,"
" \"hue\": 0,"
" \"speed\": 1,"
" \"transitionstart\": \"white\","
" \"transitionend\": \"black\","
" \"transitionduration\": 2,"
" \"mirror\":\"hori\","
" \"rotate\" : 180"
" },"
" \"mediainfo\": {"
" \"key\": \"77f70ad4cf57e46af1b1249999c62918.jpeg\","
" \"bucket\": \"testbucket111\","
" \"filetype\": \"image\""
" },"
" \"uid\": \"d0a7a580-fe36-4baf-b4ac-193565925b01\""
" }"
" ]"
" }"
" ],"
" \"audio\":["
" {"
" \"key\":\"name\","
" \"list\":["
" ]"
" }"
" ],"
" \"sticker\":["
" ],"
" \"subtitle\" : ["
" ]"
" }"
" }"
"}";
string notification = "notificationname";
map<string, object> editbody = new objectmapper().convertvalue(jsonutils.jsonnodeof(jsonstring), map.class);
videoeditcreaterequest request = new videoeditcreaterequest(editbody, referertype.rmrb, notification);
videoeditcreateresponse response = client.createvideoedit(request);
}
- 自己组合timeline数据对象
自己组合timeline对象(map
) ,将组合好的符合timeline规则对象作为参数传入videoeditcreaterequest构造函数即可
private void createvideoedit(bvwclient client, map<string, object> cmd) {
map<string, object> editbody = new hashmap<string, object>();
string notification = "notificationname";
editbody.put("bucket", "userbucket");
editbody.put("title", "edittitle");
editbody.put("cmd", cmd);
videoeditcreaterequest request = new videoeditcreaterequest(editbody, referertype.rmrb, notification);
videoeditcreateresponse response = client.createvideoedit(request);
}
查询视频合成结果
使用如下代码可以查询视频合成结果。
private void pollingvideoedit(bvwclient client) {
long editid = 123;
videoeditpollingresponse response = client.pollingvideoedit(editid);
}
创建草稿
private void createdraft(bvwclient client) {
matlibtaskrequest request = new matlibtaskrequest();
matlibtaskresponse draft = client.createdraft(request);
}
更新草稿
private void updatedraft(bvwclient client) {
matlibtaskrequest request = new matlibtaskrequest();
// request 设置草稿的各个字段值
// 123为创建生成的草稿id
client.updatedraft(123, request);
}
获取草稿列表
private void listdraft(bvwclient client) {
draftlistrequest listrequest = draftlistrequest.of(1, 5);
listrequest.setstatus(matlibtaskstatus.editing);
listbypageresponse<matlibtaskgetresponse> draftlist = client.getdraftlist(listrequest);
}