Communitygithub.com

VideoDB

動画・音声の取り込み、インデックス作成、検索、トランスコード、タイムライン編集、生成、ライブストリーム監視、デスクトップキャプチャを実現するAIエージェントスキルです。

VideoDB とは?

このスキルは、VideoDB SDKを介して動画・音声コンテンツに対する「認識」「理解」「操作」を統合的に行うためのツールです。ファイルやURL、YouTube、RTSPストリーム、デスクトップキャプチャからの取り込みをサポートし、再生可能なストリームリンクを返します。また、音声・視覚・意味・キーワードベースのインデックスを構築し、タイムスタンプ付きの検索結果と自動クリップ生成が可能です。トランスコード(コーデック、fps、解像度、アスペクト比の変換)、字幕生成・翻訳・焼き込み、テキスト・画像・ブランディングオーバーレイ、音声重ね合わせ(ナレーション、BGM、吹き替え)、画像・音声・動画の生成AIメディア作成、そしてライブストリームやデスクトップキャプチャのリアルタイムイベント監視とアラートまでをカバーします。特に、ffmpegやmoviepyなどのローカルツールに頼らず、サーバーサイドで一貫した処理を提供する点が特徴で、エラー処理や一般的な落とし穴(既存インデックスの強制上書き、シーン検索のスコア閾値、タイムラインのタイムスタンプ検証など)のベストプラクティスも詳細に記載されています。

対応✓Claude Code~Codex CLI~Cursor
npx skills add https://github.com/affaan-m/ECC/tree/main/skills/videodb

お気に入りのAIに質問する

このエージェントスキルを事前に読み込んだ状態で新しいチャットを開きます。

ドキュメント

VideoDB スキル

動画、ライブストリーム、デスクトップセッションのための「認識+記憶+操作」

使用タイミング

デスクトップ認識

  • デスクトップセッションを開始/停止し、画面、マイク、システム音声をキャプチャ
  • ライブコンテキストをストリームし、エピソード的セッション記憶を保存
  • 画面に表示されている内容や発話に基づいてリアルタイムアラート/トリガーを実行
  • セッション要約、検索可能なタイムライン、再生可能な証拠リンクを生成

動画取り込み+ストリーム

  • ファイルまたはURLを取り込み、再生可能なWebストリームリンクを返す
  • トランスコード/正規化: コーデック、ビットレート、fps、解像度、アスペクト比

インデックス+検索(タイムスタンプ+証拠)

  • 視覚、発話、キーワードのインデックスを構築
  • 正確な瞬間をタイムスタンプと再生可能な証拠とともに検索・返却
  • 検索結果から自動でクリップを作成

タイムライン編集+生成

  • 字幕: 生成、翻訳、焼き込み
  • オーバーレイ: テキスト/画像/ブランディング、モーションキャプション
  • 音声: BGM、ナレーション、吹き替え
  • タイムライン操作によるプログラム的な合成と書き出し

ライブストリーム(RTSP)+監視

  • RTSP/ライブフィードに接続
  • リアルタイムの視覚・発話理解を実行し、監視ワークフロー向けにイベント/アラートを発行

動作の仕組み

一般的な入力

  • ローカルファイルパス、公開URL、またはRTSP URL
  • デスクトップキャプチャリクエスト: セッションの開始/停止/要約
  • 希望する操作: 理解のためのコンテキスト取得、トランスコード仕様、インデックス仕様、検索クエリ、クリップ範囲、タイムライン編集、アラートルール

一般的な出力

  • ストリームURL
  • タイムスタンプと証拠リンクを含む検索結果
  • 生成されたアセット: 字幕、音声、画像、クリップ
  • ライブストリームのイベント/アラートペイロード
  • デスクトップセッション要約と記憶エントリ

Pythonコードの実行

VideoDBコードを実行する前に、プロジェクトディレクトリに移動して環境変数を読み込みます:

from dotenv import load_dotenv
load_dotenv(".env")

import videodb
conn = videodb.connect()

