画质比对
video-comparer
by daymade
对比原始与压缩后视频,自动提取编码、分辨率、码率等参数,计算 PSNR、SSIM,并生成可交互 HTML 报告,用逐帧滑块、并排和网格视图分析压缩质量差异。
做压缩前后视频质检很省心,自动生成含 PSNR/SSIM 与逐帧对比的交互报告,定位画质差异特别直观。
安装
claude skill add --url github.com/daymade/claude-code-skills/tree/main/video-comparer文档
Video Comparer
Overview
Compare two videos and generate an interactive HTML report analyzing compression results. The script extracts video metadata, calculates quality metrics (PSNR, SSIM), and creates frame-by-frame visual comparisons with three viewing modes: slider, side-by-side, and grid.
When to Use This Skill
Use this skill when:
- Comparing original and compressed videos
- Analyzing video compression quality and efficiency
- Evaluating codec performance or bitrate reduction impact
- Users mention "compare videos", "video quality", "compression analysis", or "before/after compression"
Core Usage
Basic Command
python3 scripts/compare.py original.mp4 compressed.mp4
Generates comparison.html with:
- Video parameters (codec, resolution, bitrate, duration, file size)
- Quality metrics (PSNR, SSIM, size/bitrate reduction percentages)
- Frame-by-frame comparison (default: frames at 5s intervals)
Command Options
# Custom output file
python3 scripts/compare.py original.mp4 compressed.mp4 -o report.html
# Custom frame interval (larger = fewer frames, faster processing)
python3 scripts/compare.py original.mp4 compressed.mp4 --interval 10
# Batch comparison
for original in originals/*.mp4; do
compressed="compressed/$(basename "$original")"
output="reports/$(basename "$original" .mp4).html"
python3 scripts/compare.py "$original" "$compressed" -o "$output"
done
Requirements
System Dependencies
FFmpeg and FFprobe (required for video analysis and frame extraction):
# macOS
brew install ffmpeg
# Ubuntu/Debian
sudo apt update && sudo apt install ffmpeg
# Windows
# Download from https://ffmpeg.org/download.html
# Or use: winget install ffmpeg
Python 3.8+ (uses type hints, f-strings, pathlib)
Video Specifications
- Supported formats:
.mp4(recommended),.mov,.avi,.mkv,.webm - File size limit: 500MB per video (configurable)
- Processing time: ~1-2 minutes for typical videos; varies by duration and frame interval
Script Behavior
Automatic Validation
The script automatically validates:
- FFmpeg/FFprobe installation and availability
- File existence, extensions, and size limits
- Path security (prevents directory traversal)
Clear error messages with resolution guidance appear when validation fails.
Quality Metrics
The script calculates two standard quality metrics:
PSNR (Peak Signal-to-Noise Ratio): Pixel-level similarity measurement (20-50 dB scale, higher is better)
SSIM (Structural Similarity Index): Perceptual similarity measurement (0.0-1.0 scale, higher is better)
For detailed interpretation scales and quality thresholds, consult references/video_metrics.md.
Frame Extraction
The script extracts frames at specified intervals (default: 5 seconds), scales them to consistent height (800px) for comparison, and embeds them as base64 data URLs in self-contained HTML. Temporary files are automatically cleaned after processing.
Output Report
The generated HTML report includes:
- Slider Mode: Drag to reveal original vs compressed (default)
- Side-by-Side Mode: Simultaneous display for direct comparison
- Grid Mode: Compact 2-column layout
- Zoom Controls: 50%-200% magnification
- Self-contained format (no server required, works offline)
Important Implementation Details
Security
The script implements:
- Path validation (absolute paths, prevents directory traversal)
- Command injection prevention (no
shell=True, validated arguments) - Resource limits (file size, timeouts)
- Custom exceptions:
ValidationError,FFmpegError,VideoComparisonError
Common Error Scenarios
"FFmpeg not found": Install FFmpeg via platform package manager (see Requirements section)
"File too large": Compress videos before comparison, or adjust MAX_FILE_SIZE_MB in scripts/compare.py
"Operation timed out": Increase FFMPEG_TIMEOUT constant or use larger --interval value (processes fewer frames)
"Frame count mismatch": Videos have different durations/frame rates; script auto-truncates to minimum frame count and shows warning
Configuration
The script includes adjustable constants for file size limits, timeouts, frame dimensions, and extraction intervals. To customize behavior, edit the constants at the top of scripts/compare.py. For detailed configuration options and their impacts, consult references/configuration.md.
Reference Materials
Consult these files for detailed information:
references/video_metrics.md: Quality metrics interpretation (PSNR/SSIM scales, compression targets, bitrate guidelines)references/ffmpeg_commands.md: FFmpeg command reference (metadata extraction, frame extraction, troubleshooting)references/configuration.md: Script configuration options and adjustable constantsassets/template.html: HTML report template for customizing viewing modes and styling
相关 Skills
资深数据工程师
by alirezarezvani
聚焦生产级数据工程,覆盖 ETL/ELT、批处理与流式管道、数据建模、Airflow/dbt/Spark 优化和数据质量治理,适合设计数据架构、搭建现代数据栈与排查性能问题。
✎ 复杂数据管道、ETL/ELT 和治理难题交给它,凭 Spark、Airflow、dbt 等现代数据栈经验,能更稳地搭起可扩展的数据基础设施。
技术栈评估
by alirezarezvani
对比框架、数据库和云服务,结合 5 年 TCO、安全风险、生态活力与迁移复杂度做量化评估,适合技术选型、栈升级和替换路线决策。
✎ 帮你系统比较技术栈优劣,不只看功能,还把TCO、安全性和生态健康度一起量化,选型和迁移决策更稳。
迁移架构师
by alirezarezvani
为数据库、API 与基础设施迁移制定分阶段零停机方案,提前校验兼容性与风险,生成回滚策略、验证关卡和时间线,适合复杂系统平滑切换。
✎ 做数据库与存储迁移时,用它统一梳理表结构和数据搬迁流程,架构视角更完整,复杂迁移也更稳。
相关 MCP 服务
SQLite 数据库
编辑精选by Anthropic
SQLite 是让 AI 直接查询本地数据库进行数据分析的 MCP 服务器。
✎ 这个服务器解决了 AI 无法直接访问 SQLite 数据库的问题,适合需要快速分析本地数据集的开发者。不过,作为参考实现,它可能缺乏生产级的安全特性,建议在受控环境中使用。
PostgreSQL 数据库
编辑精选by Anthropic
PostgreSQL 是让 Claude 直接查询和管理你的数据库的 MCP 服务器。
✎ 这个服务器解决了开发者需要手动编写 SQL 查询的痛点,特别适合数据分析师或后端开发者快速探索数据库结构。不过,由于是参考实现,生产环境使用前务必评估安全风险,别指望它能处理复杂事务。
Firecrawl 智能爬虫
编辑精选by Firecrawl
Firecrawl 是让 AI 直接抓取网页并提取结构化数据的 MCP 服务器。
✎ 它解决了手动写爬虫的麻烦,让 Claude 能直接访问动态网页内容。最适合需要实时数据的研究者或开发者,比如监控竞品价格或抓取新闻。但要注意,它依赖第三方 API,可能涉及隐私和成本问题。