Communitygithub.com

VideoDB 技能

影片與音訊感知、索引與編輯。支援檔案/網址/直播串流擷取,建立視覺與語音索引,搭配時間戳搜尋,編輯時間軸,加上覆疊與字幕,生成媒體內容,以及即時警示。

VideoDB 技能 是什麼?

VideoDB 技能是一個強大的工具,專為開發者和 AI 代理設計,用於處理影片與音訊內容,涵蓋感知、索引、搜尋、編輯和生成。它支援多種來源,包括本地檔案、公開網址、桌面會話和 RTSP 直播串流,並能將處理結果轉換為可直接播放的串流連結。此技能的核心功能包括:擷取桌面螢幕與麥克風內容並建立可搜尋的會話記憶;對影片進行視覺、語音與關鍵字索引,實現精確的時間戳搜尋與證據播放;透過時間軸操作進行字幕生成、翻譯與燒錄、圖片/文字覆疊、背景音樂與配音合成;以及連接直播來源,即時監控並觸發事件警示。VideoDB 技能在 Claude Code、Cursor 等代理平台上運行,所有繁重的轉碼、索引與媒體生成工作均由 VideoDB 後端處理,大幅降低本地資源需求。它特別適合用於內容審查、監控、社交媒體剪輯、字幕製作與自動化媒體工作流程。

相容平台✓Claude Code~Codex CLI~Cursor
npx skills add https://github.com/AbobakrDiara61/railway-system/tree/HEAD/frontend/skills/videodb

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

VideoDB 技能 是做什麼的?

為影片、直播串流與桌面會話提供感知、記憶與操作。

當您需要以下功能時,請使用此技能:

使用時機

  • 您需要從檔案、網址、桌面會話或直播串流進行影片或音訊感知、索引、搜尋或時間軸編輯。
  • 任務涉及時間戳、可搜尋的證據、字幕、剪輯、覆疊或即時監控警示。
  • 您希望有一個統一的工作流程,將擷取、理解、檢索和媒體操作結合在一起。

1) 桌面感知

  • 啟動/停止 桌面會話,捕捉 螢幕、麥克風和系統音訊
  • 串流 即時上下文 並儲存 事件性會話記憶
  • 對螢幕上的語音和畫面內容執行 即時警示/觸發器
  • 產生 會話摘要、可搜尋的時間軸與 可播放的證據連結

2) 影片擷取 + 串流

  • 擷取 檔案或網址,並回傳 可播放的網頁串流連結
  • 轉碼/標準化:編碼格式、位元率、幀率、解析度、畫面比例

3) 索引 + 搜尋(時間戳 + 證據)

  • 建立 視覺、語音 和 關鍵字 索引
  • 搜尋並回傳帶有 時間戳 的準確時刻與 可播放的證據
  • 從搜尋結果自動建立 剪輯

4) 時間軸編輯 + 生成

  • 字幕:生成、翻譯、燒錄
  • 覆疊:文字/圖片/品牌標誌、動態字幕
  • 音訊:背景音樂、旁白、配音
  • 通過 時間軸操作 進行程式化合成與匯出

5) 直播串流 (RTSP) + 監控

  • 連接 RTSP/直播來源
  • 執行 即時視覺與語音理解,並為監控工作流程發出 事件/警示

常見輸入

  • 本地 檔案路徑、公開 網址 或 RTSP 網址
  • 桌面擷取請求:開始 / 停止 / 摘要會話
  • 期望的操作:取得理解上下文、轉碼規格、索引規格、搜尋查詢、剪輯範圍、時間軸編輯、警示規則

常見輸出

  • 串流網址
  • 帶有 時間戳 和 證據連結 的搜尋結果
  • 生成的資產:字幕、音訊、圖片、剪輯
  • 直播串流的 事件/警示負載
  • 桌面 會話摘要 與記憶條目

典型提示(範例)

  • "啟動桌面擷取,並在密碼欄位出現時發出警示。"
  • "錄製我的會話,並在結束時產出可操作的摘要。"
  • "擷取此檔案並回傳可播放的串流連結。"
  • "索引此資料夾,找出所有包含人物的場景,回傳時間戳。"
  • "生成字幕並燒錄進去,再加入輕柔的背景音樂。"
  • "連接此 RTSP 網址,並在有人進入區域時發出警示。"

執行 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 個陳述式,請改用 heredoc:

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

import videodb
conn = videodb.connect()
coll = conn.get_collection()
print(f"影片數量: {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 檔案中

在 https://console.videodb.io 取得免費 API 金鑰(50 次免費上傳,無需信用卡)。

請勿自行讀取、寫入或處理 API 金鑰。務必讓使用者自行設定。

快速參考

上傳媒體

# 網址
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("產品展示")
    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="描述此場景中的視覺內容。",
    )
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="一個人在白板上寫字",
        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="劇終", 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 上修剪影片,再對較短的結果進行 reframe
from videodb import ReframeMode

# 建議優先對短片段進行 reframe:
reframed = video.reframe(start=0, end=60, target="vertical", mode=ReframeMode.smart)

# 全長影片的非同步 reframe(回傳 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})

生成式媒體

image = coll.generate_image(
    prompt="日落山景",
    aspect_ratio="16:9",
)

錯誤處理

from videodb.exceptions import AuthenticationError, InvalidRequestError

try:
    conn = videodb.connect()
except AuthenticationError:
    print("請檢查您的 VIDEO_DB_API_KEY")

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

常見陷阱

