ffmpeg-encoder-check-4855c0
Check available FFmpeg encoders before writing encoding scripts to avoid library version mismatches
- License 许可
- MIT
- 所属仓库
- HKUDS/AgentPilot
- 最近更新
- 2026-11-12
- Stars
- ★ 8.0k
- Forks
- 941
01 前言 Front Matter
- name
- ffmpeg-encoder-check-4855c0
- description
- Check available FFmpeg encoders before writing encoding scripts to avoid library version mismatches
02 资源文件 1
- 其他.skill_id41 B
03 SKILL.md 正文
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:
-
-c:v copy- If source and target resolution/format match, copy the stream without re-encoding (fastest, no quality loss) -
-c:v libx264- If available, this is the most reliable and widely-compatible H.264 encoder -
-c:v h264- Hardware acceleration if available (varies by system) -
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
04 同仓库更多 Skills
agentpilot
Set up AgentPilot and use its single entry to prepare missing inputs and run configured RSI experiments. Use when the user requests AgentPilot installation or work with AgentPilot.
remember
Review auto-memory entries and propose promotions to OPENSPACE.md, OPENSPACE.local.md, or retained auto-memory topics; detect duplicates, stale facts, conflicts, and ambiguous entries before making changes.
skill-discovery
Search reusable OpenSpace skills locally, and browse cloud packages step by step when a cloud skill may help. Reusing proven skills saves tokens, improves reliability, and extends your capabilities beyond built-in tools.
delegate-task
Delegate tasks to OpenSpace — a full-stack autonomous worker for coding, DevOps, web research, and desktop automation, backed by an extensive MCP tool and skill library. Skills auto-improve through use, reducing token consumption over time. A cloud community lets agents share and collectively evolve reusable skills.
write-special-chars-ts-check
Workaround for write_file failures caused by special characters (apostrophes, backticks, template literals) using a Python heredoc script, plus a reliable TypeScript type-checking step that filters output to only the newly-written files to avoid being misled by pre-existing errors.
write-special-chars-readback
Workaround for write_file failures caused by special characters (apostrophes, backticks, template literals) using a Python heredoc script, with mandatory post-write verification via read_file and cleanup of /tmp helper scripts.