video-frames

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Video-Frames Skill

Video-Frames 技能

Production-grade video frame extraction with comprehensive quality control, progress tracking, and safety limits.
具备全面质量控制、进度追踪和安全限制的生产级视频帧提取工具。

When to Use

适用场景

USE this skill when:
  • Extracting specific frames from videos at timestamps
  • Creating thumbnail grids/contact sheets for video overview
  • Generating animated GIFs from video segments
  • Batch extracting frames at intervals (e.g., every N seconds)
  • Creating video previews or storyboards
  • Needing pixel-perfect frame access by index
  • Extracting frames at specific quality levels
DON'T use this skill when:
  • Simple format conversion → Use ffmpeg-tools
  • Video editing (effects) → Use video editor
  • Real-time frame capture → Use streaming tools
  • Video capture from camera → Use camsnap
  • Image generation → Use image-gen
适用场景:
  • 从视频中按时间戳提取特定帧
  • 为视频概览创建缩略图网格/联络表
  • 从视频片段生成动画GIF
  • 按固定间隔批量提取帧(例如:每N秒一帧)
  • 创建视频预览或故事板
  • 需要按索引精确访问某一帧
  • 按特定质量等级提取帧
不适用场景:
  • 简单格式转换 → 使用ffmpeg-tools
  • 视频编辑(添加特效)→ 使用视频编辑器
  • 实时帧捕获 → 使用流媒体工具
  • 从摄像头捕获视频 → 使用camsnap
  • 图像生成 → 使用image-gen

Prerequisites

前置要求

bash
undefined
bash
undefined

Install FFmpeg

安装 FFmpeg

brew install ffmpeg # macOS sudo apt install ffmpeg # Ubuntu/Debian
brew install ffmpeg # macOS sudo apt install ffmpeg # Ubuntu/Debian

Optional: Install ImageMagick for better grid generation

可选:安装 ImageMagick 以获得更好的网格生成效果

brew install imagemagick # macOS sudo apt install imagemagick # Ubuntu
brew install imagemagick # macOS sudo apt install imagemagick # Ubuntu

Verify installation

验证安装

ffmpeg -version ffprobe -version
undefined
ffmpeg -version ffprobe -version
undefined

Commands

命令说明

1. Extract Single Frame

1. 提取单帧

Extract a single frame at a specific time or by frame index.
bash
undefined
按特定时间或帧索引提取单帧。
bash
undefined

Extract frame at timestamp

按时间戳提取帧

{baseDir}/video-frames.js frame video.mp4 --time 30 --out frame.jpg {baseDir}/video-frames.js frame video.mp4 --time 00:02:30 --out frame.jpg {baseDir}/video-frames.js frame video.mp4 --time 150.5 --out frame.jpg
{baseDir}/video-frames.js frame video.mp4 --time 30 --out frame.jpg {baseDir}/video-frames.js frame video.mp4 --time 00:02:30 --out frame.jpg {baseDir}/video-frames.js frame video.mp4 --time 150.5 --out frame.jpg

Extract by frame index

按帧索引提取

{baseDir}/video-frames.js frame video.mp4 --index 0 --out first-frame.jpg {baseDir}/video-frames.js frame video.mp4 --index 1000 --out frame-1000.jpg
{baseDir}/video-frames.js frame video.mp4 --index 0 --out first-frame.jpg {baseDir}/video-frames.js frame video.mp4 --index 1000 --out frame-1000.jpg

With quality settings

带质量设置

{baseDir}/video-frames.js frame video.mp4 --time 30 --format png --out high-quality.png {baseDir}/video-frames.js frame video.mp4 --time 30 --quality 1 --out best-quality.jpg {baseDir}/video-frames.js frame video.mp4 --time 30 --format jpg --quality 2

**Time Formats:**
| Format | Example | Description |
|--------|---------|-------------|
| Seconds | `30` | Simple seconds |
| MM:SS | `2:30` | Minutes:Seconds |
| HH:MM:SS | `00:02:30` | Full timecode |
| Decimal | `90.5` | Millisecond precision |

**Quality Settings (JPEG):**
| Value | Quality | File Size | Use Case |
|-------|---------|-----------|----------|
| `1` | Best | Large | Archival, quality preservation |
| `2-3` | High | Medium | Default, good balance |
| `5` | Medium | Small | Web, quick preview |
| `10+` | Low | Very small | Draft, thumbnail |

