AI成片-图文转视频
<p>[TOC]</p>
<h3>简介</h3>
<ul>
<li>输入图文素材,一键生成短视频,自动实现配音、加字幕、素材匹配、添加数字人形象等环节。适用于企业宣传、营销推广、知识科普等场景,帮助创作者实现精美视频的快速产出。</li>
<li>AI 成片涉及2个接口,分别为:AI 成片-图文转视频、AI 成片-查询结果。</li>
</ul>
<h3>接入流程</h3>
<ol>
<li>传入文本、图片、背景音乐等参数,创建AI成片任务,获得任务ID。当前接口必须传入至少一张图片。</li>
<li>用于在任务创建后,查看视频生成状态。待视频生成完毕,通过查询接口即可查看生成视频的地址链接</li>
</ol>
<h3>接口调用说明</h3>
<h4>请求方式</h4>
<p>如接口没有单独说明,所有接口均为:<strong>POST</strong></p>
<h4>请求格式</h4>
<p>如接口没有单独说明,所有接口均为:<strong>application/form-data</strong></p>
<h4>请求参数</h4>
<p>请求参数均包括公共参数和业务参数(业务参数见具体接口说明)
如接口没有单独说明,所有接口调用时,均需要把<strong>公共参数</strong>和<strong>业务参数</strong>一并放在<strong>请求参数</strong>中提交</p>
<p><a name="公共请求参数"></a></p>
<h5>公共请求参数</h5>
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>必须</th>
<th><div style="width:420px;">说明</div></th>
</tr>
</thead>
<tbody>
<tr>
<td>appId</td>
<td>String</td>
<td>是</td>
<td>服务商分配的唯一标识</td>
</tr>
<tr>
<td>timestamp</td>
<td>Long</td>
<td>是</td>
<td>当前时间戳(毫秒)</td>
</tr>
<tr>
<td>sign</td>
<td>String</td>
<td>是</td>
<td>签名,详见签名算法说明</td>
</tr>
</tbody>
</table>
<h5>签名算法说明</h5>
<pre><code>sign = sha256(appId + appSecret + timestamp)</code></pre>
<p>用服务商分配的 <strong>appId</strong>、服务商分配的 <strong>appSecret</strong>,当前时间戳(毫秒) <strong>timestamp</strong>,按上述顺序拼接成字符串,再进行 <strong>sha256</strong> 哈希得到。如下:</p>
<pre><code class="language-java">String appId = &quot;xyzxy2121zxyz&quot;;
String timestamp = &quot;1555378976238&quot;;
String appSecret = &quot;efcefcef1121cefcefc1212121&quot;;
String str = appId + appSecret + timestamp;
String sign = sha256(str);</code></pre>
<h4>返回说明</h4>
<h5>公共返回字段说明</h5>
<p>所有接口均返回以下公共字段:</p>
<table>
<thead>
<tr>
<th>字段名</th>
<th><div style="width:420px">说明</div></th>
</tr>
</thead>
<tbody>
<tr>
<td>code</td>
<td>返回码,详见:code返回码说明</td>
</tr>
<tr>
<td>msg</td>
<td>code对应的描述</td>
</tr>
<tr>
<td>charge</td>
<td>计费标志 true为计费,false为不计费</td>
</tr>
<tr>
<td>taskNo</td>
<td>本次请求号</td>
</tr>
<tr>
<td>data</td>
<td>返回具体结果,object类型,详见data返回字段描述</td>
</tr>
</tbody>
</table>
<p><a name="code返回码说明"></a></p>
<table>
<thead>
<tr>
<th>code</th>
<th><div style="width:420px;">说明</div></th>
</tr>
</thead>
<tbody>
<tr>
<td>200</td>
<td>成功</td>
</tr>
<tr>
<td>400</td>
<td>参数错误</td>
</tr>
<tr>
<td>404</td>
<td>接口地址不正确</td>
</tr>
<tr>
<td>500</td>
<td>系统维护,请稍候再试</td>
</tr>
<tr>
<td>601</td>
<td>接口未开通</td>
</tr>
<tr>
<td>602</td>
<td>账号停用</td>
</tr>
<tr>
<td>604</td>
<td>接口停用</td>
</tr>
<tr>
<td>606</td>
<td>调用超限,请稍候再试</td>
</tr>
<tr>
<td>607</td>
<td>ip不在白名单</td>
</tr>
<tr>
<td>609</td>
<td>请求过于频繁,请稍候再试</td>
</tr>
<tr>
<td>610</td>
<td>请求超时</td>
</tr>
<tr>
<td>999</td>
<td>其他,以实际返回为准</td>
</tr>
</tbody>
</table>
<hr />
<h3>提交任务</h3>
<h4>请求地址</h4>
<p><code>https://api.jumdata.com/ai/creative-video/submit</code></p>
<h5>请求格式</h5>
<ul>
<li>application/json</li>
</ul>
<h5>业务参数</h5>
<ul>
<li>样例</li>
</ul>
<pre><code class="language-json">{
&quot;source&quot;: {//用于生成视频的图文内容与设置项
&quot;structs&quot;: [//文本、图片素材内容,必须包含文字段落和图片,structs中文本总长在20-2000字符之间
{
&quot;type&quot;: &quot;text&quot;,//内容类型,支持image(图片)、text(文字)
&quot;text&quot;: &quot;向往去西藏旅游,看看西藏的蓝天绿水,看看西藏高耸入云的山峰&quot; //若内容类型type=text,该字段描述文本内容
},
{
&quot;type&quot;: &quot;image&quot;,//内容类型,支持image(图片)、text(文字)
&quot;mediaSource&quot;: {//若内容类型type=image,该字段描述图片内容,支持jpg/jpeg/png格式的图片
&quot;type&quot;: 3,//图片类型,支持url,固定传3
&quot;url&quot;: &quot;xxxxxxx&quot;//传入图片的url地址
}
},
{
&quot;type&quot;: &quot;image&quot;,
&quot;mediaSource&quot;: {
&quot;type&quot;: 3,
&quot;url&quot;: &quot;xxxxxxx&quot;
}
}
]
},
&quot;config&quot;: {//视频生产配置,resolution分辨率为必传,其他非必传
&quot;ttsPer&quot;: 103,//支持基础音库、甄选音库,默认4100:小雯-女;【基础音库】0:小美-女、1:小宇-男、3:小云-男、4:小丫-女童、5:小娇-女、
//103:小朵-女童、106:小博-男、110:小童-男童、111:小萌-女、5003:小遥-男、5118:小婷-女、4003:小耀-男、4100:小雯-女、
//4103:小米-男童、4105:小灵-女、4106:小文-男、4115:小贤-男、4117:小乔-女、4119:小鹿-女;【甄选音库】4144:姗姗-女、
//4140:小新-女、4143:清风-男、4129:小彦-男、4278:小贝-女、4254:小清-女、4149:星河-男
&quot;digitalHumanId&quot;: 2,//数字人选择,支持 2:灿儿 、3:逍遥、4:关关、5:家乐
&quot;resolution&quot;: [//分辨率,横屏支持[1920,1080]、[1280,720]、[1024,576]、竖屏支持[1080,1920]、[720,1280]、[576,1024]
1280,
720
],
&quot;bgMusic&quot;: {//背景音乐,支持使用mp3格式,文件大小不超过10M
&quot;mediaSource&quot;: {//需要指定背景音乐时,通过该字段进行添加
&quot;type&quot;: &quot;3&quot;,//背景音乐类型,支持url,固定传3
&quot;url&quot;: &quot;&quot; //传入音频的url地址
}
},
&quot;videoBegin&quot;: {//视频片头,大小限制50M,格式为mp4或mov
&quot;mediaSource&quot;: {//需要指定视频片头来源时,通过该字段进行添加
&quot;type&quot;: &quot;3&quot;,//视频片头类型,支持url,固定传3
&quot;url&quot;: &quot;&quot; //传入的视频片头url地址
}
},
&quot;videoEnd&quot;: {//视频片尾,大小限制50M,格式为mp4或mov
&quot;mediaSource&quot;: {//需要指定视频片尾来源时,通过该字段进行添加
&quot;type&quot;: &quot;3&quot;,//视频片尾类型,支持url,固定传3
&quot;url&quot;: &quot;&quot; //传入的视频片尾url地址
}
},
&quot;caption&quot;: {//字幕显示设置
&quot;marginBottom&quot;: &quot;3&quot;,//字幕距离视频底部的位置,单位px,支持选择0-500。横屏默认值为70px;竖屏[1080,1920]默认为270px、[720,1280]默认为180px、[576,1024]默认为170px
&quot;fontColor&quot;: &quot;&quot;,//字体颜色,支持传入颜色的十六进制,默认:ffffff
&quot;fontAlpha&quot;: &quot;&quot;,//字体透明度,范围:0-100,从透明到不透明,默认:100
&quot;bgColor&quot;: &quot;&quot;,//字幕背景颜色,支持传入颜色的十六进制,默认:927070
&quot;bgAlpha&quot;: &quot;&quot; //字幕背景透明度,范围:0-100,从透明到不透明,默认32
},
&quot;videoLogo&quot;: {//视频角标,支持jpg/jpeg/png类型的图片,大小限制1M
&quot;location&quot;: &quot;&quot;,//角标位置,支持:top-left(左上)、top-right(右上),默认为 top-left
&quot;margin&quot;: &quot;&quot;,//角标边缘距离,单位px,支持0-100,默认为 20
&quot;mediaSource&quot;: {//需要指定角标来源时,通过该字段进行添加
&quot;type&quot;: &quot;3&quot;,//角标类型,支持url,固定传3
&quot;url&quot;: &quot;&quot; //传入角标图片的url地址
}
}
}
}</code></pre>
<h4>成功返回样例</h4>
<pre><code class="language-json">{
&quot;code&quot;: 200,// 返回码,详见返回码说明
&quot;msg&quot;: &quot;成功&quot;,// 返回码对应描述
&quot;taskNo&quot;: &quot;043439882226367117195632&quot;,// 本次请求号
&quot;charge&quot;: true, // 计费标志
&quot;data&quot;: {
&quot;jobId&quot;: &quot;xxxx&quot; //用于查询
}
}</code></pre>
<h4>失败返回样例</h4>
<pre><code class="language-json">{
&quot;code&quot;: 400,// 返回码,详见返回码说明
&quot;taskNo&quot;: &quot;255033697205413852131601&quot;,// 本次请求号
&quot;charge&quot;: false,// 计费标志
&quot;msg&quot;: &quot;图文内容与设置项不能为空&quot;// 返回码对应描述
}</code></pre>
<hr />
<h3>查询结果</h3>
<h4>请求地址</h4>
<p><code>https://api.jumdata.com/ai/creative-video/query</code></p>
<h4>业务参数</h4>
<p>参数说明</p>
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>必须</th>
<th><div style="width:420px;">说明</div></th>
</tr>
</thead>
<tbody>
<tr>
<td>jobId</td>
<td>String</td>
<td>是</td>
<td>提交任务接口返回的jobId</td>
</tr>
</tbody>
</table>
<h4>成功返回样例</h4>
<pre><code class="language-json">{
&quot;code&quot;: 200,// 返回码,详见返回码说明
&quot;msg&quot;: &quot;成功&quot;, // 返回码对应描述
&quot;taskNo&quot;: &quot;448290834186092138576138&quot;,// 本次请求号
&quot;charge&quot;: false, //计费标志,查询结果接口不计费
&quot;data&quot;: {
&quot;url&quot;: &quot;xxxxx&quot;,//任务产出视频地址(有效期三个月)
&quot;progress&quot;: 0.33 //任务进度,范围0-1,1为任务完成
}
}
</code></pre>
<h4>失败返回样例</h4>
<pre><code class="language-json">{
&quot;code&quot;: 400,// 返回码,详见返回码说明
&quot;msg&quot;: &quot;jobId不能为空&quot;, // 返回码对应描述
&quot;taskNo&quot;: &quot;255033697205413852131601&quot;,// 本次请求号
&quot;charge&quot;: false, //计费标志,查询结果接口不计费
}</code></pre>