これにより、VIDEO_DB_API_KEY が以下から読み込まれます:

  1. 環境変数(すでにエクスポートされている場合)
  2. 現在のディレクトリのプロジェクト .env ファイル

キーがない場合、videodb.connect() は自動的に AuthenticationError を発生させます。

短いインラインコマンドで済む場合はスクリプトファイルを作成しないでください。

インラインPython(python -c "...")を記述する場合、常に適切にフォーマットされたコードを使用してください。セミコロンでステートメントを区切り、読みやすく保ちます。約3ステートメントを超える場合は、代わりにヒアドキュメントを使用してください:

python << 'EOF'
from dotenv import load_dotenv
load_dotenv(".env")

import videodb
conn = videodb.connect()
coll = conn.get_collection()
print(f"Videos: {len(coll.get_videos())}")
EOF

セットアップ

ユーザーが「videodbをセットアップして」などと依頼した場合:

1. SDKのインストール

pip install "videodb[capture]" python-dotenv

Linuxで videodb[capture] が失敗した場合は、captureエクストラなしでインストール:

pip install videodb python-dotenv

2. APIキーの設定

ユーザーは以下のいずれかの方法で VIDEO_DB_API_KEY を設定する必要があります:

  • ターミナルでエクスポート(Claudeを起動する前): export VIDEO_DB_API_KEY=your-key
  • プロジェクトの .env ファイル: VIDEO_DB_API_KEY=your-key をプロジェクトの .env ファイルに保存

無料のAPIキーは console.videodb.io で取得できます(無料アップロード50回、クレジットカード不要)

APIキーを自分で読み取り、書き込み、または処理しないでください。 常にユーザーに設定させてください。

クイックリファレンス

メディアのアップロード

# URL
video = coll.upload(url="https://example.com/video.mp4")

# YouTube
video = coll.upload(url="https://www.youtube.com/watch?v=VIDEO_ID")

# ローカルファイル
video = coll.upload(file_path="/path/to/video.mp4")

文字起こし+字幕

# force=True は動画がすでにインデックスされている場合のエラーをスキップ
video.index_spoken_words(force=True)
text = video.get_transcript_text()
stream_url = video.add_subtitle()

動画内検索

from videodb.exceptions import InvalidRequestError

video.index_spoken_words(force=True)

# search() は結果が見つからない場合に InvalidRequestError を発生させます。
# 常に try/except でラップし、「結果が見つかりません」を空として扱います。
try:
    results = video.search("product demo")
    shots = results.get_shots()
    stream_url = results.compile()
except InvalidRequestError as e:
    if "No results found" in str(e):
        shots = []
    else:
        raise

シーン検索

import re
from videodb import SearchType, IndexType, SceneExtractionType
from videodb.exceptions import InvalidRequestError

# index_scenes() には force パラメータはありません — シーンインデックスが
# すでに存在する場合はエラーを発生させます。エラーから既存のインデックスIDを抽出します。
try:
    scene_index_id = video.index_scenes(
        extraction_type=SceneExtractionType.shot_based,
        prompt="Describe the visual content in this scene.",
    )
except Exception as e:
    match = re.search(r"id\s+([a-f0-9]+)", str(e))
    if match:
        scene_index_id = match.group(1)
    else:
        raise

# score_threshold を使用して低関連性のノイズをフィルタリング(推奨: 0.3以上)
try:
    results = video.search(
        query="person writing on a whiteboard",
        search_type=SearchType.semantic,
        index_type=IndexType.scene,
        scene_index_id=scene_index_id,
        score_threshold=0.3,
    )
    shots = results.get_shots()
    stream_url = results.compile()
except InvalidRequestError as e:
    if "No results found" in str(e):
        shots = []
    else:
        raise

タイムライン編集

重要: タイムラインを構築する前に、常にタイムスタンプを検証してください:

  • start は 0 以上である必要があります(負の値は黙って受け入れられますが、壊れた出力を生成します)
  • start は end より小さくなければなりません
  • end は video.length 以下でなければなりません
from videodb.timeline import Timeline
from videodb.asset import VideoAsset, TextAsset, TextStyle