**Supported Formats:**
- `jpg/jpeg` - Web optimized, compression
- `png` - Lossless, transparency, best quality
- `bmp` - Uncompressed raw
- `tiff` - Professional formats
- `webp` - Next-gen web format
{baseDir}/video-frames.js frame video.mp4 --time 30 --format png --out high-quality.png {baseDir}/video-frames.js frame video.mp4 --time 30 --quality 1 --out best-quality.jpg {baseDir}/video-frames.js frame video.mp4 --time 30 --format jpg --quality 2

**时间格式:**
| 格式 | 示例 | 说明 |
|--------|---------|-------------|
| 秒 | `30` | 简单秒数 |
| 分:秒 | `2:30` | 分钟:秒数 |
| 时:分:秒 | `00:02:30` | 完整时间码 |
| 十进制 | `90.5` | 毫秒精度 |

**JPEG 质量设置:**
| 数值 | 质量 | 文件大小 | 适用场景 |
|-------|---------|-----------|----------|
| `1` | 最佳 | 大 | 归档、画质保留 |
| `2-3` | 高 | 中等 | 默认选项,平衡画质与大小 |
| `5` | 中等 | 小 | 网页使用、快速预览 |
| `10+` | 低 | 极小 | 草稿、缩略图 |

**支持的输出格式:**
- `jpg/jpeg` - 网页优化格式,带压缩
- `png` - 无损格式,支持透明,画质最佳
- `bmp` - 无压缩原始格式
- `tiff` - 专业格式
- `webp` - 下一代网页格式

2. Extract Multiple Frames

2. 提取多帧

Batch extract frames at regular intervals.
bash
undefined
按固定间隔批量提取帧。
bash
undefined

Extract 1 frame per second

每秒提取1帧

{baseDir}/video-frames.js frames video.mp4 --fps 1
{baseDir}/video-frames.js frames video.mp4 --fps 1

Extract specific segment

提取特定片段

{baseDir}/video-frames.js frames video.mp4 --fps 1 --start 00:01:00 --duration 60 {baseDir}/video-frames.js frames video.mp4 --fps 5 --start 30 --duration 120
{baseDir}/video-frames.js frames video.mp4 --fps 1 --start 00:01:00 --duration 60 {baseDir}/video-frames.js frames video.mp4 --fps 5 --start 30 --duration 120
高质量提取 {baseDir}/video-frames.js frames video.mp4 --fps 1 --quality 1 --prefix keyframe

Higher quality extraction

提取时调整尺寸

{baseDir}/video-frames.js frames video.mp4 --fps 1 --quality 1 --prefix keyframe
{baseDir}/video-frames.js frames video.mp4 --fps 1 --width 1920 --quality 1

**帧率选项:**
| 帧率 | 说明 | 适用场景 |
|------|-------------|----------|
| `--fps 1` | 每秒1帧 | 时间轴提取 |
| `--fps 5` | 每秒5帧 | 细节分析 |
| `--fps 0.1` | 每10秒1帧 | 概览、故事板 |
| `--fps 0.5` | 每2秒1帧 | 中等细节需求 |

**输出结构:**
/tmp/frames_1234567890/ ├── frame_00001.jpg ├── frame_00002.jpg ├── frame_00003.jpg └── ...
undefined

Resize during extraction

3. 生成缩略图网格(联络表)

{baseDir}/video-frames.js frames video.mp4 --fps 1 --width 1920 --quality 1

**Frame Rate Options:**
| Rate | Description | Use Case |
|------|-------------|----------|
| `--fps 1` | 1 frame/second | Timeline extraction |
| `--fps 5` | 5 frames/second | Detailed analysis |
| `--fps 0.1` | Every 10 seconds | Overview, storyboard |
| `--fps 0.5` | Every 2 seconds | Moderate detail |

**Output:**
/tmp/frames_1234567890/ ├── frame_00001.jpg ├── frame_00002.jpg ├── frame_00003.jpg └── ...
undefined
创建视频概览用的缩略图网格。
bash
undefined

3. Generate Thumbnail Grid (Contact Sheet)

