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 的負載裡。如果需要長期保留,請下載後自行存儲。

準備好開始了嗎?

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

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