ffmpeg-encoder-check
它能做什么
这项技能展示如何列出 FFmpeg 的 H.264 编码器,并为电脑选择最合适的一个。它适合需要编码视频、并想避免编解码器问题的人。
适用场景
- ✓当我需要用 FFmpeg 转换或编码视频的时候。
- ✓当视频任务因库版本不匹配而失败的时候。
- ✓当我的源视频已符合想要的格式,无需重新编码的时候。
技能链接
https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/ffmpeg-encoder-check/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请用 FFmpeg 转换我的视频。先检查已安装哪些 H.264 编码器,这样任务就不会失败。”
每周 5 个新技能,1 分钟读完。
工作原理
AI 会列出系统中的编码器,与一份选项表进行对照,然后选择流复制、libx264、硬件编码器或其他可用选项。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
FFmpeg Encoder Availability Check
Purpose
Before writing video encoding scripts, always verify which H.264 encoders are available in your FFmpeg installation. This prevents failures from library version mismatches, particularly with libopenh264.
Instructions
Step 1: Probe Available Encoders
Run the following command to check available H.264 encoders:
ffmpeg -encoders 2>/dev/null | grep h264
This shows which H.264 encoders are compiled into your FFmpeg build.
Step 2: Interpret Results
Common encoder options you may see:
| Encoder | Description | Recommendation |
|---|---|---|
libx264 |
Software H.264 encoder | Preferred - widely compatible |
libopenh264 |
OpenH264 software encoder | Use with caution - often has library version mismatches |
h264_nvenc |
NVIDIA hardware encoder | Good if NVIDIA GPU available |
h264_videotoolbox |
macOS hardware encoder | Good on macOS |
h264_vaapi |
Intel VAAPI hardware encoder | Good on Linux with Intel GPU |
h264_qsv |
Intel QuickSync encoder | Good on Windows/Linux with Intel GPU |
Step 3: Choose Encoding Strategy
For same-resolution sources (no re-encoding needed):
# Best option - pass-through without quality loss
ffmpeg -i input.mp4 -c:v copy -c:a copy output.mp4
If libx264 is available:
# Reliable software encoding
ffmpeg -i input.mp4 -c:v libx264 -preset medium -crf 23 -c:a aac output.mp4
If only libopenh264 is available:
# Use with caution - may have library issues
ffmpeg -i input.mp4 -c:v libopenh264 -c:a aac output.mp4
Step 4: Validate Before Batch Processing
Always test your encoding command on a small sample file before processing multiple videos or long footage.
Best Practices
- Default to
-c:v copywhen source and target resolutions match - no quality loss, fastest processing - Prefer libx264 over libopenh264 for software encoding - more stable, better compatibility
- Check encoder availability at script startup, not during execution - fail fast with clear error
- Cache encoder check results if running multiple encoding operations in the same session
- Provide fallback options in automated scripts - try copy first, then libx264, then fail gracefully
Example Script Template
#!/bin/bash
# Check available encoders at startup
ENCODERS=$(ffmpeg -encoders 2>/dev/null | grep h264)
if echo "$ENCODERS" | grep -q "libx264"; then
VIDEO_CODEC="libx264"
echo "Using libx264 encoder"
elif echo "$ENCODERS" | grep -q "libopenh264"; then
VIDEO_CODEC="libopenh264"
echo "Warning: Using libopenh264 (may have compatibility issues)"
else
echo "Error: No H.264 encoder available"
echo "Available encoders:"
echo "$ENCODERS"
exit 1
fi
# For same-resolution sources, prefer copy
if [ "$SOURCE_RESOLUTION" = "$TARGET_RESOLUTION" ]; then
VIDEO_CODEC="copy"
echo "Same resolution detected - using stream copy"
fi
# Encode
ffmpeg -i "$INPUT" -c:v "$VIDEO_CODEC" -c:a aac "$OUTPUT"
Common Errors to Avoid
- Do not assume libx264 is available - FFmpeg builds vary by system
- Do not use libopenh264 without checking - frequent library version mismatch errors
- Do not re-encode unnecessarily - use
-c:v copywhen resolution matches - Do not skip the encoder check - always probe before writing encoding logic
常见问题
哪个编码器兼容性最广?
指南说 libx264 是首选,且兼容性广。
硬件编码器依赖什么?
它们依赖电脑中的显卡硬件,例如 NVIDIA、Apple 或 Intel 的芯片。
为什么要避免 libopenh264?
指南说它常常存在库版本不匹配的问题。
详情
作者的原始描述
Check FFmpeg encoder availability before video encoding to avoid library mismatches
repo: HKUDS/AgentPilot
热度
- GitHub 星标
- 7.8k
- 排名
- #12886
- 许可证
- MIT
- 更新时间
- 2026/11/1
评论
- …
同一仓库的更多技能
agentpilot
7.8k帮你的智能体准备任务并运行 AgentPilot 循环,逐步改进项目:循环会提出修改、测试修改并为其打分。
openspace
7.8k帮你的智能体设置 OpenSpace,这是一个用于存储和获取智能体技能的工具,并通过 MCP 将其连接到你的 AI 应用。
rsi-arena
7.8k帮你的智能体设置并运行标准 AI 基准测试,例如 AIME 和 Terminal-Bench,用来比较不同的改进方法。
experiment-guide
7.8k帮你的智能体规划小型实验、阅读实验结果并记录发现,同时研究如何改进一个程序。