| | |
| | | from tool.video_wan import WanVideoClient |
| | | from tool.image_jimeng import JiMengClient |
| | | from tool.video_kling import KlingVideoClient |
| | | from tool.video_seedance import SeedanceVideoClient |
| | | except ImportError: |
| | | from video_wan import WanVideoClient |
| | | from image_jimeng import JiMengClient |
| | | from video_kling import KlingVideoClient |
| | | from video_seedance import SeedanceVideoClient |
| | | |
| | | logger = logging.getLogger(__name__) |
| | | |
| | |
| | | base_url=kling_base_url, |
| | | ) |
| | | |
| | | # Seedance 客户端 |
| | | self.seedance_client = SeedanceVideoClient( |
| | | api_key=os.getenv("ARK_API_KEY"), |
| | | base_url=os.getenv("ARK_BASE_URL"), |
| | | ) |
| | | |
| | | def generate_video( |
| | | self, |
| | | prompt: str, |
| | | image_path: str, |
| | | save_path: str, |
| | | model: str = "wan2.6-i2v-flash", |
| | | model: str = "wan2.7-i2v", |
| | | duration: int = 5, |
| | | shot_type: str = "multi", |
| | | sound: str = "", |
| | |
| | | RuntimeError: 生成或下载失败 |
| | | """ |
| | | if not model: |
| | | model = "wan2.6-i2v-flash" |
| | | model = "wan2.7-i2v" |
| | | |
| | | if Config.PRINT_MODEL_INPUT: |
| | | print("---- VIDEO GENERATION REQUEST ----") |
| | |
| | | return self._generate_jimeng(prompt, image_path, save_path, model, video_ratio) |
| | | elif "kling" in model_lower: |
| | | return self._generate_kling(prompt, image_path, save_path, model, duration, sound) |
| | | elif "seedance" in model_lower: |
| | | return self._generate_seedance(prompt, image_path, save_path, model, duration) |
| | | else: |
| | | return self._generate_wan(prompt, image_path, save_path, model, duration, shot_type) |
| | | |
| | |
| | | duration=duration, |
| | | sound=sound, |
| | | ) |
| | | |
| | | def _generate_seedance( |
| | | self, |
| | | prompt: str, |
| | | image_path: str, |
| | | save_path: str, |
| | | model: str, |
| | | duration: int = 5, |
| | | ) -> str: |
| | | """通过 Seedance 模型生成视频""" |
| | | logger.info(f"VideoClient: 路由至 Seedance model={model}") |
| | | return self.seedance_client.generate_video( |
| | | prompt=prompt, |
| | | image_path=image_path, |
| | | save_path=save_path, |
| | | model=model, |
| | | duration=duration, |
| | | ) |