萬相2.7-視頻編輯API參考
萬相2.7-視頻編輯模型,支援輸入多模態(文本/映像/視頻),可完成指令編輯和視頻遷移任務。
相關文檔:指南文檔
適用範圍
為確保調用成功,請務必保證模型、endpoint URL 和 API Key 均屬於同一地區。跨地區調用將會失敗。
選擇模型:確認模型所屬的地區。
選擇 URL:選擇對應的地區 Endpoint URL,支援HTTP URL或 DashScope SDK URL。
配置 API Key:擷取該地區的API Key,再配置API Key到環境變數。
本文的範例程式碼適用於新加坡地區。
新加坡地區的舊版網域名稱 https://dashscope-intl.aliyuncs.com 即將下線,請及時遷移到新版網域名稱 https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com。
HTTP調用
視頻編輯任務耗時較長(通常為1-5分鐘),API採用非同步呼叫的方式。整個流程包含 “建立任務 -> 輪詢擷取” 兩個核心步驟,具體如下:
步驟1:建立任務擷取任務ID
新加坡
POST https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis
調用時請將WorkspaceId替換為真實的Workspace ID。
北京
POST https://dashscope.aliyuncs.com/api/v1/services/aigc/video-generation/video-synthesis
-
建立成功後,使用介面返回的
task_id查詢結果,task_id 有效期間為 24 小時。請勿重複建立任務,輪詢擷取即可。 -
新手指引請參見Postman。
請求參數 | 純指令編輯(修改視頻風格)指令+參考圖編輯(本機覆寫) |
Content-Type 請求內容類型。此參數必須設定為 | |
Authorization 請求身份認證。介面使用阿里雲百鍊API Key進行身份認證。樣本值:Bearer sk-xxxx。 | |
X-DashScope-Async 非同步處理配置參數。HTTP請求只支援非同步,必須設定為 重要
缺少此要求標頭將報錯:“current user api does not support synchronous calls”。 | |
請求體(Request Body) | |
model 模型名稱。 樣本值:wan2.7-videoedit。 | |
input 輸入的基本資料,如提示詞等。 | |
parameters 視頻處理參數,如設定視頻解析度、設定視頻時間長度、開啟prompt智能改寫、添加浮水印等。 |
響應參數 | 成功響應請儲存 task_id,用於查詢任務狀態與結果。
異常響應建立任務失敗,請參見錯誤碼進行解決。
|
output 任務輸出資訊。 | |
request_id 請求唯一標識。可用於請求明細溯源和問題排查。 | |
code 請求失敗的錯誤碼。請求成功時不會返回此參數,詳情請參見錯誤碼。 | |
message 請求失敗的詳細資料。請求成功時不會返回此參數,詳情請參見錯誤碼。 |
步驟2:根據任務ID查詢結果
新加坡
GET https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/tasks/{task_id}
調用時請將WorkspaceId替換為真實的Workspace ID。
北京
GET https://dashscope.aliyuncs.com/api/v1/tasks/{task_id}
-
輪詢建議:視頻產生過程約需數分鐘,建議採用輪詢機制,並設定合理的查詢間隔(如 15 秒)來擷取結果。
-
任務狀態流轉:PENDING(排隊中)→ RUNNING(處理中)→ SUCCEEDED(成功)/ FAILED(失敗)。
-
結果連結:任務成功後返回視頻連結,有效期間為 24 小時。建議在擷取連結後立即下載並轉存至永久儲存(如阿里雲 OSS)。
-
task_id 有效期間:24小時,逾時後將無法查詢結果,介面將返回任務狀態為
UNKNOWN。
請求參數 | 查詢任務結果將 |
要求標頭(Headers) | |
Authorization 請求身份認證。介面使用阿里雲百鍊API Key進行身份認證。樣本值:Bearer sk-xxxx。 | |
URL路徑參數(Path parameters) | |
task_id 任務ID。 |
響應參數 | 任務執行成功視頻URL僅保留24小時,逾時後會被自動清除,請及時儲存產生的視頻。 任務執行失敗若任務執行失敗,task_status將置為 FAILED,並提供錯誤碼和資訊。請參見錯誤碼進行解決。 任務查詢到期task_id查詢有效期間為 24 小時,逾時後將無法查詢,返回以下報錯資訊。
|
output 任務輸出資訊。 | |
usage 輸出資訊統計,只對成功的結果計數。 | |
request_id 請求唯一標識。可用於請求明細溯源和問題排查。 |
DashScope SDK調用
SDK 的參數命名與HTTP介面基本一致,參數結構根據語言特性進行封裝。
由於視頻編輯任務耗時較長(通常為1-5分鐘),SDK 在底層封裝了 HTTP 非同步呼叫流程,支援同步、非同步兩種調用方式。
具體耗時受限於排隊任務數和服務執行情況,請在擷取結果時耐心等待。
Python SDK調用
請確保 DashScope Python SDK 版本不低於 1.25.16,再運行以下代碼。
若版本過低,可能會觸發 "url error, please check url!" 等錯誤。請參考安裝SDK進行更新。
根據模型所在地區設定 base_http_api_url:
新加坡
dashscope.base_http_api_url = 'https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1'
調用時請將WorkspaceId替換為真實的Workspace ID。
北京
dashscope.base_http_api_url = 'https://dashscope.aliyuncs.com/api/v1'
同步調用
請求樣本
import base64
import mimetypes
from http import HTTPStatus
from dashscope import VideoSynthesis
import dashscope
import os
# 以下為新加坡地區URL,各地區的URL不同
dashscope.base_http_api_url = 'https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1'
# 若沒有配置環境變數,請用百鍊API Key將下行替換為:api_key="sk-xxx"
# 各地區的API Key不同。擷取API Key:https://www.alibabacloud.com/help/en/model-studio/get-api-key
api_key = os.getenv("DASHSCOPE_API_KEY")
# 格式為 data:{MIME_type};base64,{base64_data}
def encode_file(file_path):
mime_type, _ = mimetypes.guess_type(file_path)
if not mime_type or not mime_type.startswith("image/"):
raise ValueError("不支援或無法識別的映像格式")
with open(file_path, "rb") as image_file:
encoded_string = base64.b64encode(image_file.read()).decode('utf-8')
return f"data:{mime_type};base64,{encoded_string}"
# 參考映像URL,支援以下三種輸入方式
# 【方式一】使用公網圖片URL
reference_image_url = "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260402/fwjpqf/wan2.7-videoedit-change-clothes.png"
# 【方式二】使用本地檔案(支援絕對路徑和相對路徑)
# 格式要求:file:// + 檔案路徑
# 樣本(絕對路徑):
# reference_image_url = "file://" + "/path/to/image.png" # Linux/macOS
# reference_image_url = "file://" + "C:/path/to/image.png" # Windows
# 樣本(相對路徑):
# reference_image_url = "file://" + "./image.png" # 相對當前執行檔案的路徑
# 【方式三】使用Base64編碼
# reference_image_url = encode_file("/path/to/image.png")
def sample_sync_call_videoedit():
# call sync api, will return the result
print('please wait...')
rsp = VideoSynthesis.call(
api_key=api_key,
model='wan2.7-videoedit',
prompt='將視頻中女孩的衣服替換為圖片中的衣服',
media=[
{
"type": "video",
"url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260403/nlspwm/T2VA_22.mp4"
},
{
"type": "reference_image",
"url": reference_image_url
}
],
resolution='720P',
prompt_extend=True,
watermark=True)
print(rsp)
if rsp.status_code == HTTPStatus.OK:
print(rsp.output.video_url)
else:
print('Failed, status_code: %s, code: %s, message: %s' %
(rsp.status_code, rsp.code, rsp.message))
if __name__ == '__main__':
sample_sync_call_videoedit()響應樣本
video_url 有效期間24小時,請及時下載視頻。{
"status_code": 200,
"request_id": "d6c3c865-34e9-98a9-a53d-xxxxxx",
"code": null,
"message": "",
"output": {
"task_id": "1de7c853-755a-454a-91bc-xxxxxx",
"task_status": "SUCCEEDED",
"video_url": "https://dashscope-a717.oss-accelerate.aliyuncs.com/xxx.mp4?Expires=xxxx",
"submit_time": "2026-04-10 17:16:30.821",
"scheduled_time": "2026-04-10 17:16:46.379",
"end_time": "2026-04-10 17:24:59.352",
"orig_prompt": "將視頻中女孩的衣服替換為圖片中的衣服"
},
"usage": {
"video_count": 1,
"video_duration": 0,
"video_ratio": "",
"duration": 10.08,
"input_video_duration": 5.04,
"output_video_duration": 5.04,
"SR": 720
}
}非同步呼叫
請求樣本
import base64
import mimetypes
from http import HTTPStatus
from dashscope import VideoSynthesis
import dashscope
import os
# 以下為新加坡地區URL,各地區的URL不同
dashscope.base_http_api_url = 'https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1'
# 若沒有配置環境變數,請用百鍊API Key將下行替換為:api_key="sk-xxx"
# 各地區的API Key不同。擷取API Key:https://www.alibabacloud.com/help/en/model-studio/get-api-key
api_key = os.getenv("DASHSCOPE_API_KEY")
# 格式為 data:{MIME_type};base64,{base64_data}
def encode_file(file_path):
mime_type, _ = mimetypes.guess_type(file_path)
if not mime_type or not mime_type.startswith("image/"):
raise ValueError("不支援或無法識別的映像格式")
with open(file_path, "rb") as image_file:
encoded_string = base64.b64encode(image_file.read()).decode('utf-8')
return f"data:{mime_type};base64,{encoded_string}"
# 參考映像URL,支援以下三種輸入方式
# 【方式一】使用公網圖片URL
reference_image_url = "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260402/fwjpqf/wan2.7-videoedit-change-clothes.png"
# 【方式二】使用本地檔案(支援絕對路徑和相對路徑)
# 格式要求:file:// + 檔案路徑
# 樣本(絕對路徑):
# reference_image_url = "file://" + "/path/to/image.png" # Linux/macOS
# reference_image_url = "file://" + "C:/path/to/image.png" # Windows
# 樣本(相對路徑):
# reference_image_url = "file://" + "./image.png" # 相對當前執行檔案的路徑
# 【方式三】使用Base64編碼
# reference_image_url = encode_file("/path/to/image.png")
def sample_async_call_videoedit():
# call async api, will return the task information
# you can get task status with the returned task id.
rsp = VideoSynthesis.async_call(
api_key=api_key,
model='wan2.7-videoedit',
prompt='將視頻中女孩的衣服替換為圖片中的衣服',
media=[
{
"type": "video",
"url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260403/nlspwm/T2VA_22.mp4"
},
{
"type": "reference_image",
"url": reference_image_url
}
],
resolution='720P',
prompt_extend=True,
watermark=True)
print(rsp)
if rsp.status_code == HTTPStatus.OK:
print("task_id: %s" % rsp.output.task_id)
else:
print('Failed, status_code: %s, code: %s, message: %s' %
(rsp.status_code, rsp.code, rsp.message))
# get the task information include the task status.
status = VideoSynthesis.fetch(task=rsp, api_key=api_key)
if status.status_code == HTTPStatus.OK:
print(status.output.task_status) # check the task status
else:
print('Failed, status_code: %s, code: %s, message: %s' %
(status.status_code, status.code, status.message))
# wait the task complete, will call fetch interval, and check it's in finished status.
rsp = VideoSynthesis.wait(task=rsp, api_key=api_key)
print(rsp)
if rsp.status_code == HTTPStatus.OK:
print(rsp.output.video_url)
else:
print('Failed, status_code: %s, code: %s, message: %s' %
(rsp.status_code, rsp.code, rsp.message))
if __name__ == '__main__':
sample_async_call_videoedit()響應樣本
1、建立任務的響應樣本
{
"status_code": 200,
"request_id": "f16ae7e9-d518-92f8-a02c-xxxxxx",
"code": "",
"message": "",
"output": {
"task_id": "05e68c7e-850c-49e4-b866-xxxxxx",
"task_status": "PENDING",
"video_url": ""
},
"usage": null
}2、查詢任務結果的響應樣本
video_url 有效期間24小時,請及時下載視頻。{
"status_code": 200,
"request_id": "d6c3c865-34e9-98a9-a53d-xxxxxx",
"code": null,
"message": "",
"output": {
"task_id": "1de7c853-755a-454a-91bc-xxxxxx",
"task_status": "SUCCEEDED",
"video_url": "https://dashscope-a717.oss-accelerate.aliyuncs.com/xxx.mp4?Expires=xxxx",
"submit_time": "2026-04-10 17:16:30.821",
"scheduled_time": "2026-04-10 17:16:46.379",
"end_time": "2026-04-10 17:24:59.352",
"orig_prompt": "將視頻中女孩的衣服替換為圖片中的衣服"
},
"usage": {
"video_count": 1,
"video_duration": 0,
"video_ratio": "",
"duration": 10.08,
"input_video_duration": 5.04,
"output_video_duration": 5.04,
"SR": 720
}
}Java SDK調用
請確保 DashScope Java SDK 版本不低於 2.22.14,再運行以下代碼。
若版本過低,可能會觸發 "url error, please check url!" 等錯誤。請參考安裝SDK進行更新。
根據模型所在地區設定 Constants.baseHttpApiUrl:
新加坡
Constants.baseHttpApiUrl = "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1";
調用時請將WorkspaceId替換為真實的Workspace ID。
北京
Constants.baseHttpApiUrl = "https://dashscope.aliyuncs.com/api/v1";
同步調用
請求樣本
// Copyright (c) Alibaba, Inc. and its affiliates.
import com.alibaba.dashscope.aigc.videosynthesis.VideoSynthesis;
import com.alibaba.dashscope.aigc.videosynthesis.VideoSynthesisParam;
import com.alibaba.dashscope.aigc.videosynthesis.VideoSynthesisResult;
import com.alibaba.dashscope.exception.ApiException;
import com.alibaba.dashscope.exception.InputRequiredException;
import com.alibaba.dashscope.exception.NoApiKeyException;
import com.alibaba.dashscope.utils.JsonUtils;
import com.alibaba.dashscope.utils.Constants;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Base64;
public class VideoEdit {
static {
// 以下為新加坡地區url,各地區的url不同
Constants.baseHttpApiUrl = "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1";
}
// 若沒有配置環境變數,請用百鍊API Key將下行替換為:apiKey="sk-xxx"
// 各地區的API Key不同。擷取API Key:https://www.alibabacloud.com/help/en/model-studio/get-api-key
public static String apiKey = System.getenv("DASHSCOPE_API_KEY");
// 參考映像URL,支援以下三種輸入方式
// 【方式一】使用公網圖片URL
static String referenceImageUrl = "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260402/fwjpqf/wan2.7-videoedit-change-clothes.png";
// 【方式二】使用本地檔案(支援絕對路徑和相對路徑)
// 格式要求:file:// + 檔案路徑
// 樣本(絕對路徑):
// static String referenceImageUrl = "file://" + "/path/to/image.png"; // Linux/macOS
// static String referenceImageUrl = "file://" + "C:/path/to/image.png"; // Windows
// 樣本(相對路徑):
// static String referenceImageUrl = "file://" + "./image.png"; // 相對當前執行檔案的路徑
// 【方式三】使用Base64編碼
// static String referenceImageUrl = encodeFile("/path/to/image.png");
// 格式為 data:{MIME_type};base64,{base64_data}
public static String encodeFile(String filePath) {
Path path = Paths.get(filePath);
if (!Files.exists(path)) {
throw new IllegalArgumentException("檔案不存在: " + filePath);
}
String mimeType = null;
try {
mimeType = Files.probeContentType(path);
} catch (IOException e) {
throw new IllegalArgumentException("無法檢測檔案類型: " + filePath);
}
if (mimeType == null || !mimeType.startsWith("image/")) {
throw new IllegalArgumentException("不支援或無法識別的映像格式");
}
byte[] fileBytes = null;
try {
fileBytes = Files.readAllBytes(path);
} catch (IOException e) {
throw new IllegalArgumentException("無法讀取檔案內容: " + filePath);
}
String encodedString = Base64.getEncoder().encodeToString(fileBytes);
return "data:" + mimeType + ";base64," + encodedString;
}
public static void videoEdit() throws ApiException, NoApiKeyException, InputRequiredException {
VideoSynthesis vs = new VideoSynthesis();
List<VideoSynthesisParam.Media> media = new ArrayList<VideoSynthesisParam.Media>(){{
add(VideoSynthesisParam.Media.builder()
.url("https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260403/nlspwm/T2VA_22.mp4")
.type("video")
.build());
add(VideoSynthesisParam.Media.builder()
.url(referenceImageUrl)
.type("reference_image")
.build());
}};
Map<String, Object> parameters = new HashMap<>();
parameters.put("resolution", "720P");
parameters.put("prompt_extend", true);
parameters.put("watermark", true);
VideoSynthesisParam param =
VideoSynthesisParam.builder()
.apiKey(apiKey)
.model("wan2.7-videoedit")
.prompt("將視頻中女孩的衣服替換為圖片中的衣服")
.media(media)
.parameters(parameters)
.build();
System.out.println("please wait...");
VideoSynthesisResult result = vs.call(param);
System.out.println(JsonUtils.toJson(result));
}
public static void main(String[] args) {
try {
videoEdit();
} catch (ApiException | NoApiKeyException | InputRequiredException e) {
System.out.println(e.getMessage());
}
System.exit(0);
}
}響應樣本
video_url 有效期間24小時,請及時下載視頻。{
"request_id": "0a15ad3c-cde7-9f7e-b8d2-xxxxxx",
"output": {
"task_id": "0025d1e1-009a-4f53-9c27-xxxxx",
"task_status": "SUCCEEDED",
"video_url": "https://dashscope-a717.oss-accelerate.aliyuncs.com/xxx.mp4?Expires=xxx",
"orig_prompt": "將視頻中女孩的衣服替換為圖片中的衣服",
"submit_time": "2026-04-10 17:21:01.719",
"scheduled_time": "2026-04-10 17:21:13.182",
"end_time": "2026-04-10 17:31:41.286"
},
"usage": {
"video_count": 1,
"duration": 10.08,
"input_video_duration": 5.04,
"output_video_duration": 5.04,
"SR": "720"
},
"status_code": 200,
"code": "",
"message": ""
}非同步呼叫
請求樣本
// Copyright (c) Alibaba, Inc. and its affiliates.
import com.alibaba.dashscope.aigc.videosynthesis.VideoSynthesis;
import com.alibaba.dashscope.aigc.videosynthesis.VideoSynthesisParam;
import com.alibaba.dashscope.aigc.videosynthesis.VideoSynthesisResult;
import com.alibaba.dashscope.aigc.videosynthesis.VideoSynthesisListResult;
import com.alibaba.dashscope.exception.ApiException;
import com.alibaba.dashscope.exception.InputRequiredException;
import com.alibaba.dashscope.exception.NoApiKeyException;
import com.alibaba.dashscope.task.AsyncTaskListParam;
import com.alibaba.dashscope.utils.JsonUtils;
import com.alibaba.dashscope.utils.Constants;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Base64;
public class VideoEdit {
static {
// 以下為新加坡地區url,各地區的url不同
Constants.baseHttpApiUrl = "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1";
}
// 若沒有配置環境變數,請用百鍊API Key將下行替換為:apiKey="sk-xxx"
// 各地區的API Key不同。擷取API Key:https://www.alibabacloud.com/help/en/model-studio/get-api-key
public static String apiKey = System.getenv("DASHSCOPE_API_KEY");
// 參考映像URL,支援以下三種輸入方式
// 【方式一】使用公網圖片URL
static String referenceImageUrl = "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260402/fwjpqf/wan2.7-videoedit-change-clothes.png";
// 【方式二】使用本地檔案(支援絕對路徑和相對路徑)
// 格式要求:file:// + 檔案路徑
// 樣本(絕對路徑):
// static String referenceImageUrl = "file://" + "/path/to/image.png"; // Linux/macOS
// static String referenceImageUrl = "file://" + "C:/path/to/image.png"; // Windows
// 樣本(相對路徑):
// static String referenceImageUrl = "file://" + "./image.png"; // 相對當前執行檔案的路徑
// 【方式三】使用Base64編碼
// static String referenceImageUrl = encodeFile("/path/to/image.png");
// 格式為 data:{MIME_type};base64,{base64_data}
public static String encodeFile(String filePath) {
Path path = Paths.get(filePath);
if (!Files.exists(path)) {
throw new IllegalArgumentException("檔案不存在: " + filePath);
}
String mimeType = null;
try {
mimeType = Files.probeContentType(path);
} catch (IOException e) {
throw new IllegalArgumentException("無法檢測檔案類型: " + filePath);
}
if (mimeType == null || !mimeType.startsWith("image/")) {
throw new IllegalArgumentException("不支援或無法識別的映像格式");
}
byte[] fileBytes = null;
try {
fileBytes = Files.readAllBytes(path);
} catch (IOException e) {
throw new IllegalArgumentException("無法讀取檔案內容: " + filePath);
}
String encodedString = Base64.getEncoder().encodeToString(fileBytes);
return "data:" + mimeType + ";base64," + encodedString;
}
public static void videoEdit() throws ApiException, NoApiKeyException, InputRequiredException {
VideoSynthesis vs = new VideoSynthesis();
List<VideoSynthesisParam.Media> media = new ArrayList<VideoSynthesisParam.Media>(){{
add(VideoSynthesisParam.Media.builder()
.url("https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20260403/nlspwm/T2VA_22.mp4")
.type("video")
.build());
add(VideoSynthesisParam.Media.builder()
.url(referenceImageUrl)
.type("reference_image")
.build());
}};
Map<String, Object> parameters = new HashMap<>();
parameters.put("resolution", "720P");
parameters.put("prompt_extend", true);
parameters.put("watermark", true);
VideoSynthesisParam param =
VideoSynthesisParam.builder()
.apiKey(apiKey)
.model("wan2.7-videoedit")
.prompt("將視頻中女孩的衣服替換為圖片中的衣服")
.media(media)
.parameters(parameters)
.build();
// 非同步呼叫
VideoSynthesisResult task = vs.asyncCall(param);
System.out.println(JsonUtils.toJson(task));
System.out.println("please wait...");
// 擷取結果
VideoSynthesisResult result = vs.wait(task, apiKey);
System.out.println(JsonUtils.toJson(result));
}
// 擷取工作清單
public static void listTask() throws ApiException, NoApiKeyException {
VideoSynthesis is = new VideoSynthesis();
AsyncTaskListParam param = AsyncTaskListParam.builder().build();
param.setApiKey(apiKey);
VideoSynthesisListResult result = is.list(param);
System.out.println(result);
}
// 擷取單個任務結果
public static void fetchTask(String taskId) throws ApiException, NoApiKeyException {
VideoSynthesis is = new VideoSynthesis();
// 如果已設定 DASHSCOPE_API_KEY 為環境變數,apiKey 可為空白
VideoSynthesisResult result = is.fetch(taskId, apiKey);
System.out.println(result.getOutput());
System.out.println(result.getUsage());
}
public static void main(String[] args) {
try {
videoEdit();
} catch (ApiException | NoApiKeyException | InputRequiredException e) {
System.out.println(e.getMessage());
}
System.exit(0);
}
}響應樣本
1、建立任務的響應樣本
{
"request_id": "f16ae7e9-d518-92f8-a02c-xxxxxx",
"output": {
"task_id": "05e68c7e-850c-49e4-b866-xxxxxx",
"task_status": "PENDING",
"video_url": ""
},
"usage": null,
"status_code": 200,
"code": "",
"message": ""
}2、查詢任務結果的響應樣本
video_url 有效期間24小時,請及時下載視頻。{
"request_id": "0a15ad3c-cde7-9f7e-b8d2-xxxxxx",
"output": {
"task_id": "0025d1e1-009a-4f53-9c27-xxxxx",
"task_status": "SUCCEEDED",
"video_url": "https://dashscope-a717.oss-accelerate.aliyuncs.com/xxx.mp4?Expires=xxx",
"orig_prompt": "將視頻中女孩的衣服替換為圖片中的衣服",
"submit_time": "2026-04-10 17:21:01.719",
"scheduled_time": "2026-04-10 17:21:13.182",
"end_time": "2026-04-10 17:31:41.286"
},
"usage": {
"video_count": 1,
"duration": 10.08,
"input_video_duration": 5.04,
"output_video_duration": 5.04,
"SR": "720"
},
"status_code": 200,
"code": "",
"message": ""
}錯誤碼
如果模型調用失敗並返回報錯資訊,請參見錯誤碼進行解決。