timeline = Timeline(conn)
timeline.add_inline(VideoAsset(asset_id=video.id, start=10, end=30))
timeline.add_overlay(0, TextAsset(text="The End", duration=3, style=TextStyle(fontsize=36)))
stream_url = timeline.generate_stream()

動画のトランスコード(解像度/画質変更)

from videodb import TranscodeMode, VideoConfig, AudioConfig

# サーバーサイドで解像度、画質、アスペクト比を変更
job_id = conn.transcode(
    source="https://example.com/video.mp4",
    callback_url="https://example.com/webhook",
    mode=TranscodeMode.economy,
    video_config=VideoConfig(resolution=720, quality=23, aspect_ratio="16:9"),
    audio_config=AudioConfig(mute=False),
)

アスペクト比のリフレーム(ソーシャルプラットフォーム向け)

警告: reframe() は低速なサーバーサイド操作です。長い動画の場合、数分かかりタイムアウトする可能性があります。ベストプラクティス:

  • 可能な限り start/end を使用して短いセグメントに制限
  • 全長動画の場合は、callback_url を使用して非同期処理
  • まず Timeline で動画をトリミングし、その短い結果をリフレーム
from videodb import ReframeMode

# 常に短いセグメントのリフレームを優先:
reframed = video.reframe(start=0, end=60, target="vertical", mode=ReframeMode.smart)

# 全長動画の非同期リフレーム(Noneを返し、結果はWebhook経由):
video.reframe(target="vertical", callback_url="https://example.com/webhook")

# プリセット: "vertical" (9:16), "square" (1:1), "landscape" (16:9)
reframed = video.reframe(start=0, end=60, target="square")

# カスタムサイズ
reframed = video.reframe(start=0, end=60, target={"width": 1280, "height": 720})

生成AIメディア

image = coll.generate_image(
    prompt="a sunset over mountains",
    aspect_ratio="16:9",
)

エラー処理

from videodb.exceptions import AuthenticationError, InvalidRequestError

try:
    conn = videodb.connect()
except AuthenticationError:
    print("Check your VIDEO_DB_API_KEY")

try:
    video = coll.upload(url="https://example.com/video.mp4")
except InvalidRequestError as e:
    print(f"Upload failed: {e}")

よくある落とし穴

シナリオエラーメッセージ解決策
すでにインデックス済みの動画を再インデックスSpoken word index for video already existsvideo.index_spoken_words(force=True) を使用してスキップ
シーンインデックスが既に存在Scene index with id XXXX already existsre.search(r"id\s+([a-f0-9]+)", str(e)) で既存の scene_index_id を抽出
検索結果なしInvalidRequestError: No results found例外をキャッチし、空の結果として扱う(shots = [])
リフレームがタイムアウト長い動画で無期限にブロックstart/end でセグメントを制限、または callback_url で非同期処理
タイムラインに負のタイムスタンプ壊れたストリームを黙って生成VideoAsset を作成する前に start >= 0 を常に検証
generate_video() / create_collection() が失敗Operation not allowed または maximum limitプラン制限機能 — ユーザーにプラン制限について通知

例

典型的なプロンプト

  • 「デスクトップキャプチャを開始し、パスワードフィールドが表示されたらアラートを出してください。」
  • 「セッションを記録し、終了時に実用的な要約を生成してください。」
  • 「このファイルを取り込み、再生可能なストリームリンクを返してください。」
  • 「このフォルダをインデックスし、人物がいるシーンをすべて見つけてタイムスタンプを返してください。」
  • 「字幕を生成し、焼き込んで、軽いBGMを追加してください。」
  • 「このRTSP URLに接続し、人がゾーンに入ったらアラートを出してください。」

画面録画(デスクトップキャプチャ)

録画セッション中にWebSocketイベントをキャプチャするには ws_listener.py を使用します。デスクトップキャプチャは macOS のみサポートされています。

