MCPcopy Create free account
hub / github.com/TheSmallHanCat/flow2api / generate_video_extend

Method generate_video_extend

src/services/flow_client.py:3421–3572  ·  view source on GitHub ↗

视频续写,基于已生成的视频延伸7秒 Args: at: Access Token project_id: 项目ID prompt: 续写提示词 model_key: veo_3_1_extend_portrait / veo_3_1_extend 等 aspect_ratio: 视频宽高比 video_media_id: 源视频的 mediaGenerationId user_paygate_tier: 用户等

(
        self,
        at: str,
        project_id: str,
        prompt: str,
        model_key: str,
        aspect_ratio: str,
        video_media_id: str,
        user_paygate_tier: str = "PAYGATE_TIER_ONE",
        token_id: Optional[int] = None,
        token_video_concurrency: Optional[int] = None,
    )

Source from the content-addressed store, hash-verified

3419 # ========== 视频续写 (Video Extend) ==========
3420
3421 async def generate_video_extend(
3422 self,
3423 at: str,
3424 project_id: str,
3425 prompt: str,
3426 model_key: str,
3427 aspect_ratio: str,
3428 video_media_id: str,
3429 user_paygate_tier: str = "PAYGATE_TIER_ONE",
3430 token_id: Optional[int] = None,
3431 token_video_concurrency: Optional[int] = None,
3432 ) -> dict:
3433 """视频续写,基于已生成的视频延伸7秒
3434
3435 Args:
3436 at: Access Token
3437 project_id: 项目ID
3438 prompt: 续写提示词
3439 model_key: veo_3_1_extend_portrait / veo_3_1_extend 等
3440 aspect_ratio: 视频宽高比
3441 video_media_id: 源视频的 mediaGenerationId
3442 user_paygate_tier: 用户等级
3443
3444 Returns:
3445 同 generate_video_text (operations 列表)
3446 """
3447 url = f"{self.api_base_url}/video:batchAsyncGenerateVideoExtendVideo"
3448
3449 # 403/reCAPTCHA 重试逻辑 - reCAPTCHA evaluation failed 时允许更高重试上限
3450 max_retries = self._resolve_generation_retry_budget(config.flow_max_retries)
3451 last_error = None
3452 retry_attempt = 0
3453 session_id = self._generate_session_id()
3454 workflow_id = str(uuid.uuid4())
3455 batch_id = str(uuid.uuid4())
3456 video_context_warmed = False
3457 while retry_attempt < max_retries:
3458 launch_gate_acquired = False
3459 launch_ok, _, _ = await self._acquire_video_launch_gate(
3460 token_id=token_id,
3461 token_video_concurrency=token_video_concurrency,
3462 )
3463 if not launch_ok:
3464 last_error = Exception("Video launch queue wait timeout")
3465 raise last_error
3466
3467 launch_gate_acquired = True
3468 try:
3469 recaptcha_token, browser_id = await self._get_recaptcha_token(
3470 project_id,
3471 action="VIDEO_GENERATION",
3472 token_id=token_id
3473 )
3474 finally:
3475 if launch_gate_acquired:
3476 await self._release_video_launch_gate(token_id)
3477 if not recaptcha_token:
3478 last_error = Exception("Failed to obtain reCAPTCHA token")

Callers 1

Tested by

no test coverage detected