Video
Tạo tác vụ video-sang-video Runway
Chỉnh sửa video bằng Runway Aleph 2 qua CometAPI, sử dụng Prompt văn bản, hình ảnh hướng dẫn theo thời điểm và tỷ lệ khung hình mục tiêu tùy chọn.
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>"
}
}Dùng
Dấu thời gian keyframe phải nằm trong cửa sổ chỉnh sửa của nó. Nếu bạn dùng
Nếu
aleph2 để chỉnh sửa video nguồn bằng Prompt văn bản. Yêu cầu trả về một
tác vụ id; truy xuất thông tin chi tiết của tác vụ để lấy đầu ra hoàn tất.
Chuẩn bị yêu cầu
- Xác thực bằng API key CometAPI của bạn.
- Đặt
modelthànhaleph2và cung cấpvideoUricho video dài tối đa 30 giây. - Tùy chọn: thêm
promptTextđể mô tả nội dung chỉnh sửa, với độ dài từ 1 đến 1.000 ký tự. Bạn cũng có thể bỏ qua tham số này khi sử dụng keyframe. - Thay URL phương tiện mẫu bằng URL HTTPS có thể truy cập. Các trường phương tiện cũng chấp nhận URI dữ liệu Base64 có kích thước mã hóa tối đa 5 MB.
Thêm hình ảnh hướng dẫn theo thời điểm
Để hướng dẫn các thời điểm cụ thể, hãy cung cấp từ một đến năm đối tượng trongkeyframes.
Mỗi đối tượng chứa một uri hình ảnh và chính xác một vị trí:
| Trường | Ý nghĩa |
|---|---|
seconds | Dấu thời gian tính từ đầu video, từ 0 đến 30 giây. |
at | Phần tỷ lệ của thời lượng video, từ 0 đến 1. |
range.start_seconds | Điểm bắt đầu bao gồm của cửa sổ chỉnh sửa tùy chọn, tính bằng số giây nguyên. |
range.end_seconds | Điểm kết thúc không bao gồm của cửa sổ đó, tính bằng số giây nguyên; phải lớn hơn điểm bắt đầu. |
range,
hãy đặt tham số này trên mọi keyframe. Nếu không, hãy bỏ range khỏi mọi keyframe.
Bỏ keyframes khi không cần hình ảnh hướng dẫn. Mảng trống hoặc
null được coi như bỏ qua.
Chọn hình dạng và định dạng khung hình
DùngtargetAspectRatio để yêu cầu mở rộng thành 16:9, 4:3, 3:2, 1:1,
2:3, 3:4, 9:16, hoặc 21:9. Video đầu vào và hình ảnh hướng dẫn được
thêm viền đen để phù hợp với hình dạng này trước khi tạo. Trường ratio đã ngừng hỗ trợ
là tùy chọn; dùng targetAspectRatio để kiểm soát tỷ lệ khung hình.
outputFormat | Đầu ra |
|---|---|
mp4 | H.264 MP4; được dùng khi bỏ qua trường này. |
prores | ProRes MOV. |
png_sequence | Tệp lưu trữ ZIP chứa các khung hình PNG. |
sdr_rec709_10bit | MP4 HEVC Rec.709 10-bit. |
outputFormat là prores, bạn có thể đặt proresProfile thành 422, 4444,
422 Proxy, 422 LT, 422 HQ, hoặc 4444 XQ. Profile mặc định là 4444.
Kênh alpha trong 4444 và 4444 XQ là đục. Bỏ proresProfile
đối với các định dạng đầu ra khác.
Để đặt seed lấy mẫu cụ thể, dùng 1 đến 4294967295. Bỏ seed
để dùng seed ngẫu nhiên; 0 được coi như bỏ qua.
Truy xuất kết quả
Lưuid được trả về và dùng
Lấy tác vụ Runway để truy xuất trạng thái tác vụ.
Khi status là SUCCEEDED, đọc các URL kết quả từ output. Nếu tác vụ
thất bại, hãy kiểm tra failure và failureCode nếu có.Nội dung
application/json
Aleph 2 video-editing request.
Phản hồi
The task was created. Save its id for task retrieval.
Lần sửa đổi cuối 22 tháng 9, 2026
⌘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>"
}
}