Skip to content

anbeime/skill / skills/agentkit-multimedia-shopping/agentkit-multimedia-shopping

agentkit-multimedia-shopping

Verified

电商运营与内容创作者在需要制作带货短视频时,用此技能一键生成9:16竖屏数字人成片。自动编排AI绘画、语音合成与视频生成,快速产出“小省导购员”专属形象与专业配音,让多模态视频制作省时省力。

scripts/generate_video.py

View on GitHub
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
视频生成脚本
基于ByteDance agentkit-samples多媒体用例
"""

import sys
import os

def generate_video(character_image, scene_image, voice_file, music_file, prompt, duration=5, aspect_ratio="9:16"):
    """
    生成多模态视频

    Args:
        character_image (str): 角色参考图路径
        scene_image (str): 场景参考图路径
        voice_file (str): 语音文件路径
        music_file (str): 音乐文件路径
        prompt (str): InfiniteTalk专用提示词
        duration (int): 时长(秒),默认5
        aspect_ratio (str): 画面比例,默认"9:16"

    Returns:
        object: 视频文件对象(根据实际工具返回)

    Raises:
        ValueError: 参数验证失败
        Exception: 生成失败
    """
    # 参数验证
    if not character_image or not os.path.exists(character_image):
        raise ValueError("角色参考图路径无效或文件不存在")

    if not scene_image or not os.path.exists(scene_image):
        raise ValueError("场景参考图路径无效或文件不存在")

    if not voice_file or not os.path.exists(voice_file):
        raise ValueError("语音文件路径无效或文件不存在")

    if not music_file or not os.path.exists(music_file):
        raise ValueError("音乐文件路径无效或文件不存在")

    if not prompt:
        raise ValueError("提示词不能为空")

    if duration <= 0:
        raise ValueError("时长必须大于0")

    if aspect_ratio != "9:16":
        raise ValueError("画面比例必须为9:16")

    # TODO: 调用实际的视频生成工具
    # 这里需要根据ByteDance agentkit-samples的实际实现来调用
    # 示例代码(伪代码):
    #
    # from agentkit import VideoGenerator
    #
    # generator = VideoGenerator()
    # video = generator.generate(
    #     character_image=character_image,
    #     scene_image=scene_image,
    #     voice_file=voice_file,
    #     music_file=music_file,
    #     prompt=prompt,
    #     duration=duration,
    #     aspect_ratio=aspect_ratio
    # )
    #
    # return video

    # 占位符返回
    print(f"[generate_video] 生成视频")
    print(f"  角色参考图: {character_image}")
    print(f"  场景参考图: {scene_image}")
    print(f"  语音文件: {voice_file}")
    print(f"  音乐文件: {music_file}")
    print(f"  提示词: {prompt[:50]}...")
    print(f"  时长: {duration}秒")
    print(f"  画面比例: {aspect_ratio}")

    return None


def main():
    """
    主函数:从命令行读取参数并生成视频
    """
    import argparse

    parser = argparse.ArgumentParser(description="生成多模态视频")
    parser.add_argument("--character-image", type=str, required=True, help="角色参考图路径")
    parser.add_argument("--scene-image", type=str, required=True, help="场景参考图路径")
    parser.add_argument("--voice-file", type=str, required=True, help="语音文件路径")
    parser.add_argument("--music-file", type=str, required=True, help="音乐文件路径")
    parser.add_argument("--prompt", type=str, required=True, help="InfiniteTalk专用提示词")
    parser.add_argument("--duration", type=int, default=5, help="时长(秒)")
    parser.add_argument("--aspect-ratio", type=str, default="9:16", help="画面比例")
    parser.add_argument("--output", type=str, default="./output/video.mp4", help="输出文件路径")

    args = parser.parse_args()

    try:
        # 生成视频
        video_file = generate_video(
            character_image=args.character_image,
            scene_image=args.scene_image,
            voice_file=args.voice_file,
            music_file=args.music_file,
            prompt=args.prompt,
            duration=args.duration,
            aspect_ratio=args.aspect_ratio
        )

        # 保存视频文件
        if video_file:
            # 确保输出目录存在
            output_dir = os.path.dirname(args.output)
            if output_dir and not os.path.exists(output_dir):
                os.makedirs(output_dir)

            video_file.save(args.output)
            print(f"视频文件已保存至: {args.output}")
        else:
            print("警告: 视频生成返回为空(可能是占位符)")

        return 0

    except ValueError as e:
        print(f"参数错误: {e}", file=sys.stderr)
        return 1
    except Exception as e:
        print(f"生成失败: {e}", file=sys.stderr)
        return 2


if __name__ == "__main__":
    sys.exit(main())
reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis.Stars: 471kUpdated Claude CodeCodexVerifiedInstall
diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.Stars: 322kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 322kUpdated Claude CodeCodexVerifiedInstall
executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is availableStars: 322kUpdated Claude CodeCodexVerifiedInstall