首尾帧视频 API
部分视频模型支持 frames_to_video,需要 start_frame,并可选传入 end_frame。当你同时关心起始构图和最终构图时,适合使用这个工作流。
适用场景
- 产品变化视频
- 室内装修前后对比
- 角色在两个姿态之间运动
- 品牌可控转场
Veo 3.1 Fast 示例
curl https://img2vid.net/api/v1/generations \
-H "Authorization: Bearer $BUBLE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "google/veo3.1-fast",
"mode": "frames_to_video",
"prompt": "Create an elegant transformation from the first frame to the final frame with smooth cinematic camera movement and realistic lighting continuity",
"start_frame": "https://example.com/start.png",
"end_frame": "https://example.com/end.png",
"duration": "8s",
"resolution": "720p",
"aspect_ratio": "16:9"
}'
支持首尾帧的模型
google/veo3.1-fastgoogle/veo3.1-qualitydoubao/seedance-2.0-fastdoubao/seedance-2.0doubao/seedance-1.5-prokling/kling-v3
min_files: 1 表示只传首帧即可。只有需要控制结尾画面时再传 end_frame。
SDK 示例
下面的 SDK 代码与上方 HTTP 示例使用同一套公开 API 结构:model、mode、prompt、媒体 URL 等稳定字段直接传入,模型专属选项保持为扁平的生成参数。
TypeScript / JavaScript
import { Buble } from '@buble/sdk';
const buble = new Buble();
const task = await buble.generations.create({
model: 'google/veo3.1-fast',
mode: 'frames_to_video',
prompt:
'Create an elegant transformation from the first frame to the final frame with smooth cinematic camera movement and realistic lighting continuity',
start_frame: 'https://example.com/start.png',
end_frame: 'https://example.com/end.png',
duration: '8s',
resolution: '720p',
aspect_ratio: '16:9',
});
const result = await buble.generations.wait(task.data.id);
console.log(result.data);
Python
from buble_ai import Buble
client = Buble()
task = client.generations.create(
model='google/veo3.1-fast',
mode='frames_to_video',
prompt='Create an elegant transformation from the first frame to the final frame with smooth cinematic camera movement and realistic lighting continuity',
start_frame='https://example.com/start.png',
end_frame='https://example.com/end.png',
duration='8s',
resolution='720p',
aspect_ratio='16:9',
)
result = client.generations.wait(task["data"]["id"])
print(result["data"])
Go
package main
import (
"context"
"fmt"
"log"
buble "github.com/bublehq/sdks/go"
)
func main() {
ctx := context.Background()
client := buble.NewClient()
task, err := client.Generations.Create(ctx, &buble.CreateGenerationRequest{
Model: "google/veo3.1-fast",
Mode: "frames_to_video",
Prompt: "Create an elegant transformation from the first frame to the final frame with smooth cinematic camera movement and realistic lighting continuity",
StartFrame: "https://example.com/start.png",
EndFrame: "https://example.com/end.png",
Params: map[string]any{
"duration": "8s",
"resolution": "720p",
"aspect_ratio": "16:9",
},
})
if err != nil {
log.Fatal(err)
}
result, err := client.Generations.Wait(ctx, task.Data.ID)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%+v\n", result.Data)
}
Rust
use buble::{Client, CreateGenerationRequest, WaitOptions};
#[tokio::main]
async fn main() -> buble::Result<()> {
let client = Client::from_env();
let task = client
.generations()
.create(
CreateGenerationRequest::new("google/veo3.1-fast")
.mode("frames_to_video")
.prompt("Create an elegant transformation from the first frame to the final frame with smooth cinematic camera movement and realistic lighting continuity")
.start_frame("https://example.com/start.png")
.end_frame("https://example.com/end.png")
.param("duration", "8s")?
.param("resolution", "720p")?
.param("aspect_ratio", "16:9")?,
)
.await?;
let result = client
.generations()
.wait(&task.data.id, WaitOptions::default())
.await?;
println!("{:?}", result.data);
Ok(())
}
Swift
import Buble
let client = try BubleClient.fromEnvironment()
let task = try await client.generations.create(
try CreateGenerationRequest(model: "google/veo3.1-fast")
.mode("frames_to_video")
.prompt("Create an elegant transformation from the first frame to the final frame with smooth cinematic camera movement and realistic lighting continuity")
.startFrame("https://example.com/start.png")
.endFrame("https://example.com/end.png")
.param("duration", "8s")
.param("resolution", "720p")
.param("aspect_ratio", "16:9")
)
let result = try await client.generations.wait(task.data.id)
print(result.data)
Dart / Flutter
import 'package:buble/buble.dart';
Future<void> main() async {
final client = BubleClient.fromEnvironment();
final task = await client.generations.create(
CreateGenerationRequest(
model: 'google/veo3.1-fast',
mode: 'frames_to_video',
prompt:
'Create an elegant transformation from the first frame to the final frame with smooth cinematic camera movement and realistic lighting continuity',
startFrame: 'https://example.com/start.png',
endFrame: 'https://example.com/end.png',
).withParams({
'duration': '8s',
'resolution': '720p',
'aspect_ratio': '16:9',
}),
);
final result = await client.generations.wait(task.data.id);
print(result.data.raw);
}
Elixir
client = Buble.Client.new!()
{:ok, task} =
Buble.Generations.create(client, %{
model: "google/veo3.1-fast",
mode: "frames_to_video",
prompt:
"Create an elegant transformation from the first frame to the final frame with smooth cinematic camera movement and realistic lighting continuity",
start_frame: "https://example.com/start.png",
end_frame: "https://example.com/end.png",
duration: "8s",
resolution: "720p",
aspect_ratio: "16:9",
})
{:ok, result} = Buble.Generations.wait(client, get_in(task, ["data", "id"]))
IO.inspect(result["data"])
Java
import ai.buble.sdk.BubleClient;
import ai.buble.sdk.Envelope;
import ai.buble.sdk.generations.CreateGenerationRequest;
import ai.buble.sdk.generations.GenerationTask;
public class Example {
public static void main(String[] args) {
BubleClient client = BubleClient.fromEnv();
Envelope<GenerationTask> task = client.generations().create(
CreateGenerationRequest.builder()
.model("google/veo3.1-fast")
.mode("frames_to_video")
.prompt("Create an elegant transformation from the first frame to the final frame with smooth cinematic camera movement and realistic lighting continuity")
.startFrame("https://example.com/start.png")
.endFrame("https://example.com/end.png")
.param("duration", "8s")
.param("resolution", "720p")
.param("aspect_ratio", "16:9")
.build()
);
Envelope<GenerationTask> result = client.generations().wait(task.getData().getId());
System.out.println(result.getData().getStatus());
}
}
.NET
using Buble.Sdk;
using Buble.Sdk.Generations;
var client = BubleClient.FromEnv();
var request = new CreateGenerationRequest
{
Model = "google/veo3.1-fast",
Mode = "frames_to_video",
Prompt = "Create an elegant transformation from the first frame to the final frame with smooth cinematic camera movement and realistic lighting continuity",
StartFrame = "https://example.com/start.png",
EndFrame = "https://example.com/end.png",
}
.WithParam("duration", "8s")
.WithParam("resolution", "720p")
.WithParam("aspect_ratio", "16:9");
var task = await client.Generations.CreateAsync(request);
var result = await client.Generations.WaitAsync(task!.Data!.Id!);
Console.WriteLine(result.Data.Status);
PHP
<?php
use Buble\BubleClient;
use Buble\Generations\CreateGenerationRequest;
$client = BubleClient::fromEnv();
$request = new CreateGenerationRequest(
model: 'google/veo3.1-fast',
mode: 'frames_to_video',
prompt: 'Create an elegant transformation from the first frame to the final frame with smooth cinematic camera movement and realistic lighting continuity',
startFrame: 'https://example.com/start.png',
endFrame: 'https://example.com/end.png',
);
$task = $client->generations()->create(
$request
->withParam('duration', '8s')
->withParam('resolution', '720p')
->withParam('aspect_ratio', '16:9')
);
$result = $client->generations()->wait($task['data']['id']);
print_r($result['data']);
Ruby
require 'buble'
client = Buble::Client.new
task = client.generations.create(
model: 'google/veo3.1-fast',
mode: 'frames_to_video',
prompt: 'Create an elegant transformation from the first frame to the final frame with smooth cinematic camera movement and realistic lighting continuity',
start_frame: 'https://example.com/start.png',
end_frame: 'https://example.com/end.png',
duration: '8s',
resolution: '720p',
aspect_ratio: '16:9',
)
result = client.generations.wait(task['data']['id'])
puts result['data']