视频放大到 4K/1080P,返回 task_id Args: at: Access Token project_id: 项目ID video_media_id: 视频的 mediaId aspect_ratio: 视频宽高比 VIDEO_ASPECT_RATIO_PORTRAIT/LANDSCAPE resolution: VIDEO_RESOLUTION_4K 或 VIDEO_RESOLUTION_1080P model_key:
(
self,
at: str,
project_id: str,
video_media_id: str,
aspect_ratio: str,
resolution: str,
model_key: str,
user_paygate_tier: str = "PAYGATE_TIER_ONE",
token_id: Optional[int] = None,
token_video_concurrency: Optional[int] = None,
)
| 3720 | # ========== 视频放大 (Video Upsampler) ========== |
| 3721 | |
| 3722 | async def upsample_video( |
| 3723 | self, |
| 3724 | at: str, |
| 3725 | project_id: str, |
| 3726 | video_media_id: str, |
| 3727 | aspect_ratio: str, |
| 3728 | resolution: str, |
| 3729 | model_key: str, |
| 3730 | user_paygate_tier: str = "PAYGATE_TIER_ONE", |
| 3731 | token_id: Optional[int] = None, |
| 3732 | token_video_concurrency: Optional[int] = None, |
| 3733 | ) -> dict: |
| 3734 | """视频放大到 4K/1080P,返回 task_id |
| 3735 | |
| 3736 | Args: |
| 3737 | at: Access Token |
| 3738 | project_id: 项目ID |
| 3739 | video_media_id: 视频的 mediaId |
| 3740 | aspect_ratio: 视频宽高比 VIDEO_ASPECT_RATIO_PORTRAIT/LANDSCAPE |
| 3741 | resolution: VIDEO_RESOLUTION_4K 或 VIDEO_RESOLUTION_1080P |
| 3742 | model_key: veo_3_1_upsampler_4k 或 veo_3_1_upsampler_1080p |
| 3743 | |
| 3744 | Returns: |
| 3745 | 同 generate_video_text |
| 3746 | """ |
| 3747 | url = f"{self.api_base_url}/video:batchAsyncGenerateVideoUpsampleVideo" |
| 3748 | |
| 3749 | # 403/reCAPTCHA 重试逻辑 - reCAPTCHA evaluation failed 时允许更高重试上限 |
| 3750 | max_retries = self._resolve_generation_retry_budget(config.flow_max_retries) |
| 3751 | last_error = None |
| 3752 | retry_attempt = 0 |
| 3753 | session_id = self._generate_session_id() |
| 3754 | batch_id = str(uuid.uuid4()) |
| 3755 | scene_id = str(uuid.uuid4()) |
| 3756 | video_context_warmed = False |
| 3757 | while retry_attempt < max_retries: |
| 3758 | launch_gate_acquired = False |
| 3759 | launch_ok, _, _ = await self._acquire_video_launch_gate( |
| 3760 | token_id=token_id, |
| 3761 | token_video_concurrency=token_video_concurrency, |
| 3762 | ) |
| 3763 | if not launch_ok: |
| 3764 | last_error = Exception("Video launch queue wait timeout") |
| 3765 | raise last_error |
| 3766 | |
| 3767 | launch_gate_acquired = True |
| 3768 | try: |
| 3769 | recaptcha_token, browser_id = await self._get_recaptcha_token( |
| 3770 | project_id, |
| 3771 | action="VIDEO_GENERATION", |
| 3772 | token_id=token_id |
| 3773 | ) |
| 3774 | finally: |
| 3775 | if launch_gate_acquired: |
| 3776 | await self._release_video_launch_gate(token_id) |
| 3777 | if not recaptcha_token: |
| 3778 | last_error = Exception("Failed to obtain reCAPTCHA token") |
| 3779 | should_retry = await self._handle_missing_recaptcha_token( |
no test coverage detected