基础网格

Create a grid of thumbnails for video overview.
bash
undefined
{baseDir}/video-frames.js grid video.mp4 --output grid.jpg

Basic grid

自定义尺寸与布局

{baseDir}/video-frames.js grid video.mp4 --output grid.jpg
{baseDir}/video-frames.js grid video.mp4 --count 16 --columns 4 --width 480 --out grid.jpg

Custom size and layout

紧凑预览

{baseDir}/video-frames.js grid video.mp4 --count 16 --columns 4 --width 480 --out grid.jpg
{baseDir}/video-frames.js grid video.mp4 --count 20 --columns 5 --width 320 --out overview.jpg

Compact preview

高分辨率网格

{baseDir}/video-frames.js grid video.mp4 --count 20 --columns 5 --width 320 --out overview.jpg
{baseDir}/video-frames.js grid video.mp4 --count 9 --columns 3 --width 640 --format png --out detailed.png

**网格布局示例:**

| 缩略图数量 | 列数 | 行数 | 最佳用途 |
|-------|---------|------|----------|
| 4 | 2 | 2 | 快速预览 |
| 9 | 3 | 3 | 标准概览 |
| 12 | 4 | 3 | 详细时间轴 |
| 16 | 4 | 4 | 全面故事板 |
| 20 | 5 | 4 | 长视频 |

**输出格式示意:**
+---+---+---+---+ | 1 | 2 | 3 | 4 | <- 视频第5秒 +---+---+---+---+ | 5 | 6 | 7 | 8 | <- 视频第25秒 +---+---+---+---+ | 9 |10 |11 |12 | <- 视频第45秒 +---+---+---+---+
undefined

High resolution grid

4. 创建动画GIF

{baseDir}/video-frames.js grid video.mp4 --count 9 --columns 3 --width 640 --format png --out detailed.png

**Grid Layout Examples:**

| Count | Columns | Rows | Best For |
|-------|---------|------|----------|
| 4 | 2 | 2 | Quick preview |
| 9 | 3 | 3 | Standard overview |
| 12 | 4 | 3 | Detailed timeline |
| 16 | 4 | 4 | Comprehensive storyboard |
| 20 | 5 | 4 | Long videos |

**Output Format:**
+---+---+---+---+ | 1 | 2 | 3 | 4 | <- 5 seconds into video +---+---+---+---+ | 5 | 6 | 7 | 8 | <- 25 seconds into video +---+---+---+---+ | 9 |10 |11 |12 | <- 45 seconds into video +---+---+---+---+
undefined
将视频片段提取为动画GIF。
bash
undefined

4. Create Animated GIF

基础GIF(从开始提取5秒)

Extract video segment as animated GIF.
bash
undefined
{baseDir}/video-frames.js gif video.mp4 --output clip.gif

Basic GIF (5 seconds from start)

指定时间与时长

{baseDir}/video-frames.js gif video.mp4 --output clip.gif
{baseDir}/video-frames.js gif video.mp4 --start 00:01:30 --duration 5 --out highlight.gif {baseDir}/video-frames.js gif video.mp4 --start 30 --duration 10 --out segment.gif

Specific time and duration

质量预设

{baseDir}/video-frames.js gif video.mp4 --start 00:01:30 --duration 5 --out highlight.gif {baseDir}/video-frames.js gif video.mp4 --start 30 --duration 10 --out segment.gif
{baseDir}/video-frames.js gif video.mp4 --start 60 --duration 3 --preset fast --out quick.gif {baseDir}/video-frames.js gif video.mp4 --start 60 --duration 3 --preset quality --out smooth.gif {baseDir}/video-frames.js gif video.mp4 --start 60 --duration 3 --preset cinematic --out cinema.gif

Quality presets

自定义参数

{baseDir}/video-frames.js gif video.mp4 --start 60 --duration 3 --preset fast --out quick.gif {baseDir}/video-frames.js gif video.mp4 --start 60 --duration 3 --preset quality --out smooth.gif {baseDir}/video-frames.js gif video.mp4 --start 60 --duration 3 --preset cinematic --out cinema.gif
{baseDir}/video-frames.js gif video.mp4 --start 30 --duration 5 --fps 30 --width 720 --out preview.gif

