视频点播
视频点播 AI 漫剧转绘功能支持将真人实拍视频(如短剧),通过智能场景切分、内容理解、风格迁移和视频生成等多项 AI 技术,转换为具有多样化艺术风格的全新视频(例如动漫风、3D 卡通风、素描风)。您可以借此将现有的真人视频素材,低成本、批量化地转化为风格独特的动漫或卡通内容,从而丰富内容形态、提升用户吸引力。该功能适用于真人短剧的动漫化改编、营销视频的创意视觉升级,以及社交媒体内容的风格化处理等场景。
本文档将指导您如何通过调用视频点播 OpenAPI,实现真人视频的 AI 漫剧转绘。
使用 AI 漫剧转绘会产生以下费用:
项目 | 说明 |
|---|---|
输入视频 |
|
资源与并发限制 | 当前每个账号仅支持 1 个任务并发执行。如果您在有任务正在执行时提交新任务,新任务将会进入排队状态,等待前面的任务完成后再开始执行。根据当前模型预估,处理一段 1 分钟的视频大约需要 10 分钟。请您提交任务后耐心等待。 |
调用 AsyncVCreativeTask 接口提交一个 AI 漫剧转绘任务。核心参数配置如下:
Scene: 必须设置为 videostyletrans,代表 AI 漫剧转绘场景。Uploader: 设置任务产物(生成的视频)要上传到的点播空间名称。ParamObj: 传入一个包含了输入视频、转绘风格等信息的 JSON 序列化后的字符串。详细结构请参考下文。CallbackArgs: 自定义回调参数。该参数值会通过 VCreativeComplete 事件或 GetVCreativeTaskResult 接口中的 CallbackArgs 参数返回给您的服务端。成功提交后,系统将返回任务的唯一标识 VCreativeId。请务必保存好此 ID,以便后续查询结果。
ParamObj 字符串支持以下字段:
字段 | 类型 | 必填 | 描述 |
|---|---|---|---|
input | String | 是 | 输入视频。格式为 vid:// |
style | String | 否 | 转绘风格。默认为"漫画风"。您可自定义风格,例如"3D卡通风格"。 |
resolution | String | 是 | 输出视频分辨率。支持:
|
以下 HTTP 示例仅展示核心的业务参数,省略了 Authorization 请求头中的签名计算等鉴权细节。在实际发起请求前,请参考如何调用 OpenAPI 文档,了解如何在线测试接口、获取可运行的 curl 命令以及完整的 HTTP 请求构造方法与签名机制。
POST https://vod.volcengineapi.com?Action=AsyncVCreativeTask&Version=2018-01-01 { "Uploader": "your_output_space_name", "Scene": "videostyletrans", "CallbackArgs": "task_for_cartoon_style", "ParamObj": { "input": "vid://v022d2g10065d***bcde123456", "style": "3D卡通风格", "resolution": "1080p" } }
以下示例基于您已在项目中集成 Java SDK 并初始化客户端。如果您是首次使用,请参考集成 Java SDK 文档完成基础配置。
package com.volcengine.example.vod.edit; import com.alibaba.fastjson.JSONObject; import com.google.protobuf.ByteString; import com.google.protobuf.util.JsonFormat; import com.volcengine.service.vod.IVodService; import com.volcengine.service.vod.impl.VodServiceImpl; import com.volcengine.service.vod.model.request.VodAsyncVCreativeTaskRequest; import com.volcengine.service.vod.model.request.VodRequest; import com.volcengine.service.vod.model.request.VodSubmitDirectEditTaskAsyncRequest; import com.volcengine.service.vod.model.response.VodAsyncVCreativeTaskResponse; import com.volcengine.service.vod.model.response.VodSubmitDirectEditTaskAsyncResponse; import java.util.HashMap; public class VodAsyncVCreativeTaskDemo { public static void main(String[] args) { // 1. 初始化客户端 IVodService vodService = VodServiceImpl.getInstance(); // Configure your Access Key ID (AK) and Secret Access Key (SK) in the environment variables or in the local ~/.volc/config file. For detailed instructions, see https://www.volcengine.com/docs/4/65641. // The SDK will automatically fetch the AK and SK from the environment variables or the ~/.volc/config file as needed. // During testing, you may use the following code snippet. However, do not store the AK and SK directly in your project code to prevent potential leakage and safeguard the security of all resources associated with your account. // vodService.setAccessKey("your ak"); // vodService.setSecretKey("your sk"); // 2. 构建 ParamObj 对象,并序列化为字符串 JSONObject paramObj = new JSONObject(); paramObj.put("input","vid://{your vid}"); paramObj.put("style","漫画风"); paramObj.put("resolution","720p"); // 3. 构建请求 VodAsyncVCreativeTaskRequest vodAsyncVCreativeTaskRequest = VodAsyncVCreativeTaskRequest.newBuilder() .setUploader("your space") .setParamStr(paramObj.toString()) .setScene("videostyletrans") .build(); // 4. 发起调用 try { VodAsyncVCreativeTaskResponse vodAsyncVCreativeTaskResponse = vodService.asyncVCreativeTask(vodAsyncVCreativeTaskRequest); if (vodAsyncVCreativeTaskResponse.getResponseMetadata().hasError()) { System.out.println(vodAsyncVCreativeTaskResponse.getResponseMetadata().getError()); System.exit(-1); } System.out.println(vodAsyncVCreativeTaskResponse.toString()); // 编码采用 UTF8 // 5. 成功提交,获取任务 ID System.out.println(vodAsyncVCreativeTaskResponse.getResponseMetadata().getRequestId()); } catch (Exception e) { e.printStackTrace(); } } }
以下示例基于您已在项目中集成 Java SDK 并初始化客户端。如果您是首次使用,请参考集成 Python SDK 文档完成基础配置。
# coding:utf-8 from __future__ import print_function from volcengine.vod.VodService import VodService from volcengine.vod.models.request.request_vod_pb2 import VodAsyncVCreativeTaskRequest import json if __name__ == '__main__': # 1. 初始化客户端 vod_service = VodService() # Configure your Access Key ID (AK) and Secret Access Key (SK) in the environment variables or in the local ~/.volc/config file. For detailed instructions, see https://www.volcengine.com/docs/4/65646. # The SDK will automatically fetch the AK and SK from the environment variables or the ~/.volc/config file as needed. # During testing, you may use the following code snippet. However, do not store the AK and SK directly in your project code to prevent potential leakage and safeguard the security of all resources associated with your account. # vod_service.set_ak('your ak') # vod_service.set_sk('your sk') try: # 2. 构建 ParamObj 字典,并序列化为字符串 paramObj = { 'input': 'vid://{your vid}', 'style': '漫画风', 'resolution': '720p' } paramStr = json.dumps(paramObj) # 3. 构建请求体 req = VodAsyncVCreativeTaskRequest() req.Uploader = "your Uploader" req.ParamStr = paramStr req.Scene = "videostyletrans" req.CallbackArgs = "your CallbackArgs" # 4. 发起调用 resp = vod_service.async_v_creative_task(req) except Exception: raise else: l = json.loads(resp) print(json.dumps(l, ensure_ascii=False, indent=4)) print("****")
以下示例基于您已在项目中集成 Java SDK 并初始化客户端。如果您是首次使用,请参考集成 PHP SDK 文档完成基础配置。
<?php require('../../vendor/autoload.php'); // Create a VOD instance in the specified region. // $client = VolcServiceVodVod::getInstance('cn-north-1'); $client = VolcServiceVodVod::getInstance(); // Configure your Access Key ID (AK) and Secret Access Key (SK) in the environment variables or in the local ~/.volc/config file. For detailed instructions, see https://www.volcengine.com/docs/4/4408. // The SDK will automatically fetch the AK and SK from the environment variables or the ~/.volc/config file as needed. // During testing, you may use the following code snippet. However, do not store the AK and SK directly in your project code to prevent potential leakage and safeguard the security of all resources associated with your account. // $client->setAccessKey('your ak'); // $client->setSecretKey('your sk'); $paramObj = [ 'input' => 'vid://{your vid}}', 'style' => '漫画风', 'resolution' => '720p', ]; $paramStr = json_encode($paramObj); $request = new VolcServiceVodModelsRequestVodAsyncVCreativeTaskRequest(); $request->setUploader("your Uploader"); $request->setParamStr($paramStr); $request->setScene("videostyletrans"); $request->setCallbackArgs("your CallbackArgs"); $response = new VolcServiceVodModelsResponseVodAsyncVCreativeTaskResponse(); try { $response = $client->asyncVCreativeTask($request); } catch (Exception $e) { echo $e, " "; } catch (Throwable $e) { echo $e, " "; } if ($response != null && $response->getResponseMetadata() != null && $response->getResponseMetadata()->getError() != null) { echo $response->getResponseMetadata()->getError()->serializeToJsonString(), " "; } else { echo $response->serializeToJsonString(), " "; }
以下示例基于您已在项目中集成 Java SDK 并初始化客户端。如果您是首次使用,请参考集成 Go SDK 文档完成基础配置。
package vod import ( "encoding/json" "fmt" "github.com/volcengine/volc-sdk-golang/base" "testing" "github.com/volcengine/volc-sdk-golang/service/vod" "github.com/volcengine/volc-sdk-golang/service/vod/models/request" ) func Test_AsyncVCreativeTask(t *testing.T) { // Create a VOD instance in the specified region. // instance := vod.NewInstanceWithRegion("cn-north-1") instance := vod.NewInstance() // Configure your Access Key ID (AK) and Secret Access Key (SK) in the environment variables or in the local ~/.volc/config file. For detailed instructions, see https://www.volcengine.com/docs/4/65655. // The SDK will automatically fetch the AK and SK from the environment variables or the ~/.volc/config file as needed. // During testing, you may use the following code snippet. However, do not store the AK and SK directly in your project code to prevent potential leakage and safeguard the security of all resources associated with your account. instance.SetCredential(base.Credentials{ AccessKeyID: "your ak", SecretAccessKey: "your sk", }) paramObj := map[string]interface{}{ "input": "vid://{your vid}", "style": "漫画风", "resolution": "720p", } paramStr, _ := json.Marshal(paramObj) query := &request.VodAsyncVCreativeTaskRequest{ Uploader: "your Uploader", ParamStr: string(paramStr), Scene: "videostyletrans", CallbackArgs: "your CallbackArgs", } resp, status, err := instance.AsyncVCreativeTask(query) fmt.Println(status) fmt.Println(err) fmt.Println(resp.String()) }
任务提交后,系统会在后台进行异步处理。您可通过以下方式获取任务结果。
轮询 GetVCreativeTaskResult 接口并传入步骤 1 中获取的 VCreativeId 主动获取任务结果。请求示例如下:
以下 HTTP 示例仅展示核心的业务参数,省略了 Authorization 请求头中的签名计算等鉴权细节。在实际发起请求前,请参考如何调用 OpenAPI 文档,了解如何在线测试接口、获取可运行的 curl 命令以及完整的 HTTP 请求构造方法与签名机制。
GET https://vod.volcengineapi.com?Action=GetVCreativeTaskResult&Version=2018-01-01&VCreativeId=20251022v20xxxxxxxdd28d49019ebd42cf878cetob
以下示例基于您已在项目中集成 Java SDK 并初始化客户端。如果您是首次使用,请参考集成 Java SDK 文档完成基础配置。
package com.volcengine.example.vod.edit; import com.alibaba.fastjson.JSONObject; import com.volcengine.service.vod.IVodService; import com.volcengine.service.vod.impl.VodServiceImpl; import com.volcengine.service.vod.model.request.VodAsyncVCreativeTaskRequest; import com.volcengine.service.vod.model.request.VodGetVCreativeTaskResultRequest; import com.volcengine.service.vod.model.response.VodAsyncVCreativeTaskResponse; import com.volcengine.service.vod.model.response.VodGetVCreativeTaskResultResponse; public class VodGetVCreativeTaskResultDemo { public static void main(String[] args) { // Create a VOD instance in the specified region. // IVodService vodService = VodServiceImpl.getInstance("cn-north-1"); IVodService vodService = VodServiceImpl.getInstance(); // Configure your Access Key ID (AK) and Secret Access Key (SK) in the environment variables or in the local ~/.volc/config file. For detailed instructions, see https://www.volcengine.com/docs/4/65641. // The SDK will automatically fetch the AK and SK from the environment variables or the ~/.volc/config file as needed. // During testing, you may use the following code snippet. However, do not store the AK and SK directly in your project code to prevent potential leakage and safeguard the security of all resources associated with your account. // vodService.setAccessKey("your ak"); // vodService.setSecretKey("your sk"); VodGetVCreativeTaskResultRequest vodGetVCreativeTaskResultRequest = VodGetVCreativeTaskResultRequest.newBuilder() .setVCreativeId("your vcreativeId") .build(); try { VodGetVCreativeTaskResultResponse vodGetVCreativeTaskResultResponse = vodService.getVCreativeTaskResult(vodGetVCreativeTaskResultRequest); if (vodGetVCreativeTaskResultResponse.getResponseMetadata().hasError()) { System.out.println(vodGetVCreativeTaskResultResponse.getResponseMetadata().getError()); System.exit(-1); } System.out.println(vodGetVCreativeTaskResultResponse.toString()); // 编码采用UTF8 System.out.println(vodGetVCreativeTaskResultResponse.getResponseMetadata().getRequestId()); } catch (Exception e) { e.printStackTrace(); } } }
以下示例基于您已在项目中集成 Java SDK 并初始化客户端。如果您是首次使用,请参考集成 Python SDK 文档完成基础配置。
# coding:utf-8 from __future__ import print_function from volcengine.vod.VodService import VodService from volcengine.vod.models.request.request_vod_pb2 import VodGetVCreativeTaskResultRequest import json if __name__ == '__main__': # Create a VOD instance in the specified region. # vod_service = VodService('cn-north-1') vod_service = VodService() # Configure your Access Key ID (AK) and Secret Access Key (SK) in the environment variables or in the local ~/.volc/config file. For detailed instructions, see https://www.volcengine.com/docs/4/65646. # The SDK will automatically fetch the AK and SK from the environment variables or the ~/.volc/config file as needed. # During testing, you may use the following code snippet. However, do not store the AK and SK directly in your project code to prevent potential leakage and safeguard the security of all resources associated with your account. # vod_service.set_ak('your ak') # vod_service.set_sk('your sk') try: req = VodGetVCreativeTaskResultRequest() req.VCreativeId = "your VCreativeId" resp = vod_service.get_v_creative_task_result(req) except Exception: raise else: l = json.loads(resp) print(json.dumps(l, ensure_ascii=False, indent=4)) print("****")
以下示例基于您已在项目中集成 Java SDK 并初始化客户端。如果您是首次使用,请参考集成 PHP SDK 文档完成基础配置。
<?php require('../../vendor/autoload.php'); // Create a VOD instance in the specified region. // $client = VolcServiceVodVod::getInstance('cn-north-1'); $client = VolcServiceVodVod::getInstance(); // Configure your Access Key ID (AK) and Secret Access Key (SK) in the environment variables or in the local ~/.volc/config file. For detailed instructions, see https://www.volcengine.com/docs/4/4408. // The SDK will automatically fetch the AK and SK from the environment variables or the ~/.volc/config file as needed. // During testing, you may use the following code snippet. However, do not store the AK and SK directly in your project code to prevent potential leakage and safeguard the security of all resources associated with your account. // $client->setAccessKey('your ak'); // $client->setSecretKey('your sk'); $request = new VolcServiceVodModelsRequestVodGetVCreativeTaskResultRequest(); $request->setVCreativeId("your VCreativeId"); $response = new VolcServiceVodModelsResponseVodGetVCreativeTaskResultResponse(); try { $response = $client->getVCreativeTaskResult($request); } catch (Exception $e) { echo $e, " "; } catch (Throwable $e) { echo $e, " "; } if ($response != null && $response->getResponseMetadata() != null && $response->getResponseMetadata()->getError() != null) { echo $response->getResponseMetadata()->getError()->serializeToJsonString(), " "; } else { echo $response->serializeToJsonString()," "; }
以下示例基于您已在项目中集成 Java SDK 并初始化客户端。如果您是首次使用,请参考集成 Go SDK 文档完成基础配置。
package vod import ( "encoding/json" "fmt" "github.com/volcengine/volc-sdk-golang/base" "testing" "github.com/volcengine/volc-sdk-golang/service/vod" "github.com/volcengine/volc-sdk-golang/service/vod/models/request" ) func Test_GetVCreativeTaskResult(t *testing.T) { // Create a VOD instance in the specified region. // instance := vod.NewInstanceWithRegion("cn-north-1") instance := vod.NewInstance() // Configure your Access Key ID (AK) and Secret Access Key (SK) in the environment variables or in the local ~/.volc/config file. For detailed instructions, see https://www.volcengine.com/docs/4/65655. // The SDK will automatically fetch the AK and SK from the environment variables or the ~/.volc/config file as needed. // During testing, you may use the following code snippet. However, do not store the AK and SK directly in your project code to prevent potential leakage and safeguard the security of all resources associated with your account. instance.SetCredential(base.Credentials{ AccessKeyID: "your ak", SecretAccessKey: "your sk", }) query := &request.VodGetVCreativeTaskResultRequest{ VCreativeId: "your VCreativeId", } resp, status, err := instance.GetVCreativeTaskResult(query) fmt.Println(status) fmt.Println(err) fmt.Println(resp.String()) }
参考事件通知概述文档,配置一个用于接收回调的服务地址。在订阅事件时,勾选 AI 智剪任务完成事件。当任务完成时,您的服务将收到一个 EventType 为 VCreativeComplete 的 HTTP POST 请求。
无论通过哪种方式,您都需要解析 OutputJson 字段获取产物信息。OutputJson 的内容和结构取决于任务的最终 Status:
当 Status 为 success 时,OutputJson 字符串在反序列化后,结构如下:
{ "vid": "v022d2g10065d3rk***" }
字段 | 类型 | 描述 |
|---|---|---|
vid | String | 产物视频的唯一 ID。 |
当 Status 为 failed_run 时,OutputJson 字段为错误信息字符串,示例如下:
"OutputJson": "internal error: node VEdit_Track_ID error [code]=21020004, [message]={\"code\":21020004,\"error_message\":\"{\\\"code\\\":21020004,\\\"message\\\":\\\"Json数据验证不通过,异常字段:Track 0 0 TargetTime 异常信息:[] is too short\\\"}\",\"message\":\"{\\\"code\\\":21020004,\\\"message\\\":\\\"Json数据验证不通过,异常字段:Track 0 0 TargetTime 异常信息:[] is too short\\\"}\"}, [task]=e0102daa8e6d4f7b***a8c933ee08013, [srv]=VEdit"
在步骤 3 中成功获取到转绘后视频的 Vid 后,可调用 GetPlayInfo 接口来获取该视频的播放地址。成功调用后,您将从返回结果的 PlayInfoList 中获取到播放 URL,可直接用于播放器或分发。
说明
前提条件:在获取文件的公网 URL 之前,您必须为产物所在的点播空间添加并配置一个加速域名。所有 URL 都将基于此域名生成。