generate-video-by-seedance
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinese豆包 Seedance 视频生成
Doubao Seedance Video Generation
使用随技能打包的脚本,通过字节跳动 Seedance 视频模型在火山引擎 Ark 上生成/编辑视频:
- 豆包 Seedance 系列视频模型(通过 Ark contents/generations/tasks 接口)
- 支持文生视频、图生视频(单图 / 多图参考)
默认设置:
- 默认模型:(可用
doubao-seedance-1-5-pro-251215覆盖)--model - 默认时长:秒
5 - 默认比例:
16:9
Use the script packaged with the skill to generate/edit videos via ByteDance Seedance video model on Volcengine Ark:
- Doubao Seedance series video models (via Ark contents/generations/tasks interface)
- Supports text-to-video, image-to-video (single / multiple image references)
Default Settings:
- Default model: (can be overridden with
doubao-seedance-1-5-pro-251215)--model - Default duration: seconds
5 - Default aspect ratio:
16:9
文生视频
Text to Video
bash
uv run {baseDir}/scripts/generate_video.py \
--prompt "一个在草地上奔跑的小狗视频,阳光明媚,电影感" \
--filename "奔跑小狗.mp4"bash
uv run {baseDir}/scripts/generate_video.py \
--prompt "一个在草地上奔跑的小狗视频,阳光明媚,电影感" \
--filename "奔跑小狗.mp4"使用 YAML 配置文件
Use YAML Configuration File
可以将所有生视频参数写入 YAML 配置文件,然后通过 参数使用:
--configYou can write all video generation parameters into a YAML configuration file and use it via the parameter:
--config文生视频配置示例 (text2video.yaml
):
text2video.yamlText-to-video configuration example (text2video.yaml
):
text2video.yamlyaml
prompt: 一个在草地上奔跑的小狗视频,阳光明媚,电影感
filename: 奔跑小狗.mp4
ratio: 16:9
duration: 5yaml
prompt: 一个在草地上奔跑的小狗视频,阳光明媚,电影感
filename: 奔跑小狗.mp4
ratio: 16:9
duration: 5图生视频配置示例(带 URL 参考图列表,image2video.yaml
):
image2video.yamlImage-to-video configuration example (with URL reference image list, image2video.yaml
):
image2video.yamlyaml
prompt: 将图1的表情换为图2的表情,做一个眨眼微笑的短视频
filename: 表情女孩.mp4
images:
- https://ark-project.tos-cn-beijing.volces.com/doc_image/seedream4_imagesToimage_1.png
- https://ark-project.tos-cn-beijing.volces.com/doc_image/seedream4_5_imagesToimage_2.png
ratio: 9:16
duration: 5yaml
prompt: 将图1的表情换为图2的表情,做一个眨眼微笑的短视频
filename: 表情女孩.mp4
images:
- https://ark-project.tos-cn-beijing.volces.com/doc_image/seedream4_imagesToimage_1.png
- https://ark-project.tos-cn-beijing.volces.com/doc_image/seedream4_5_imagesToimage_2.png
ratio: 9:16
duration: 5本地参考图配置示例(local_images.yaml
):
local_images.yamlLocal reference image configuration example (local_images.yaml
):
local_images.yamlyaml
prompt: 多图融合成一个动画短片
filename: 多图融合动画.mp4
images:
- /path/to/参考图1.jpg
- /path/to/参考图2.png
ratio: 16:9
duration: 8yaml
prompt: 多图融合成一个动画短片
filename: 多图融合动画.mp4
images:
- /path/to/参考图1.jpg
- /path/to/参考图2.png
ratio: 16:9
duration: 8使用方法:
Usage:
bash
uv run {baseDir}/scripts/generate_video.py --config image2video.yamlbash
uv run {baseDir}/scripts/generate_video.py --config image2video.yaml混合使用配置文件和命令行参数(命令行参数优先级更高):
Mix configuration file and command line parameters (command line parameters have higher priority):
bash
uv run {baseDir}/scripts/generate_video.py --config prompt.yaml --filename "自定义文件名.mp4"bash
uv run {baseDir}/scripts/generate_video.py --config prompt.yaml --filename "自定义文件名.mp4"YAML 配置文件支持的所有参数:
All parameters supported by YAML configuration file:
- : 视频内容描述
prompt - : 输出文件名
filename - : 参考图像列表(可以是 URL 或本地文件路径)
images - : 画面比例(如 "16:9"、"9:16")
ratio - : 视频时长(秒)
duration - : 完整的模型名称(高级选项)
model - : API 密钥
api_key
- : Video content description
prompt - : Output file name
filename - : Reference image list (can be URL or local file path)
images - : Aspect ratio (e.g. "16:9", "9:16")
ratio - : Video duration (seconds)
duration - : Full model name (advanced option)
model - : API key
api_key
图生视频 / 参考图(URL 或本地文件均可,多图,使用 lite i2v 模型)
Image to Video / Reference Images (URL or local files are supported, multiple images, use lite i2v model)
bash
uv run {baseDir}/scripts/generate_video.py \
--prompt "参考图片中的女孩,做一个挥手微笑的短视频" \
--filename "挥手女孩.mp4" \
-i "https://example.com/ref_image_1.png" \
-i "/path/to/local_ref_2.jpg" \
--ratio "9:16" \
--duration 8bash
uv run {baseDir}/scripts/generate_video.py \
--prompt "参考图片中的女孩,做一个挥手微笑的短视频" \
--filename "挥手女孩.mp4" \
-i "https://example.com/ref_image_1.png" \
-i "/path/to/local_ref_2.jpg" \
--ratio "9:16" \
--duration 8只用参考图(无显式文案提示)
Use only reference images (no explicit text prompt)
bash
uv run {baseDir}/scripts/generate_video.py \
--filename "仅参考图生成视频.mp4" \
-i "/path/to/ref1.jpg" \
-i "/path/to/ref2.png"提示:至少需要「提示词」或「参考图」其一存在,否则脚本会报错。
bash
uv run {baseDir}/scripts/generate_video.py \
--filename "仅参考图生成视频.mp4" \
-i "/path/to/ref1.jpg" \
-i "/path/to/ref2.png"Tip: At least one of "prompt" or "reference image" is required, otherwise the script will report an error.
注意事项
Notes
API 密钥
API Key
- 需要设置 环境变量
ARK_API_KEY
- You need to set the environment variable
ARK_API_KEY
参数说明
Parameter Description
- prompt:视频内容文案(中文 / 英文均可)
- image / -i:
- URL:直接透传给 Ark(例如公网可访问的图片链接)
- 本地文件:自动读取并转成 形式再发送
data:image/...;base64,... - 可多次传入,形成多图参考(多图目前仅在 等 lite i2v 模型下生效)
doubao-seedance-1-0-lite-i2v-250428
- ratio:画面比例,常用:
- (默认)
"16:9" "9:16""1:1""21:9"
- duration:视频时长(秒),由模型 / Endpoint 实际支持的区间决定
- model(可选,高级):直接指定 Ark Endpoint / 模型 ID,覆盖默认绑定
轮询脚本 额外参数:
get_video_task_status.py- interval:轮询间隔(秒),默认 ,可根据任务耗时与频率需求自行调整
10 - timeout:最大等待时间(秒),默认 ,超过后脚本会报错退出
600
- prompt: Video content text (supports Chinese / English)
- image / -i:
- URL: Pass directly to Ark (e.g. publicly accessible image link)
- Local file: Automatically read and converted to format before sending
data:image/...;base64,... - Can be passed multiple times to form multi-image reference (multi-image currently only works under lite i2v models such as )
doubao-seedance-1-0-lite-i2v-250428
- ratio: Aspect ratio, commonly used:
- (default)
"16:9" "9:16""1:1""21:9"
- duration: Video duration (seconds), determined by the actual supported range of the model / Endpoint
- model (optional, advanced): Directly specify Ark Endpoint / model ID to override the default binding
Additional parameters for polling script :
get_video_task_status.py- interval: Polling interval (seconds), default , can be adjusted according to task duration and frequency requirements
10 - timeout: Maximum waiting time (seconds), default , the script will report an error and exit after exceeding
600
结果与文件输出
Result and File Output
- Ark 视频生成通常是异步任务:
- 脚本会调用
POST /contents/generations/tasks - 成功时优先解析返回的 /
id作为任务 IDtask_id - 如果响应体中直接携带 ,脚本会尝试拉取并将视频保存到本地
video_url
- 脚本会调用
- 保存路径规则:
- 若 未指定目录,则默认保存到本仓库下的
--filename目录outputs/ - 若文件名无后缀,则默认补上
.mp4
- 若
若调用成功但后端仅返回任务 ID、尚未生成 ,脚本会输出任务 ID,可配合轮询脚本一起使用:
video_urlbash
undefined- Ark video generation is usually an asynchronous task:
- The script will call
POST /contents/generations/tasks - On success, the returned /
idwill be parsed first as the task IDtask_id - If is directly carried in the response body, the script will try to pull and save the video locally
video_url
- The script will call
- Save path rules:
- If does not specify a directory, it will be saved to the
--filenamedirectory under this repository by defaultoutputs/ - If the file name has no suffix, will be added by default
.mp4
- If
If the call is successful but the backend only returns the task ID and has not been generated, the script will output the task ID, which can be used together with the polling script:
video_urlbash
undefined1) 先创建任务(可能只返回 TASK_ID)
1) Create a task first (may only return TASK_ID)
uv run {baseDir}/scripts/generate_video.py
--prompt "一个示例视频"
--filename "示例视频.mp4"
--prompt "一个示例视频"
--filename "示例视频.mp4"
uv run {baseDir}/scripts/generate_video.py
--prompt "一个示例视频"
--filename "示例视频.mp4"
--prompt "一个示例视频"
--filename "示例视频.mp4"
2) 拿到上一步输出的 TASK_ID 后,轮询直到生成完成并下载视频
2) After getting the TASK_ID output from the previous step, poll until generation is complete and download the video
uv run {baseDir}/scripts/get_video_task_status.py
cgt-20260226184301-4h8v6
--filename "示例视频.mp4"
--interval 5
cgt-20260226184301-4h8v6
--filename "示例视频.mp4"
--interval 5
轮询脚本会:
- 定期调用 `GET /contents/generations/tasks/{task_id}` 查看任务状态
- 当状态为 `succeeded` / `completed` 且拿到 `video_url` 时,自动下载视频到本地uv run {baseDir}/scripts/get_video_task_status.py
cgt-20260226184301-4h8v6
--filename "示例视频.mp4"
--interval 5
cgt-20260226184301-4h8v6
--filename "示例视频.mp4"
--interval 5
The polling script will:
- Periodically call `GET /contents/generations/tasks/{task_id}` to check task status
- When the status is `succeeded` / `completed` and `video_url` is obtained, automatically download the video to local文件名推荐(供调用方参考)
Recommended file names (for caller reference)
- 不要在文件名里包含具体实现细节(如 "seedance"、"ark" 等)
- 文件名语言建议与 Prompt 语言一致,如中文 Prompt 就用简短中文文件名(如 )
挥手女孩.mp4 - 文件名要有语义但尽量简短,避免过长句子
- Do not include specific implementation details in the file name (such as "seedance", "ark", etc.)
- It is recommended that the file name language is consistent with the Prompt language, for example, use a short Chinese file name for Chinese Prompt (e.g. )
挥手女孩.mp4 - The file name should be semantic and as short as possible, avoid overly long sentences
关键词提示(便于发现 / 搜索命中)
Keyword tips (for easy discovery / search hit)
- "doubao", "豆包", "Seedance"
- "ByteDance video model", "字节跳动视频生成"
- "文生视频", "图生视频", "视频生成", "短视频生成"
- "doubao", "豆包", "Seedance"
- "ByteDance video model", "字节跳动视频生成"
- "文生视频", "图生视频", "视频生成", "短视频生成"