**GIF预设参数:**
| 预设 | 帧率 | 宽度 | 颜色数 | 文件大小 | 最佳用途 |
|--------|-----|-------|--------|------|----------|
| `fast` | 15 | 480px | 128 | 小 | 快速生成 |
| `balanced` | 20 | 640px | 256 | 中等 | 默认选项 |
| `quality` | 24 | 720px | 512 | 大 | 流畅动效 |
| `cinematic` | 30 | 1080px | 1024 | 极大 | 最高画质 |

**最大限制:** 300帧(30fps下约10秒)

Custom parameters

5. 获取视频信息

{baseDir}/video-frames.js gif video.mp4 --start 30 --duration 5 --fps 30 --width 720 --out preview.gif

**GIF Presets:**
| Preset | FPS | Width | Colors | Size | Best For |
|--------|-----|-------|--------|------|----------|
| `fast` | 15 | 480px | 128 | Small | Quick generation |
| `balanced` | 20 | 640px | 256 | Medium | Default |
| `quality` | 24 | 720px | 512 | Large | Smooth motion |
| `cinematic` | 30 | 1080px | 1024 | Very large | Maximum quality |

**Max Duration:** 300 frames (~10 seconds at 30fps)
显示详细的视频元数据。
bash
{baseDir}/video-frames.js info video.mp4
输出示例:
json
{
  "stats": { "size": 1234567890, "mtime": "..." },
  "duration": 3665,
  "width": 1920,
  "height": 1080,
  "fps": 29.97,
  "totalFrames": 109785,
  "info": { ... }  // 完整ffprobe输出
}

5. Get Video Information

进度追踪

Display detailed video metadata.
bash
{baseDir}/video-frames.js info video.mp4
Output:
json
{
  "stats": { "size": 1234567890, "mtime": "..." },
  "duration": 3665,
  "width": 1920,
  "height": 1080,
  "fps": 29.97,
  "totalFrames": 109785,
  "info": { ... }  // Full ffprobe output
}
操作过程中会显示实时进度:
⏳ 提取帧:15/30 (50.0%) | 已耗时:12.3s
⏳ 生成缩略图:8/12 (66.7%) | 已耗时:5.2s

Progress Tracking

安全特性

限制参数

Operations display real-time progress:
⏳ Extracting frames: 15/30 (50.0%) | Elapsed: 12.3s
⏳ Generating thumbnails: 8/12 (66.7%) | Elapsed: 5.2s
限制项数值说明
最大视频文件大小50 GB输入文件大小限制
最大视频时长4小时视频长度限制
最大批量提取帧数1000批量帧提取上限
最大网格缩略图数量60联络表限制
最大GIF帧数300动画GIF限制
超时时间30分钟默认操作超时时间

Safety Features

视频验证

Limits

LimitValueDescription
Max Video Size50 GBInput file size limit
Max Duration4 hoursVideo length limit
Max Frames1,000Batch frame extraction
Max Grid Size60 thumbnailsContact sheet limit
Max GIF Frames300Animated GIF limit
Timeout30 minutesDefault operation timeout
处理前,工具会自动验证:
  • 文件存在且可读取
  • 文件大小在限制内
  • 视频格式有效
  • 时长在限制内
  • 包含视频流
  • 文件未损坏

Video Validation

错误处理

错误码

Before processing, the skill validates:
  • File exists and is readable
  • File size within limits
  • Valid video format
  • Duration within limits
  • Contains video stream
  • Not corrupted
代码名称说明
0SUCCESS操作完成
1INVALID_INPUT参数缺失或无效
2FILE_NOT_FOUND视频文件未找到
3INVALID_FORMAT不支持的格式
4INVALID_TIME_RANGE时间戳无效
5FFMPEG_ERRORFFmpeg执行失败
6OUT_OF_MEMORY内存超限
7TIMEOUT操作超时
8INTERRUPTED用户中断操作
9PERMISSION_DENIED读写权限不足
10VALIDATION_FAILED视频验证未通过
99UNKNOWN未知错误

Error Handling

常见错误场景

Error Codes