クイックスタート

  1. 状態ディレクトリを選択: STATE_DIR="${VIDEODB_EVENTS_DIR:-$HOME/.local/state/videodb}"
  2. リスナーを起動: VIDEODB_EVENTS_DIR="$STATE_DIR" python scripts/ws_listener.py --clear "$STATE_DIR" &
  3. WebSocket IDを取得: cat "$STATE_DIR/videodb_ws_id"
  4. キャプチャコードを実行(完全なワークフローは reference/capture.md を参照)
  5. イベントが書き込まれる場所: $STATE_DIR/videodb_events.jsonl

新しいキャプチャ実行を開始するときは常に --clear を使用して、古い文字起こしイベントや視覚イベントが新しいセッションに漏れないようにします。

イベントのクエリ

import json
import os
import time
from pathlib import Path

events_dir = Path(os.environ.get("VIDEODB_EVENTS_DIR", Path.home() / ".local" / "state" / "videodb"))
events_file = events_dir / "videodb_events.jsonl"
events = []

if events_file.exists():
    with events_file.open(encoding="utf-8") as handle:
        for line in handle:
            try:
                events.append(json.loads(line))
            except json.JSONDecodeError:
                continue

transcripts = [e["data"]["text"] for e in events if e.get("channel") == "transcript"]
cutoff = time.time() - 300
recent_visual = [
    e for e in events
    if e.get("channel") == "visual_index" and e["unix_ts"] > cutoff
]

追加ドキュメント

リファレンスドキュメントはこのSKILL.mdファイルと同じディレクトリの reference/ にあります。必要に応じてGlobツールを使用して探してください。

VideoDBが操作をサポートしている場合、ffmpeg、moviepy、またはローカルのエンコードツールを使用しないでください。 以下はすべてVideoDBがサーバーサイドで処理します — トリミング、クリップの結合、音声や音楽のオーバーレイ、字幕の追加、テキスト/画像オーバーレイ、トランスコード、解像度変更、アスペクト比変換、プラットフォーム要件に合わせたリサイズ、文字起こし、メディア生成。ローカルツールへのフォールバックは、reference/editor.md の「制限事項」に記載されている操作(トランジション、速度変更、クロップ/ズーム、カラーグレーディング、音量ミキシング)にのみ行ってください。

何をいつ使うか

問題VideoDBの解決策
プラットフォームが動画のアスペクト比や解像度を拒否video.reframe() または VideoConfig を使った conn.transcode()
Twitter/Instagram/TikTok用に動画をリサイズvideo.reframe(target="vertical") または target="square"
解像度変更(例: 1080p→720p)VideoConfig(resolution=720) を使った conn.transcode()
動画に音声/音楽をオーバーレイTimeline 上の AudioAsset
字幕を追加video.add_subtitle() または CaptionAsset
クリップの結合/トリミングTimeline 上の VideoAsset
ナレーション、音楽、効果音を生成coll.generate_voice()、generate_music()、generate_sound_effect()

出典

このスキルのリファレンス資料は skills/videodb/reference/ 以下にローカルにベンダリングされています。実行時に外部リポジトリのリンクをたどる代わりに、上記のローカルコピーを使用してください。

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

accessibility

Design, implement, and audit inclusive digital products using WCAG 2.2 Level AA. Use when building or auditing UI that must meet WCAG 2.2 Level AA, or when reviewing a change for keyboard, contrast, or screen-reader support.

affaan-m/content-engine

Create platform-native content systems for X, LinkedIn, TikTok, YouTube, newsletters, and repurposed multi-platform campaigns. Use when the user wants social posts, threads, scripts, content calendars, or one source asset adapted cleanly across platforms.

affaan-m/ECC

Multi-platform content distribution across X, LinkedIn, Threads, and Bluesky. Adapts content per platform using content-engine patterns. Never posts identical content cross-platform. Use when the user wants to distribute content across social platforms.

affaan-m/fal-ai-media

Unified media generation via fal.ai MCP — image, video, and audio. Covers text-to-image (Nano Banana), text/image-to-video (Seedance, Kling, Veo 3), text-to-speech (CSM-1B), and video-to-audio (ThinkSound). Use when the user wants to generate images, videos, or audio with AI.

