SuperAPI AI Directory

video-content-analyzer

Data & analytics

View repository

Updated 10-15 08:07

About this skill

Video Content Analyzer

Automatically download videos and analyze content with AI, extract the complete speech transcript, and analyze video structure and pacing.

Features

  1. Video Download - Supports mainstream platforms such as Bilibili, Douyin, and YouTube
  2. Audio Extraction - Use ffmpeg to extract audio from the video
  3. Speech Transcription - Use OpenAI Whisper API to transcribe into text
  4. Content Analysis - AI analyzes video structure, pacing, hooks, etc.

Prerequisites

Required tools

# 安装 yt-dlp (视频下载)
pip3 install --break-system-packages yt-dlp
Install ffmpeg (audio processing) Mac: brew install ffmpeg Ubuntu: sudo apt install ffmpeg

### API Key

需要设置 OpenAI API Key(用于Whisper转写):
```bash
export OPENAI_API_KEY="your-api-key"

Or in ~/.openclaw/openclaw.json configure:

{
  "skills": {
    "openai-whisper-api": {
      "apiKey": "your-api-key"
    }
  }
}

Usage

Input

The user provides a video link, for example:

  • Bilibili: https://www.bilibili.com/video/BV1xuPYzcEdo
  • Douyin: https://www.douyin.com/video/xxx
  • YouTube: https://www.youtube.com/watch?v=xxx

Output

A complete analysis report, including:

  1. 📝 Full transcript (speech transcription)
  2. 🎬 Video structure analysis (chapters/time nodes)
  3. 🪝 Hook analysis
  4. ⏱️ Pacing analysis
  5. 💡 Content summary

Workflow

1. 输入视频链接
        ↓
2. yt-dlp 下载视频
        ↓
3. 获取视频时长,计算关键帧数量
        ↓
4. ffmpeg 提取关键帧(每30秒1帧)
        ↓
5. 获取弹幕数据(若有)
        ↓
6. Whisper API 转写(若有API)
        ↓
7. AI 分析画面+弹幕+文案
        ↓
8. 输出完整报告

Keyframe Extraction (Optimized Version)

Automatic Extraction Strategy

# 视频时长 / 30 = 关键帧数量
# 例如:8分钟视频 → 16-17张关键帧

# 提取关键帧(每30秒1帧)
ffmpeg -ss 00:00:00 -i video.mp4 -vframes 1 -q:v 2 frame_001.jpg -y
ffmpeg -ss 00:00:30 -i video.mp4 -vframes 1 -q:v 2 frame_002.jpg -y
ffmpeg -ss 00:01:00 -i video.mp4 -vframes 1 -q:v 2 frame_003.jpg -y
# ... 以此类推

Frame Count Recommendations

Video Duration Recommended Frames Interval
< 3 minutes 6-8 frames Every 20-30 seconds
3-10 minutes 12-20 frames Every 30 seconds
10-30 minutes 30-60 frames Every 30 seconds

Batch Extraction Script

import subprocess
import os

def extract_frames(video_path, output_dir, interval=30):
    """提取视频关键帧
    
    Args:
        video_path: 视频文件路径
        output_dir: 输出目录
        interval: 帧间隔(秒),默认30秒
    """
    # 获取视频时长
    cmd = ['ffprobe', '-v', 'error', '-show_entries', 
           'format=duration', '-of', 'default=noprint_wrappers=1:nokey=1', 
           video_path]
    result = subprocess.run(cmd, capture_output=True, text=True)
    duration = float(result.stdout.strip())
    
    # 计算帧数
    num_frames = int(duration // interval) + 1
    
    os.makedirs(output_dir, exist_ok=True)
    
    for i in range(num_frames):
        seconds = i * interval
        mins = seconds // 60
        secs = seconds % 60
        ts = f'{mins:02d}:{secs:02d}'
        out = f'{output_dir}/frame_{i+1:03d}.jpg'
        
        cmd = ['ffmpeg', '-ss', ts, '-i', video_path, 
               '-vframes', '1', '-q:v', '2', out, '-y']
        subprocess.run(cmd, capture_output=True)
        print(f'✓ Extracted {out}')
    
    return num_frames

# 使用示例
extract_frames('/tmp/video.mp4', '/tmp/frames', interval=30)

Command Line Examples

Manually download a Bilibili video

# 下载B站视频(仅音频)
yt-dlp -x --audio-format mp3 -o "%(title)s.%(ext)s" "https://www.bilibili.com/video/BV1xuPYzcEdo"

# 下载视频(最佳画质)
yt-dlp -f "bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best" -o "%(title)s.%(ext)s" "https://www.bilibili.com/video/BV1xuPYzcEdo"

# 仅下载字幕
yt-dlp --write-subs --skip-download -o "%(title)s" "https://www.bilibili.com/video/BV1xuPYzcEdo"

Extract audio

# 从视频提取音频
ffmpeg -i input.mp4 -vn -acodec libmp3lame -q:a 2 output.mp3

# 或直接用yt-dlp
yt-dlp -x --audio-format mp3 "https://www.bilibili.com/video/BV1xuPYzcEdo"

Output Template

# 📹 视频内容分析报告

**视频**: [标题]
**链接**: [URL]
**时长**: [时长]
**平台**: [B站/抖音/YouTube]
**关键帧数**: [数量]

---

## 📝 完整文案

[Whisper转写的完整语音文案]

---

## 🎬 视频结构(基于关键帧)

| 时间 | 画面内容 | 阶段 |
|------|---------|------|
| 0:00 | [第1帧描述] | 钩子 |
| 0:30 | [第2帧描述] | 铺垫 |
| 1:00 | [第3帧描述] | 主题展开 |
| ... | ... | ... |

---

## 🪝 钩子分析

[开头画面的钩子设计分析]

---

## 🎯 内容分层

- **开头 (0-1分钟)**:
- **中段 (1-5分钟)**:
- **高潮 (5-7分钟)**:
- **结尾 (7-分钟)**:

---

## 💡 爆款元素

| 元素 | 分析 |
|------|------|
| 情感点 | [弹幕高频情感词] |
| 互动点 | [弹幕互动热点] |
| 记忆点 | [金句/名场面] |

---

## 📊 弹幕热点词

[High-frequency danmaku extracted from danmaku.xml]


---

## 🔥 成功原因总结

1. [核心爆款因素]
2. [情感共鸣点]
3. [创新/独特之处]

---

## 总结

[视频的核心内容和亮点]

Notes

  1. 📡 Network - Downloading videos requires a stable network
  2. 💰 Cost - Whisper API is billed per minute (~$0.006/minute)
  3. ⏱️ Time - A complete analysis takes 3-5 minutes
  4. 📏 Length - Recommended video duration < 30 minutes
  5. 🔐 Copyright - For learning and analysis only, do not use for commercial purposes

Troubleshooting

Download Failed

  • Check the network connection
  • Try using a proxy
  • Bilibili may require Cookie authentication

Whisper Transcription Failed

  • Confirm that OPENAI_API_KEY is set correctly
  • Check the API balance
  • Whether the audio file is corrupted

ffmpeg Issues

  • Confirm that ffmpeg is installed: ffmpeg -version
  • Mac users: brew install ffmpeg