CodeNameDescription
0SUCCESSOperation completed
1INVALID_INPUTMissing/invalid parameters
2FILE_NOT_FOUNDVideo not found
3INVALID_FORMATUnsupported format
4INVALID_TIME_RANGEInvalid timestamp
5FFMPEG_ERRORFFmpeg execution failed
6OUT_OF_MEMORYMemory limit exceeded
7TIMEOUTOperation timed out
8INTERRUPTEDUser interrupted
9PERMISSION_DENIEDCannot read/write
10VALIDATION_FAILEDVideo validation failed
99UNKNOWNUnexpected error
帧索引超出范围:
bash
{baseDir}/video-frames.js frame video.mp4 --index 999999

Common Scenarios

❌ 错误:帧索引999999超出范围(0-109784)

Frame Index Out of Range:
bash
{baseDir}/video-frames.js frame video.mp4 --index 999999

**时间戳超出视频时长:**
```bash
{baseDir}/video-frames.js frame video.mp4 --time 10000

❌ ERROR: Frame index 999999 out of range (0-109784)

❌ 错误:时间戳02:46:40超出范围(0-01:01:05)


**Timestamp Beyond Video:**
```bash
{baseDir}/video-frames.js frame video.mp4 --time 10000

**请求帧数过多:**
```bash
{baseDir}/video-frames.js frames video.mp4 --fps 100

❌ ERROR: Timestamp 02:46:40 out of range (0-01:01:05)

❌ 错误:请求帧数过多:366500(上限:1000)


**Too Many Frames:**
```bash
{baseDir}/video-frames.js frames video.mp4 --fps 100

**GIF请求过长:**
```bash
{baseDir}/video-frames.js gif video.mp4 --duration 60 --fps 60

❌ ERROR: Too many frames requested: 366500 (max: 1000)

❌ 错误:GIF过长:3600帧(上限:300)


**Large GIF Request:**
```bash
{baseDir}/video-frames.js gif video.mp4 --duration 60 --fps 60
undefined

❌ ERROR: GIF too long: 3600 frames (max: 300)

技术细节

帧提取方式

undefined
  1. 片段定位 (
    -ss
    -i
    之前)
    • 快速帧访问
    • 用于
      --time
      选项
    • 开头部分精度略有损失
  2. 帧选择 (
    -vf select
    )
    • 精确按索引提取帧
    • 速度较慢但帧精度高
    • 用于
      --index
      选项
  3. 间隔提取 (
    fps
    过滤器)
    • 高效批量提取
    • 支持帧率转换
    • 用于批量操作

Technical Details

质量设置细节

Frame Extraction Methods

  1. Segment Seek (
    -ss
    before
    -i
    )
    • Fast frame access
    • Use for
      --time
      option
    • Slight accuracy trade-off at start
  2. Frame Selection (
    -vf select
    )
    • Precise frame index extraction
    • Slower but frame-accurate
    • Use for
      --index
      option
  3. Extract at Interval (
    fps
    filter)
    • Efficient batch extraction
    • Frame-rate conversion
    • Use for batch operations
JPEG 质量(CRF - 恒定速率因子):
-q:v 1  -> 100%画质(最佳,文件最大)
-q:v 2  -> ~95%画质(默认)
-q:v 5  -> ~85%画质(网页使用)
-q:v 10 -> ~70%画质(低画质)
-q:v 31 -> ~10%画质(最低)
PNG 输出:
  • 始终无损
  • 文件体积较大
  • 适合归档
  • 支持透明背景
缩放(Lanczos 算法):
-vf scale=320:-2:flags=lanczos
  • Lanczos 重采样算法保证最佳画质
  • -2
    确保尺寸为偶数(编码要求)
  • 保持原视频宽高比

Quality Settings

GIF 优化

JPEG Quality (CRF - Constant Rate Factor):
-q:v 1  -> 100% quality (best, largest)
-q:v 2  -> ~95% quality (default)
-q:v 5  -> ~85% quality (web)
-q:v 10 -> ~70% quality (low)
-q:v 31 -> ~10% quality (minimum)
PNG Output:
  • Always lossless
  • Larger file sizes
  • Best for archival
  • Transparent backgrounds supported
Scaling (Lanczos):
-vf scale=320:-2:flags=lanczos
  • Lanczos resampling for best quality
  • -2
    ensures even dimensions (encoding requirement)
  • Maintains aspect ratio
