跳到正文
Skillpedia
视频剪辑7.8k · #12885

ffmpeg-encoder-check-4855c0

它能做什么

这项技能告诉 AI 在编码视频之前,先检查 FFmpeg 可用的编码器。它适合处理视频、并遇到过编解码器或库错误的人。

适用场景

  • ✓当我即将编写一个把视频编码为 H.264 的 FFmpeg 脚本的时候。
  • ✓当 FFmpeg 编码因缺少编码器或编码器不兼容而失败的时候。
  • ✓当源视频无需重新编码即可直接复制的时候。

技能链接

https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/ffmpeg-encoder-check-4855c0/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/ffmpeg-encoder-check-4855c0/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“请用 FFmpeg 把这段视频编码为 H.264。先检查这台电脑有哪些编码器,并选一个能用的。”

每周 5 个新技能,1 分钟读完。

工作原理

AI 会列出 H.264 编码器;当格式已经匹配时,优先使用直接流复制;存在 libx264 时就使用它;并在完整任务前用一段短片进行测试。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

FFmpeg Encoder Availability Check

Purpose

Before writing any FFmpeg encoding script, always probe the system for available encoders. This prevents failures from missing or incompatible codec libraries (especially libopenh264 which frequently has version mismatches).

Core Pattern

Step 1: Probe Available Encoders

Always run this command before deciding on encoding parameters:

ffmpeg -encoders | grep h264

This shows which H.264 encoders are available on the system.

Step 2: Choose Encoder Based on Availability

Priority order for H.264 encoding:

  1. -c:v copy - If source and target resolution/format match, copy the stream without re-encoding (fastest, no quality loss)

  2. -c:v libx264 - If available, this is the most reliable and widely-compatible H.264 encoder

  3. -c:v h264 - Hardware acceleration if available (varies by system)

  4. Avoid libopenh264 - This encoder frequently has library version mismatches causing runtime failures

Step 3: Verify Before Execution

After choosing an encoder, verify it works with a short test:

ffmpeg -t 5 -i input.mp4 -c:v libx264 -preset fast -crf 23 -c:a copy test_output.mp4

Example Decision Flow

#!/bin/bash

# Check available encoders
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 "h264"; then
    VIDEO_CODEC="h264"
    echo "Using h264 encoder"
else
    VIDEO_CODEC="copy"
    echo "No H.264 encoder available, using stream copy"
fi

# Use $VIDEO_CODEC in your ffmpeg command
ffmpeg -i input.mp4 -c:v $VIDEO_CODEC output.mp4

When to Use Stream Copy

Use -c:v copy when:

  • Source and target resolution are identical
  • Source codec is already H.264
  • You only need to change container format or audio
  • Speed is critical and re-encoding is unnecessary

Common Pitfalls

  • Don't assume encoder availability - Different systems have different FFmpeg builds
  • Don't hardcode libopenh264 - High failure rate due to library mismatches
  • Always test encoding - Run a short segment test before processing full files
  • Check both video and audio codecs - Audio encoder availability matters too
常见问题

首选哪个编码器?

指南首选直接流复制,其次是 libx264,并建议避免使用 libopenh264。

为什么要用短片测试?

五秒钟的测试可以在处理完整视频之前,显示编码器是否可用。

什么是流复制?

它直接复制视频而不重新编码,因此没有画质损失。

详情

作者的原始描述

Check available FFmpeg encoders before writing encoding scripts to avoid library version mismatches

repo: HKUDS/AgentPilot

热度

GitHub 星标
7.8k
排名
#12885
许可证
MIT
更新时间
2026/11/1

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能