情境錯誤訊息解決方案
為已索引過的影片建立索引Spoken word index for video already exists使用 video.index_spoken_words(force=True) 跳過,如果已索引則不處理
場景索引已存在Scene index with id XXXX already exists使用 re.search(r"id\s+([a-f0-9]+)", str(e)) 從錯誤中擷取現有的 scene_index_id
搜尋找不到匹配InvalidRequestError: No results found捕捉例外並視為空結果 (shots = [])
Reframe 逾時長時間影片會無限阻塞使用 start/end 限制片段,或傳遞 callback_url 進行非同步處理
時間軸上的負時間戳記靜默產生有問題的串流在建立 VideoAsset 之前,務必驗證 start >= 0
generate_video() / create_collection() 失敗Operation not allowed 或 maximum limit方案限制的功能 — 請告知使用者方案限制

其他文件

參考文件位於此 SKILL.md 檔案旁的 reference/ 目錄中。如有需要,請使用 Glob 工具查找。

螢幕錄製(桌面擷取)

使用 ws_listener.py 在錄製會話期間擷取 WebSocket 事件。桌面擷取僅支援 macOS。

快速開始

  1. 啟動監聽器:python scripts/ws_listener.py &
  2. 取得 WebSocket ID:cat /tmp/videodb_ws_id
  3. 執行擷取程式碼(完整工作流程請參閱 reference/capture.md)
  4. 事件寫入位置:/tmp/videodb_events.jsonl

查詢事件

import json
events = [json.loads(l) for l in open("/tmp/videodb_events.jsonl")]

# 取得所有逐字稿
transcripts = [e["data"]["text"] for e in events if e.get("channel") == "transcript"]

# 取得最近 5 分鐘的視覺描述
import time
cutoff = time.time() - 300
recent_visual = [e for e in events 
                 if e.get("channel") == "visual_index" and e["unix_ts"] > cutoff]

工具指令碼

完整的擷取工作流程,請參閱 reference/capture.md。

如果 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()

儲存庫

https://github.com/video-db/skills

維護者: VideoDB

限制

  • 僅在任務明確符合上述範圍時使用此技能。
  • 請勿將輸出視為環境特定驗證、測試或專家審查的替代品。
  • 如果缺少必要的輸入、權限、安全邊界或成功標準,請停止並要求澄清。

Individual skills in this repo

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

AbobakrDiara61/railway-system

Skill for discovering and researching autonomous AI agents, tools, and ecosystems using the AgentFolio directory.

AbobakrDiara61/railway-system

Advanced JavaScript animation library skill for creating complex, high-performance web animations.

AbobakrDiara61/railway-system

Astropy is the core Python package for astronomy, providing essential functionality for astronomical research and data analysis.

AbobakrDiara61/railway-system

One sentence - what this skill does and when to invoke it

AbobakrDiara61/railway-system

Audit and fix animation performance issues including layout thrashing, compositor properties, scroll-linked motion, and blur effects. Use when animations stutter, transitions jank, or reviewing CSS/JS animation performance.

AbobakrDiara61/railway-system

Internationalization and localization patterns. Detecting hardcoded strings, managing translations, locale files, RTL support.

AbobakrDiara61/railway-system

Expert in building portfolios that actually land jobs and clients - not just showing work, but creating memorable experiences. Covers developer portfolios, designer portfolios, creative portfolios, and portfolios that convert visitors into opportunities.

AbobakrDiara61/railway-system

Generates high-converting Next.js/React landing pages with Tailwind CSS. Uses PAS, AIDA, and BAB frameworks for optimized copy/components (Heroes, Features, Pricing). Focuses on Core Web Vitals/SEO.

AbobakrDiara61/railway-system

AI-powered animation tool for creating motion in logos, UI, icons, and social media assets.

AbobakrDiara61/railway-system

CRITICAL: Use for Makepad animation system. Triggers on: makepad animation, makepad animator, makepad hover, makepad state, makepad transition, "from: { all: Forward", makepad pressed, makepad 动画, makepad 状态, makepad 过渡, makepad 悬停效果

AbobakrDiara61/railway-system

Best practices for Remotion - Video creation in React

AbobakrDiara61/railway-system

Generate walkthrough videos from Stitch projects using Remotion with smooth transitions, zooming, and text overlays

AbobakrDiara61/railway-system

Seek and analyze video content using Memories.ai Large Visual Memory Model for persistent video intelligence

AbobakrDiara61/railway-system

Writes complete, structured landing pages optimized for SEO ranking, AEO citation, and visitor conversion. Activate when the user wants to write or generate a landing page for a product, service, or offer.

AbobakrDiara61/railway-system

Three.js animation - keyframe animation, skeletal animation, morph targets, animation mixing. Use when animating objects, playing GLTF animations, creating procedural motion, or blending animations.

AbobakrDiara61/railway-system

Automate TikTok tasks via Rube MCP (Composio): upload/publish videos, post photos, manage content, and view user profiles/stats. Always search tools first for current schemas.

AbobakrDiara61/railway-system

Upload, stream, search, edit, transcribe, and generate AI video and audio using the VideoDB SDK.

AbobakrDiara61/railway-system

One sentence - what this skill does and when to invoke it

AbobakrDiara61/railway-system

Automate YouTube tasks via Rube MCP (Composio): upload videos, manage playlists, search content, get analytics, and handle comments. Always search tools first for current schemas.

AbobakrDiara61/railway-system

Extract transcripts from YouTube videos and generate comprehensive, detailed summaries using intelligent analysis frameworks

相關技能