调色板生成:
  1. 解析视频片段
  2. 生成最优256色调色板
  3. 将调色板应用到所有帧
  4. 抖动处理实现平滑渐变
文件体积优化:
  • 固定帧率
  • 限制颜色数量
  • 编码前调整尺寸
  • 优化编码设置

GIF Optimization

使用示例

视频故事板创建

Palette Generation:
  1. Parse video segment
  2. Generate optimal 256-color palette
  3. Apply palette to all frames
  4. Dithering for smooth gradients
File Size Optimization:
  • Fixed frame rate
  • Limited color palette
  • Resizing before encoding
  • Optimized encoding settings
bash
#!/bin/bash
VIDEO="movie.mp4"
OUTDIR="storyboard"

mkdir -p $OUTDIR

Examples

创建概览网格

Video Storyboard Creation

bash
#!/bin/bash
VIDEO="movie.mp4"
OUTDIR="storyboard"

mkdir -p $OUTDIR
echo "创建概览网格..." {baseDir}/video-frames.js grid "$VIDEO" --count 20 --columns 5 --width 480 --out "$OUTDIR/overview.jpg"

Create overview grid

每分钟提取关键帧

echo "Creating overview grid..." {baseDir}/video-frames.js grid "$VIDEO" --count 20 --columns 5 --width 480 --out "$OUTDIR/overview.jpg"
echo "提取关键帧..." {baseDir}/video-frames.js frames "$VIDEO" --fps 0.0167 --prefix key --out "$OUTDIR/"

Extract key frames every minute

创建章节缩略图

echo "Extracting key frames..." {baseDir}/video-frames.js frames "$VIDEO" --fps 0.0167 --prefix key --out "$OUTDIR/"
echo "创建章节缩略图..." for time in 0:00 10:00 20:00 30:00; do {baseDir}/video-frames.js frame "$VIDEO" --time $time --quality 1 --out "$OUTDIR/chapter_${time//:/}.png" done
echo "故事板已生成在 $OUTDIR/"
undefined

Create chapter thumbnails

视频预览图库

echo "Creating chapter thumbnails..." for time in 0:00 10:00 20:00 30:00; do {baseDir}/video-frames.js frame "$VIDEO" --time $time --quality 1 --out "$OUTDIR/chapter_${time//:/}.png" done
echo "Storyboard complete in $OUTDIR/"
undefined
bash
#!/bin/bash
for video in *.mp4; do
  echo "处理中:$video"
  
  # 创建3x3网格
  {baseDir}/video-frames.js grid "$video" --count 9 --columns 3 --width 640 --out "${video%.*}-grid.jpg"
  
  # 创建5秒预览GIF
  {baseDir}/video-frames.js gif "$video" --start 30 --duration 5 --preset balanced --out "${video%.*}-preview.gif"
  
done

Video Preview Gallery

每N秒提取一帧

bash
#!/bin/bash
for video in *.mp4; do
  echo "Processing: $video"
  
  # Create 3x3 grid
  {baseDir}/video-frames.js grid "$video" --count 9 --columns 3 --width 640 --out "${video%.*}-grid.jpg"
  
  # Create 5-second preview GIF
  {baseDir}/video-frames.js gif "$video" --start 30 --duration 5 --preset balanced --out "${video%.*}-preview.gif"
  
done
bash
undefined

Extract Frames Every N Seconds

每分钟开头提取一帧

bash
undefined
for i in {0..60}; do {baseDir}/video-frames.js frame video.mp4 --time $((i*60)) --out "frames/minute_${i}.jpg" done

Extract frame at beginning of every minute

批量提取的Shell脚本

for i in {0..60}; do {baseDir}/video-frames.js frame video.mp4 --time $((i*60)) --out "frames/minute_${i}.jpg" done
extract_frames() { local video="$1" local interval="${2:-10}" # 默认10秒间隔 local duration duration=$(ffprobe -v error -show_entries format=duration -of csv=p=0 "$video")
for ((t=0; t<duration; t+=interval)); do {baseDir}/video-frames.js frame "$video" --time $t --out "frames/frame_${t}.jpg" done }
undefined

Shell script for batch extraction

高质量缩略图生成

