视频
创建 Runway 视频转视频任务
通过 CometAPI 使用 Runway Aleph 2,借助文本 Prompt、定时引导图像和可选的目标宽高比编辑视频。
POST
/
runwayml
/
v1
/
video_to_video
cURL
curl --request POST \
--url https://api.cometapi.com/runwayml/v1/video_to_video \
--header "Authorization: Bearer $COMETAPI_KEY" \
--header "Content-Type: application/json" \
--data '{
"model": "aleph2",
"videoUri": "https://example.com/source-video.mp4",
"promptText": "Turn the daytime scene into a snowy winter evening."
}'import os
import requests
response = requests.post(
"https://api.cometapi.com/runwayml/v1/video_to_video",
headers={"Authorization": f"Bearer {os.environ['COMETAPI_KEY']}"},
json={
"model": "aleph2",
"videoUri": "https://example.com/source-video.mp4",
"promptText": "Turn the daytime scene into a snowy winter evening."
},
)
response.raise_for_status()
print(response.json())const response = await fetch(
"https://api.cometapi.com/runwayml/v1/video_to_video",
{
method: "POST",
headers: {
Authorization: `Bearer ${process.env.COMETAPI_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"model": "aleph2",
"videoUri": "https://example.com/source-video.mp4",
"promptText": "Turn the daytime scene into a snowy winter evening."
}),
},
);
if (!response.ok) throw new Error(await response.text());
console.log(await response.json());<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.cometapi.com/runwayml/v1/video_to_video",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => 'aleph2',
'videoUri' => 'https://example.com/source-video.mp4'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.cometapi.com/runwayml/v1/video_to_video"
payload := strings.NewReader("{\n \"model\": \"aleph2\",\n \"videoUri\": \"https://example.com/source-video.mp4\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.cometapi.com/runwayml/v1/video_to_video")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"aleph2\",\n \"videoUri\": \"https://example.com/source-video.mp4\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cometapi.com/runwayml/v1/video_to_video")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"aleph2\",\n \"videoUri\": \"https://example.com/source-video.mp4\"\n}"
response = http.request(request)
puts response.read_body{
"id": "00000000-0000-4000-8000-000000000000"
}{
"code": "<string>",
"message": "<string>",
"data": "<unknown>"
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>"
}
}使用
关键帧时间戳必须位于其编辑窗口内。如果使用
如果
aleph2 通过文本 Prompt 编辑源视频。该请求会返回一个
任务 id;检索任务详细信息以获取完成的输出。
准备请求
- 使用您的 CometAPI API 密钥进行身份验证。
- 将
model设置为aleph2,并为最长 30 秒的视频提供videoUri。 - 可选:添加
promptText以描述编辑内容,长度为 1 到 1,000 个 字符。使用关键帧时,也可以省略它。 - 将示例媒体 URL 替换为可访问的 HTTPS URL。媒体字段 也接受编码大小最高为 5 MB 的 Base64 数据 URI。
添加定时引导图像
若要引导特定时刻,请在keyframes 中提供一到五个对象。
每个对象包含一个图像 uri 和且仅包含以下一种位置:
| 字段 | 含义 |
|---|---|
seconds | 从视频开始计算的时间戳,范围为 0 到 30 秒。 |
at | 视频时长的比例,范围为 0 到 1. |
range.start_seconds | 可选编辑窗口的包含式起始位置,以整数秒为单位。 |
range.end_seconds | 该窗口的排除式结束位置,以整数秒为单位;必须大于其起始位置。 |
range,
请在每个关键帧中设置它。否则,请从每个关键帧中省略 range。
不需要引导图像时,请省略 keyframes。空数组或
null 会被视为省略。
选择帧形状和格式
使用targetAspectRatio 请求扩展为 16:9、4:3、3:2、1:1
2:3, 3:4, 9:16或 21:9。生成前,输入视频和引导图像会被添加黑边以适配此形状。
已弃用的 ratio 字段
是可选的;请使用 targetAspectRatio 控制宽高比。
outputFormat | 输出 |
|---|---|
mp4 | H.264 MP4;省略该字段时使用。 |
prores | ProRes MOV。 |
png_sequence | 包含 PNG 帧的 ZIP 归档文件。 |
sdr_rec709_10bit | 10 位 Rec.709 HEVC MP4。 |
outputFormat 为 prores,可以将 proresProfile 设置为 422、4444
422 Proxy, 422 LT, 422 HQ或 4444 XQ。默认配置文件为 4444。
4444 和 4444 XQ 中的 Alpha 通道为不透明。请省略 proresProfile
以使用其他输出格式。
如需指定采样种子,请使用 1 到 4294967295。请省略 seed
以使用随机种子;0 会被视为省略。
检索结果
保存返回的id 并使用
获取 Runway 任务 检索任务状态。
当 status 为 SUCCEEDED 时,从 output 读取结果 URL。如果任务
失败,请在存在时检查 failure 和 failureCode。请求体
application/json
Aleph 2 video-editing request.
响应
The task was created. Save its id for task retrieval.
最后修改于 2026年9月22日
⌘I
cURL
curl --request POST \
--url https://api.cometapi.com/runwayml/v1/video_to_video \
--header "Authorization: Bearer $COMETAPI_KEY" \
--header "Content-Type: application/json" \
--data '{
"model": "aleph2",
"videoUri": "https://example.com/source-video.mp4",
"promptText": "Turn the daytime scene into a snowy winter evening."
}'import os
import requests
response = requests.post(
"https://api.cometapi.com/runwayml/v1/video_to_video",
headers={"Authorization": f"Bearer {os.environ['COMETAPI_KEY']}"},
json={
"model": "aleph2",
"videoUri": "https://example.com/source-video.mp4",
"promptText": "Turn the daytime scene into a snowy winter evening."
},
)
response.raise_for_status()
print(response.json())const response = await fetch(
"https://api.cometapi.com/runwayml/v1/video_to_video",
{
method: "POST",
headers: {
Authorization: `Bearer ${process.env.COMETAPI_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"model": "aleph2",
"videoUri": "https://example.com/source-video.mp4",
"promptText": "Turn the daytime scene into a snowy winter evening."
}),
},
);
if (!response.ok) throw new Error(await response.text());
console.log(await response.json());<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.cometapi.com/runwayml/v1/video_to_video",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => 'aleph2',
'videoUri' => 'https://example.com/source-video.mp4'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.cometapi.com/runwayml/v1/video_to_video"
payload := strings.NewReader("{\n \"model\": \"aleph2\",\n \"videoUri\": \"https://example.com/source-video.mp4\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.cometapi.com/runwayml/v1/video_to_video")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"aleph2\",\n \"videoUri\": \"https://example.com/source-video.mp4\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cometapi.com/runwayml/v1/video_to_video")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"aleph2\",\n \"videoUri\": \"https://example.com/source-video.mp4\"\n}"
response = http.request(request)
puts response.read_body{
"id": "00000000-0000-4000-8000-000000000000"
}{
"code": "<string>",
"message": "<string>",
"data": "<unknown>"
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>"
}
}