agentleFS
PeterTakahashiPeterTakahashi/claude-code-clip-video/CLAUDE.md

claude-code-clip-video

CLAUDE.md1 starsChanged 5 months agoMITView on GitHub

このリポジトリは claude-code-clip-video:長尺YouTube動画の人気作から 40〜60秒のショート切り抜きを 自動生成しアップロードするパイプライン。詳細手順は README.md、本書は要点だけ。

  • Reads credentials

The file

Files
CLAUDE.md

CLAUDE.md — 操作ガイド(Claude 向け)

このリポジトリは claude-code-clip-video:長尺YouTube動画の人気作から 40〜60秒のショート切り抜きを 自動生成しアップロードするパイプライン。詳細手順は README.md、本書は要点だけ。

0. まず守ること

  • アップロードは必ず人の確認 → 承認後。 生成は private で行い、data/clips/<id>/short.mp4 を見せてからアップ。勝手に public にしない。
  • 許諾。 切り抜き元の許可がある場合のみ処理する(channels/*.yaml の permission_note を確認)。新ソースは許可未確認なら着手前にユーザーへ確認。
  • 秘密情報をコミットしない。 .env / .youtube_token*.json / client_secret_*.json / data/ は .gitignore 済み。
  • 事実性。 タイトル・字幕は元動画の発言を歪めない。煽りすぎ・誤解を招く要約はしない。

1. 構成

  • Python は uv 管理。実行は uv run python -m src.<module>。
  • DB は docker compose の PostgreSQL(port 5434、webtoon-gen の 5433 とは別)。Redash は 5003。
  • クリップ選定は Claude Code(あなた)が担当。内部LLM呼び出しは無い。 transcript.json を読み clips JSON を書く → src.add_clips。詳細は .claude/skills/youtube-clipper/SKILL.md。
  • 文字起こしは OpenAIクラウド Whisper(src/transcribe.py, whisper-1, 10分チャンク分割で25MB制限回避)。OPENAI_API_KEY 必須。
  • 縦型化は ffmpeg(src/render.py): ぼかし背景全画面 + 元動画を顔中心の正方形クロップして上下中央配置 + 字幕。字幕は Pillow製PNG(黒box・白文字・**強調**で黄色)を overlay 合成。上=要約(hook,大)、下=発話字幕(≤2行・分割, subtitle_split)。※このマシンの ffmpeg は libass/drawtext 非対応。

2. パイプライン

ingest(URL) または discover → download → transcribe → (Claudeが選定→clips JSON) → add_clips(または compose)→ render →(確認)→ upload → stats_sync。 前処理一括は src.pipeline run <source_channel> --videos N / src.pipeline prep <video_id>。

3. データモデル(db/init/001_schema.sql, n:n)

  • source_channels 対象チャンネル / upload_channels アップ先(複数運用)
  • source_videos 長尺動画 / clips ショート / clip_segments 順序付き断片(ショート⇄長尺の n:n) / clip_stats 統計時系列
  • 1本のショートが複数の長尺から区間を結合できる(clip_segments.seq 順)。便利ビュー v_clips_latest。
  • DB変更は db/init/002_segments.sql(既存DBへ適用)。src.compose で複数長尺をまたぐショートを作成。

4. 主要コマンド

uv sync
docker compose up -d postgres
uv run python -m src.init_channels channels/okada_toshio.yaml
uv run python -m src.pipeline run okada_toshio --channel okada_clips_main --videos 3 --clips-per-video 5
# 確認後:
uv run python -m src.upload --channel okada_clips_main --status rendered --privacy public
# 分析:
docker compose up -d && uv run python scripts/setup_redash.py
uv run python -m src.stats_sync

5. ハマりどころ

  • 文字起こしが失敗 → OPENAI_API_KEY を確認。音声は ffmpeg で16kHz mono mp3に落として10分チャンクで送る(TRANSCRIBE_CHUNK_SECONDS)。
  • 字幕が出ない/豆腐になる → CLIP_FONT_FILE を日本語TTF/TTCに(既定 ヒラギノ角ゴシック W6.ttc 自動検出)。字幕は Pillow→PNG→ffmpeg overlay(ass/drawtext不可)。
  • 顔がズレる → CLIP_FACE_X_OFFSET(px, +で右) で正方形クロップの水平中心を調整。
  • 下字幕が長すぎ/3行以上 → subtitle_split.DEFAULT_MAX_CHARS(既定28) と render._render_caption_png(max_lines=2) を調整。
  • クリップが40-60秒に収まらない → clips JSON の segments の start/end を調整(add_clips/compose は尺を強制しない)。
  • YouTube quota 超過(アップロード ≈ 1本1600quota、既定1日10000)→ チャンネル分散 or 翌日(reset 17:00 JST頃)。
  • OAuth → client_secret_*.json をリポジトリ直下に。チャンネルごとに .youtube_token.<id>.json。
  • 再生成 → 各ステージ --force。

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.