extract_frames() { local video="$1" local interval="${2:-10}" # default 10 seconds local duration duration=$(ffprobe -v error -show_entries format=duration -of csv=p=0 "$video")
for ((t=0; t<duration; t+=interval)); do {baseDir}/video-frames.js frame "$video" --time $t --out "frames/frame_${t}.jpg" done }
undefined
bash
undefined

High-Quality Thumbnail Generation

最佳画质单帧

bash
undefined
{baseDir}/video-frames.js frame video.mp4
--time 10
--format png
--width 1920
--out thumbnail.png

Best quality single frame

最佳画质网格

{baseDir}/video-frames.js frame video.mp4
--time 10
--format png
--width 1920
--out thumbnail.png
{baseDir}/video-frames.js grid video.mp4
--count 9
--columns 3
--width 640
--format png
--out grid.png
undefined

Best quality grid

性能优化建议

1. 使用JPEG提升速度

{baseDir}/video-frames.js grid video.mp4
--count 9
--columns 3
--width 640
--format png
--out grid.png
undefined
JPEG编码比PNG更快:
bash
{baseDir}/video-frames.js frame video.mp4 --format jpg  # 更快
{baseDir}/video-frames.js frame video.mp4 --format png  # 画质更好,但速度慢

Performance Tips

2. 草稿使用低画质

1. Use JPEG for Speed

JPEG encoding is faster than PNG:
bash
{baseDir}/video-frames.js frame video.mp4 --format jpg  # Faster
{baseDir}/video-frames.js frame video.mp4 --format png  # Better quality, slower
bash
undefined

2. Lower Quality for Drafts

快速预览

bash
undefined
{baseDir}/video-frames.js grid video.mp4 --count 9 --width 320 # 文件小,速度快

Quick preview

最终画质

{baseDir}/video-frames.js grid video.mp4 --count 9 --width 320 # Small, fast
{baseDir}/video-frames.js grid video.mp4 --count 16 --width 640 # 细节更丰富
undefined

Final quality

3. 并行处理

{baseDir}/video-frames.js grid video.mp4 --count 16 --width 640 # Higher detail
undefined
bash
undefined

3. Parallel Processing

并行处理多个视频

bash
undefined
{baseDir}/video-frames.js grid video1.mp4 --out g1.jpg & {baseDir}/video-frames.js grid video2.mp4 --out g2.jpg & {baseDir}/video-frames.js grid video3.mp4 --out g3.jpg & wait
undefined

Process multiple videos in parallel

4. 提取时调整尺寸

{baseDir}/video-frames.js grid video1.mp4 --out g1.jpg & {baseDir}/video-frames.js grid video2.mp4 --out g2.jpg & {baseDir}/video-frames.js grid video3.mp4 --out g3.jpg & wait
undefined
比提取全尺寸后再缩放更高效:
bash
undefined

4. Resize During Extraction

推荐方式

Better than extracting full size then scaling:
bash
undefined
{baseDir}/video-frames.js frame video.mp4 --width 320 --out thumb.jpg

Good

低效方式

{baseDir}/video-frames.js frame video.mp4 --width 320 --out thumb.jpg
{baseDir}/video-frames.js frame video.mp4 --out full.jpg

Less efficient

再通过外部工具缩放

{baseDir}/video-frames.js frame video.mp4 --out full.jpg
undefined

Then resize externally

注意事项

undefined
  • 当ImageMagick可用时,网格生成会使用它(画质更好),否则使用FFmpeg的tile过滤器
  • 帧索引0始终是视频的第一帧
  • 时间戳会根据视频FPS四舍五入到最近的帧
  • GIF使用256色调色板平衡画质与文件大小
  • PNG透明背景会被保留(适合叠加使用)
  • 所有操作会自动清理临时文件
  • JSON输出支持程序化集成
  • 网格缩略图会按视频时间间隔分布

Notes

  • Grid generation uses ImageMagick when available (better quality), FFmpeg tile filter otherwise
  • Frame index 0 is always the first frame of the video
  • Timestamps are rounded to nearest frame based on video FPS
  • GIFs are optimized with 256-color palette for balance of quality and size
  • PNG transparency is preserved (useful for overlays)
  • All operations clean up temporary files automatically
  • JSON output enables programmatic integration
  • Grid thumbnails include timestamps at video intervals