Skip to content

anbeime/skill / skills/video-creation-suite/video-creation-suite

video-creation-suite

Unverified

自媒体创作者与影片与视频编辑当需要从零原创、二次创作或深度分析视频时,请使用此套件。通过11个智能体协同,一键生成配音、音效与BGM并合成高质量视频,或自动抽帧提取分镜提示词,全流程大幅提升视频产出效率。

scripts/generate_subtitles.py

View on GitHub
#!/usr/bin/env python3
"""
生成分镜字幕和旁白脚本
根据分镜脚本生成字幕文件和旁白文本
"""

import json
import os
from pathlib import Path


def generate_subtitles(script_path: str, output_srt: str):
    """
    生成SRT字幕文件

    参数:
        script_path: 分镜脚本路径
        output_srt: 输出SRT文件路径
    """
    with open(script_path, 'r', encoding='utf-8') as f:
        script = json.load(f)

    scenes = script['scenes']

    with open(output_srt, 'w', encoding='utf-8') as f:
        current_time = 0

        for idx, scene in enumerate(scenes, 1):
            # 计算时间范围
            start_time = current_time
            end_time = start_time + scene['duration']

            # 格式化SRT时间 (HH:MM:SS,mmm)
            def format_time(seconds):
                hours = int(seconds // 3600)
                minutes = int((seconds % 3600) // 60)
                secs = int(seconds % 60)
                millisecs = int((seconds - int(seconds)) * 1000)
                return f"{hours:02d}:{minutes:02d}:{secs:02d},{millisecs:03d}"

            start_str = format_time(start_time)
            end_str = format_time(end_time)

            # 写入SRT格式
            f.write(f"{idx}\n")
            f.write(f"{start_str} --> {end_str}\n")
            f.write(f"{scene['subtitle']}\n")
            f.write(f"{scene['narration']}\n")
            f.write("\n")

            # 更新当前时间
            current_time = end_time

    print(f"✓ 字幕文件已生成: {output_srt}")


def generate_narration_text(script_path: str, output_txt: str):
    """
    生成旁白文本文件

    参数:
        script_path: 分镜脚本路径
        output_txt: 输出文本文件路径
    """
    with open(script_path, 'r', encoding='utf-8') as f:
        script = json.load(f)

    scenes = script['scenes']

    with open(output_txt, 'w', encoding='utf-8') as f:
        f.write(f"《{script['title']}》旁白文本\n\n")

        for idx, scene in enumerate(scenes, 1):
            f.write(f"[{scene['duration']}s] {scene['subtitle']}\n")
            f.write(f"{scene['narration']}\n\n")

    print(f"✓ 旁白文本已生成: {output_txt}")


if __name__ == "__main__":
    # 脚本路径
    script_path = "./output/script.json"

    # 输出路径
    output_srt = "./output/subtitles/subtitles.srt"
    output_txt = "./output/subtitles/narration.txt"

    # 确保目录存在
    os.makedirs(os.path.dirname(output_srt), exist_ok=True)

    # 生成字幕
    generate_subtitles(script_path, output_srt)

    # 生成旁白文本
    generate_narration_text(script_path, output_txt)
slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack."Stars: 198kUpdated Claude CodeCodexVerifiedInstall
ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt.Stars: 194kUpdated Claude CodeCodexVerifiedInstall