API视频渲染 API

把成片渲染出来
直接从你的代码里

一次 POST 就把渲染任务排进我们的工作节点,签名 Webhook 把 mp4 交给你。不用装 ffmpeg,不用租 GPU,也不用盯着队列。

POSThttps://autostud.ai/api/v1/actions/renders.create

三次调用,从时间轴到 mp4

视频只需创建一次,之后想渲染多少次都可以。

  1. 1

    创建视频

    视频承载着时间轴:图层、音频、字幕、画幅。一次调用即可创建,也可以直接复用团队在编辑器里做好的那一条。

    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"
      }'
  2. 2

    把渲染排进队列

    让 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"
        }
      }'
  3. 3

    取走 mp4

    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 用横版:同一条时间轴,不同的输出。

portrait 9:16square 1:1landscape 16:9mp4 / H.264

别再轮询了

一次渲染是以分钟计的,不是毫秒。注册一个 Webhook,三个事件就会告诉你工作节点何时接手、文件何时就绪、以及何时出了问题。

render.startedrender.completedrender.failed

开发者最先问的问题

渲染需要多久?

几分钟,随视频时长和图层数量增长。任务一进队列调用就返回,所以你的应用不必等在那里。

渲染要多少钱?

渲染按积分计费,账目可通过 API 读取。密钥可以只授予 renders:read,让看板监控消耗却无法发起任务。

失败的调用可以安全重试吗?

可以。带上 Idempotency-Key 请求头,重复调用会返回原来的渲染,而不是排入第二个任务:API 的每个执行类操作都提供同样的保证。

文件存放在哪里?

在我们的 CDN 上,地址同时写在渲染记录和 render.completed 的负载里。如果需要长期保留,请下载后自行存储。

準備好開始了嗎?

幾分鐘就能產出爆紅影片。免費試用不需要信用卡。

安全付款
立即使用
隨時取消