影片
建立 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>"
}
}