affaan-m/manim-video

日本語翻訳:このファイルは manim-video 用の日本語翻訳が必要です

affaan-m/remotion-video-creation

Remotion のベストプラクティス - React で動画を作成する。3D、アニメーション、音声、字幕、チャート、トランジションなどをカバーするドメイン固有の29のルール。

affaan-m/video-editing

AI-assisted video editing workflows for cutting, structuring, and augmenting real footage. Covers the full pipeline from raw capture through FFmpeg, Remotion, ElevenLabs, fal.ai, and final polish in Descript or CapCut. Use when the user wants to edit video, cut footage, create vlogs, or build video content.

agent-architecture-audit

Full-stack diagnostic for agent and LLM applications. Audits the 12-layer agent stack for wrapper regression, memory pollution, tool discipline failures, hidden repair loops, and rendering corruption. Produces severity-ranked findings with code-first fixes. Essential for developers building agent applications, autonomous loops, or any LLM-powered feature. Use when an agent or LLM feature misbehaves and the failing layer is unknown, or before shipping an agent stack.

agent-eval

Head-to-head comparison of coding agents (Claude Code, Aider, Codex, etc.) on custom tasks with pass rate, cost, time, and consistency metrics. Use when choosing between coding agents, or when a change to an agent setup needs measured pass rate, cost, and time rather than an impression.

agent-harness-construction

Design and optimize AI agent action spaces, tool definitions, and observation formatting for higher completion rates. Use when defining or revising an agent

agentic-engineering

Operate as an agentic engineer using eval-first execution, decomposition, and cost-aware model routing. Use when planning or executing engineering work that agents will carry out end to end.

agentic-os

Build persistent multi-agent operating systems on Claude Code. Covers kernel architecture, specialist agents, slash commands, file-based memory, scheduled automation, and state management without external databases. Use when building a persistent multi-agent system on Claude Code with its own memory, commands, and scheduling.

agent-introspection-debugging

Structured self-debugging workflow for AI agent failures using capture, diagnosis, contained recovery, and introspection reports. Use when an agent run fails and you need a reproducible diagnosis instead of a retry.

agent-payment-x402

Add x402 payment execution to AI agents with per-task budgets, spending controls, and non-custodial wallets. Supports Base through agentwallet-sdk and X Layer through OKX Payments / OKX Agent Payments Protocol. Use when an agent must pay for something itself and needs per-task budgets, spending controls, and a non-custodial wallet.

agent-self-evaluation

Use after completing any non-trivial task. The agent self-rates its output on 5 axes — accuracy, completeness, clarity, actionability, conciseness — with concrete evidence per criterion. Produces a structured 1-5 scorecard with specific improvement suggestions.

agent-sort

Build an evidence-backed ECC install plan for a specific repo by sorting skills, commands, rules, hooks, and extras into DAILY vs LIBRARY buckets using parallel repo-aware review passes. Use when ECC should be trimmed to what a project actually needs instead of loading the full bundle.

ai-first-engineering

Engineering operating model for teams where AI agents generate a large share of implementation output. Use when setting team process, review gates, or ownership rules for a codebase largely written by agents.

ai-regression-testing

Regression testing strategies for AI-assisted development. Sandbox-mode API testing without database dependencies, automated bug-check workflows, and patterns to catch AI blind spots where the same model writes and reviews code. Use when adding regression coverage to AI-assisted code, or when the same model both wrote and reviewed a change.

android-clean-architecture

Clean Architecture patterns for Android and Kotlin Multiplatform projects — module structure, dependency rules, UseCases, Repositories, and data layer patterns. Use when structuring modules, layers, or data flow in an Android or KMP project.

angular-developer

Generates Angular code and provides architectural guidance. Trigger when creating projects, components, or services, or for best practices on reactivity (signals, linkedSignal, resource), forms, dependency injection, routing, SSR, accessibility (ARIA), animations, styling (component styles, Tailwind CSS), testing, or CLI tooling.

関連スキル