Seedance 人物写真・動画
ご利用前に、アクセス基本を押して、
SHANHAI_BASE_URL(当サイトのルートアドレス)とSHANHAI_API_KEY(当サイトのトークン)を設定してください。次のコマンドは Bash に適しています。マテリアルのサンプルアドレスは、直接ダウンロードできる実際のアドレスに置き換える必要があります。
API:写真のリンクから直接動画を生成する
写っている本人の同意があれば、写真の HTTPS リンクから直接動画を生成できます。素材の事前登録は不要です。
doubao-seedance-2-0-260128doubao-seedance-2-0-fast-260128doubao-seedance-2-0-mini-260615doubao-seedance-2-5-260628doubao-seedance-2-5-flash-261115
image_url.url を共有ページではなく、元の写真の HTTPS 直リンクに置き換えてください。ログイン不要でダウンロードでき、動画の生成が終わるまで有効なリンクを使います。
curl --fail-with-body "$SHANHAI_BASE_URL/v1/videos" \
-H "Authorization: Bearer $SHANHAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "doubao-seedance-2-0-mini-260615",
"prompt": "The person in the photo looks at the camera and smiles.",
"seconds": "4",
"metadata": {
"resolution": "480p",
"content": [
{"type": "image_url", "role": "reference_image", "image_url": {"url": "https://media.example.com/portrait.jpg"}}
]
}
}'
POST /v1/videos → id → GET /v1/videos/{task_id} → GET /v1/videos/{task_id}/content
API:素材を登録してから動画を生成する
許諾済みの写真や動画を再利用するには、キーの発行元サイトで素材を登録できます。登録に対応するのは以下の4モデルです。2.5 Flash は上記の写真リンクを使用してください。
doubao-seedance-2-5-260628doubao-seedance-2-0-260128doubao-seedance-2-0-fast-260128doubao-seedance-2-0-mini-260615
素材は一つずつ送信し、受付番号を保存してください。同じアカウントとモデルで状態が Active になるまで確認し、返された asset_url を使います。
POST /v1/portrait-assets→data.idGET /v1/portrait-assets/{id}?model=MODEL→Active→data.asset_urlPOST /v1/videos→idGET /v1/videos/{id}→completed→GET /v1/videos/{id}/content
type |
url |
consent |
|---|---|---|
Image |
HTTPS · JPEG / PNG / WebP · ≤ 10 MiB | true |
Video |
HTTPS · MP4 / MOV · ≤ 50 MiB | true |
画像を直接ダウンロードできる URL を指定します。素材の準備ができたらリンクを無効にできます。
export AUTHORIZED_PHOTO_HTTPS_URL='https://media.example.com/portrait.png'
# Optional: export AUTHORIZED_VIDEO_HTTPS_URL='https://media.example.com/motion.mp4'
python -m pip install requests
import os
import time
import requests
base = os.environ["SHANHAI_BASE_URL"].rstrip("/") + "/v1"
model = "doubao-seedance-2-5-260628"
headers = {"Authorization": "Bearer " + os.environ["SHANHAI_API_KEY"]}
# Image: PNG / JPG / WebP, ≤ 10 MiB. Video: MP4 / MOV, ≤ 50 MiB.
def register(kind, https_url):
r = requests.post(f"{base}/portrait-assets", headers=headers, timeout=30,
json={"model": model, "type": kind, "url": https_url, "consent": True})
r.raise_for_status()
receipt = r.json()["data"]["id"]
print("Receipt:", receipt)
return receipt
def wait_ready(receipt):
for _ in range(60):
r = requests.get(f"{base}/portrait-assets/{receipt}", headers=headers,
params={"model": model}, timeout=30)
r.raise_for_status()
data = r.json()["data"]
if data["status"] == "Active":
return data["asset_url"]
if data["status"] == "Failed":
raise ValueError("Material processing failed")
time.sleep(3)
raise TimeoutError("Call wait_ready again with the saved receipt")
photo = register("Image", os.environ["AUTHORIZED_PHOTO_HTTPS_URL"])
content = [
{"type": "image_url", "role": "reference_image", "image_url": {"url": wait_ready(photo)}},
]
if clip_url := os.getenv("AUTHORIZED_VIDEO_HTTPS_URL"):
clip = register("Video", clip_url)
content.append({"type": "video_url", "role": "reference_video", "video_url": {"url": wait_ready(clip)}})
r = requests.post(f"{base}/videos", headers=headers, timeout=60, json={
"model": model, "prompt": "The person in the photo looks at the camera and smiles.",
"seconds": "4", "metadata": {"resolution": "480p", "ratio": "9:16", "content": content},
})
r.raise_for_status()
task_id = r.json()["id"]
print("TASK_ID=" + task_id)
動画スタジオ
動画スタジオで対応する Seedance モデルを選び、素材の用途を参照画像または参照動画に設定します。素材の登録について出演者の同意を得たことを示す欄にチェックを入れ、アップロードしてください。処理が終わったらプロンプトを入力して動画を生成します。
で問題が発生しました
通話または設定で問題が発生した場合は、トラブルシューティングを容易にするために、サイトのカスタマー サービスに連絡し、モデル名、エラー時刻、およびエラー情報を提供してください。