视频只需创建一次,之后想渲染多少次都可以。
视频承载着时间轴:图层、音频、字幕、画幅。一次调用即可创建,也可以直接复用团队在编辑器里做好的那一条。
export AUTOSTUD_API_KEY="sk_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
# A video is the timeline. Create one, or skip this step and reuse
# a video your team already built in the editor.
curl -X POST https://autostud.ai/api/v1/actions/videos.create \
-H "Authorization: Bearer $AUTOSTUD_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"video_name": "Launch teaser",
"video_format": "portrait",
"video_lang": "en"
}'让 renders.create 指向视频 id,覆盖这次任务需要改的设置,它立刻发往工作节点。返回的是任务,不是文件。
# The Idempotency-Key makes this call safe to retry: send it twice
# and you get the same render back, never a second job.
curl -X POST https://autostud.ai/api/v1/actions/renders.create \
-H "Authorization: Bearer $AUTOSTUD_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: launch-teaser-v3" \
-d '{
"video_id": "0f4c8b71-2d95-47a3-9e6c-15b8ad7f3c20",
"render_settings": {
"quality": "high"
}
}'render.completed 会带着输出地址送达。如果你的技术栈更喜欢轮询,就按视频 id 过滤,重新读取渲染列表。
# Register once. Every render reports itself from then on.
curl -X POST https://autostud.ai/api/v1/webhooks \
-H "Authorization: Bearer $AUTOSTUD_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"url": "https://your-app.com/hooks/autostud",
"events": ["render.started", "render.completed", "render.failed"],
"description": "Rendering"
}'
# The signing secret comes back once, in this response. Store it.两个字段用来发起,一个请求头让重试安全,一个 id 用来跟踪。
video_id要渲染的视频。整套构图已经在它身上了。
render_settings本次任务的可选覆盖项:画幅、质量、想要的帧范围。
Idempotency-Key一个请求头。同一个 key 发两次,拿回的是第一次的渲染,绝不会产生重复任务。
render_id由调用返回,并由每个 Webhook 携带,所以一条完成的 mp4 永远指向请求它的那个任务。
渲染结果是 H.264 的 mp4,画幅取决于视频的设置。抖音和 Reels 用竖版,信息流用方版,YouTube 用横版:同一条时间轴,不同的输出。
一次渲染是以分钟计的,不是毫秒。注册一个 Webhook,三个事件就会告诉你工作节点何时接手、文件何时就绪、以及何时出了问题。
render.startedrender.completedrender.failed几分钟,随视频时长和图层数量增长。任务一进队列调用就返回,所以你的应用不必等在那里。
渲染按积分计费,账目可通过 API 读取。密钥可以只授予 renders:read,让看板监控消耗却无法发起任务。
可以。带上 Idempotency-Key 请求头,重复调用会返回原来的渲染,而不是排入第二个任务:API 的每个执行类操作都提供同样的保证。
在我们的 CDN 上,地址同时写在渲染记录和 render.completed 的负载里。如果需要长期保留,请下载后自行存储。