Communitygithub.com

视频比较器

该技能用于比较两个视频以分析压缩结果或质量差异。生成包含质量指标(PSNR、SSIM)和逐帧可视化对比的交互式 HTML 报告。

视频比较器 是什么?

此 AI 技能用于比较原始视频与压缩视频,生成包含详细质量指标和可视化对比的自包含 HTML 报告。它利用 FFmpeg/FFprobe 提取视频元数据并逐帧抓取,计算 PSNR(峰值信噪比)和 SSIM(结构相似性)两个标准质量指标,并以滑块、并排和网格三种模式进行可视化比较。该技能适用于 macOS、Ubuntu/Debian 和 Windows 平台,需要 Python 3.8+ 及 FFmpeg。其自动验证文件、依赖和路径安全性,并对帧数不匹配、文件过大等常见错误提供清晰提示。生成的 HTML 报告无需服务器即可离线使用,包含缩放控制,便于深入分析压缩效率、编解码器性能和比特率降低的影响。

兼容平台✓Claude Code~Codex CLI~Cursor
npx skills add https://github.com/IGTA-Tech/claude-skills-research/tree/HEAD/claude-code-skills/video-comparer

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

视频比较器 是做什么的?

概述

比较两个视频并生成一个交互式 HTML 报告,分析压缩结果。脚本提取视频元数据,计算质量指标(PSNR、SSIM),并创建三种视图模式(滑块、并排、网格)的逐帧可视化比较。

何时使用此技能

在以下情况下使用此技能:

  • 比较原始视频和压缩视频
  • 分析视频压缩质量和效率
  • 评估编解码器性能或比特率降低的影响
  • 用户提及“比较视频”、“视频质量”、“压缩分析”或“压缩前后”

核心用法

基本命令

python3 scripts/compare.py original.mp4 compressed.mp4

生成 comparison.html,包含:

  • 视频参数(编解码器、分辨率、比特率、时长、文件大小)
  • 质量指标(PSNR、SSIM、大小/比特率降低百分比)
  • 逐帧比较(默认:每 5 秒一帧)

命令选项

# 自定义输出文件
python3 scripts/compare.py original.mp4 compressed.mp4 -o report.html

# 自定义帧间隔(值越大,帧越少,处理越快)
python3 scripts/compare.py original.mp4 compressed.mp4 --interval 10

# 批量比较
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

要求

系统依赖

FFmpeg 和 FFprobe(用于视频分析和帧提取):

# macOS
brew install ffmpeg

# Ubuntu/Debian
sudo apt update && sudo apt install ffmpeg

# Windows
# 从 https://ffmpeg.org/download.html 下载
# 或使用:winget install ffmpeg

Python 3.8+(使用类型提示、f-string、pathlib)

视频规格

  • 支持的格式: .mp4(推荐)、.mov、.avi、.mkv、.webm
  • 文件大小限制: 每个视频 500MB(可配置)
  • 处理时间: 典型视频约 1-2 分钟;根据时长和帧间隔而变化

脚本行为

自动验证

脚本自动验证:

  • FFmpeg/FFprobe 的安装和可用性
  • 文件是否存在、扩展名和大小限制
  • 路径安全性(防止目录遍历)

验证失败时,会显示清晰的错误信息并提供解决指导。

质量指标

脚本计算两个标准质量指标:

PSNR(峰值信噪比): 逐像素相似性测量(20-50 dB 范围,值越高越好)

SSIM(结构相似性指数): 感知相似性测量(0.0-1.0 范围,值越高越好)

有关详细的解释范围和质量阈值,请参考 references/video_metrics.md。

帧提取

脚本按指定间隔(默认:5 秒)提取帧,将其缩放为一致高度(800px)以便比较,并以 base64 数据 URL 的形式嵌入到自包含的 HTML 中。处理完成后,临时文件会自动清理。

输出报告

生成的 HTML 报告包括:

  • 滑块模式: 拖动以显示原始 vs 压缩(默认)
  • 并排模式: 同时显示以进行直接比较
  • 网格模式: 紧凑的 2 列布局
  • 缩放控制: 50%-200% 放大
  • 自包含格式(无需服务器,可离线工作)

重要实施细节

安全性

脚本实现了:

  • 路径验证(绝对路径,防止目录遍历)
  • 命令注入防范(无 shell=True,参数已验证)
  • 资源限制(文件大小、超时)
  • 自定义异常:ValidationError、FFmpegError、VideoComparisonError

常见错误场景

“FFmpeg not found”:通过平台包管理器安装 FFmpeg(参见要求部分)

“File too large”:先压缩视频再进行比较,或在 scripts/compare.py 中调整 MAX_FILE_SIZE_MB

“Operation timed out”:增加 FFMPEG_TIMEOUT 常量或使用更大的 --interval 值(处理的帧更少)

“Frame count mismatch”:视频时长/帧率不同;脚本自动截断到最小帧数并显示警告

配置

脚本包含可调整的常量,用于文件大小限制、超时、帧尺寸和提取间隔。要自定义行为,请编辑 scripts/compare.py 顶部的常量。有关详细的配置选项及其影响,请参考 references/configuration.md。

参考资料

有关详细信息,请查阅以下文件:

  • references/video_metrics.md:质量指标解释(PSNR/SSIM 范围、压缩目标、比特率指南)
  • references/ffmpeg_commands.md:FFmpeg 命令参考(元数据提取、帧提取、故障排除)
  • references/configuration.md:脚本配置选项和可调整常量
  • assets/template.html:用于自定义视图模式和样式的 HTML 报告模板

Individual skills in this repo

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

IGTA-Tech/claude-skills-research

Use when localizing apps, using String Catalogs, generating type-safe symbols (Xcode 26+), handling plurals, RTL layouts, locale-aware formatting, or migrating from .strings files - comprehensive i18n patterns for Xcode 15-26

IGTA-Tech/claude-skills-research

Use when implementing SwiftUI animations, understanding VectorArithmetic, using @Animatable macro, choosing between spring and timing curve animations, or debugging animation behavior - comprehensive animation reference from iOS 13 through iOS 26

IGTA-Tech/claude-skills-research

Use when CAAnimation completion handler doesn't fire, spring physics look wrong on device, animation duration mismatches actual time, gesture + animation interaction causes jank, or timing differs between simulator and real hardware - systematic CAAnimation diagnosis with CATransaction patterns, frame rate awareness, and device-specific behavior

IGTA-Tech/claude-skills-research

Download YouTube videos and HLS streams (m3u8) from platforms like Mux, Vimeo, etc. using yt-dlp and ffmpeg. Use this skill when users request downloading videos, extracting audio, handling protected streams with authentication headers, or troubleshooting download issues like nsig extraction failures, 403 errors, or cookie extraction problems.

IGTA-Tech/claude-skills-research

Write high-converting landing page copy using proven frameworks like PAS (Problem-Agitate-Solution), AIDA, and StoryBrand. Creates headlines, value propositions, CTAs, and full page sections optimized for conversion. Use when users need landing page copy, sales page content, or marketing website text.

IGTA-Tech/claude-skills-research

Downloads videos from YouTube and other platforms for offline viewing, editing, or archival. Handles various formats and quality options.

IGTA-Tech/claude-skills-research

Download YouTube video transcripts when user provides a YouTube URL or asks to download/get/fetch a transcript from YouTube. Also use when user wants to transcribe or get captions/subtitles from a YouTube video.

相关技能