fix: explain video generation failures
This commit is contained in:
28
api/main.py
28
api/main.py
@@ -8269,27 +8269,29 @@ def render_storyboard_video(
|
||||
for create_path in VIDEO_CREATE_PATHS:
|
||||
resp = submit_video_create(client, f"{base}{video_path(create_path)}", headers, ref_img, payload, source_ref, prepared_last_img, prepared_product_imgs, primary_role)
|
||||
if video_uses_ark() and source_ref and resp.status_code in {400, 422}:
|
||||
create_errors.append(f"{video_path(create_path)} + reference_video -> HTTP {resp.status_code}: {resp.text[:160]}")
|
||||
create_errors.append(f"{video_path(create_path)} + reference_video -> HTTP {resp.status_code}: {resp.text[:700]}")
|
||||
resp = submit_video_create(client, f"{base}{video_path(create_path)}", headers, ref_img, payload, None, prepared_last_img, prepared_product_imgs, primary_role)
|
||||
if video_uses_ark() and prepared_last_img and resp.status_code in {400, 422}:
|
||||
create_errors.append(f"{video_path(create_path)} + last_frame -> HTTP {resp.status_code}: {resp.text[:160]}")
|
||||
create_errors.append(f"{video_path(create_path)} + last_frame -> HTTP {resp.status_code}: {resp.text[:700]}")
|
||||
resp = submit_video_create(client, f"{base}{video_path(create_path)}", headers, ref_img, payload, None, None, prepared_product_imgs, primary_role)
|
||||
if video_uses_ark() and prepared_product_imgs and resp.status_code in {400, 422}:
|
||||
create_errors.append(f"{video_path(create_path)} + product_reference -> HTTP {resp.status_code}: {resp.text[:160]}")
|
||||
create_errors.append(f"{video_path(create_path)} + product_reference -> HTTP {resp.status_code}: {resp.text[:700]}")
|
||||
resp = submit_video_create(client, f"{base}{video_path(create_path)}", headers, ref_img, payload, None, prepared_last_img, None, primary_role)
|
||||
if resp.status_code < 400:
|
||||
create = resp
|
||||
break
|
||||
create_errors.append(f"{video_path(create_path)} -> HTTP {resp.status_code}: {resp.text[:160]}")
|
||||
create_errors.append(f"{video_path(create_path)} -> HTTP {resp.status_code}: {resp.text[:700]}")
|
||||
if resp.status_code not in {400, 404, 405}:
|
||||
resp.raise_for_status()
|
||||
if create is None:
|
||||
raise RuntimeError("视频模型已选择,但当前网关视频生成入口不可用;已尝试 " + " | ".join(create_errors))
|
||||
print(f"[video create failed] job={job_id} video={local_id} errors={' | '.join(create_errors)[:1800]}", flush=True)
|
||||
raise RuntimeError(_video_create_failure_message(create_errors))
|
||||
data = create.json()
|
||||
video_api_id = data.get("id") or provider_id or local_id
|
||||
status = normalize_video_status(data.get("status"))
|
||||
progress = video_progress(data, 5)
|
||||
direct_url = video_url_from_response(data)
|
||||
status_payload = data
|
||||
update_generated_video(
|
||||
job_id,
|
||||
local_id,
|
||||
@@ -8308,6 +8310,7 @@ def render_storyboard_video(
|
||||
status = normalize_video_status(pdata.get("status"))
|
||||
progress = video_progress(pdata, progress)
|
||||
direct_url = video_url_from_response(pdata) or direct_url
|
||||
status_payload = pdata
|
||||
update_generated_video(
|
||||
job_id,
|
||||
local_id,
|
||||
@@ -8317,7 +8320,17 @@ def render_storyboard_video(
|
||||
)
|
||||
|
||||
if status != "completed":
|
||||
update_generated_video(job_id, local_id, status="failed", error=f"video status: {status}", progress=progress, queue_message="")
|
||||
raw_error = ""
|
||||
if isinstance(status_payload, dict):
|
||||
raw_error = str(
|
||||
status_payload.get("error")
|
||||
or status_payload.get("message")
|
||||
or status_payload.get("reason")
|
||||
or status_payload.get("fail_reason")
|
||||
or status_payload
|
||||
)
|
||||
print(f"[video status failed] job={job_id} video={local_id} status={status} error={raw_error[:1200]}", flush=True)
|
||||
update_generated_video(job_id, local_id, status="failed", error=_video_public_error(raw_error or f"video status: {status}"), progress=progress, queue_message="")
|
||||
return
|
||||
|
||||
download_generated_video(client, base, headers, video_api_id, direct_url, out_mp4)
|
||||
@@ -8333,7 +8346,8 @@ def render_storyboard_video(
|
||||
queue_message="",
|
||||
)
|
||||
except Exception as e:
|
||||
update_generated_video(job_id, local_id, status="failed", error=str(e)[:500], queue_message="")
|
||||
print(f"[video task failed] job={job_id} video={local_id} error={str(e)[:1200]}", flush=True)
|
||||
update_generated_video(job_id, local_id, status="failed", error=_video_public_error(e), queue_message="")
|
||||
|
||||
|
||||
@app.post("/jobs/{job_id}/frames/{idx}/storyboard/quick-plan", response_model=StoryboardScene)
|
||||
|
||||
Reference in New Issue
Block a user