視頻只需創建一次,之後想渲染多少次都可以。
視頻承載著時間軸:圖層、音頻、字幕、畫幅。一次調用即可創建,也可以直接複用團隊在編輯器裡做好的那一條。
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 的負載裡。如果需要長期保留,請下載後自行存儲。