ffmpeg-encoder-check
Check FFmpeg encoder availability before video encoding to avoid library mismatches
- License 许可
- MIT
- 所属仓库
- HKUDS/AgentPilot
- 最近更新
- 2026-11-12
- Stars
- ★ 8.0k
- Forks
- 944
01 前言 Front Matter
- name
- ffmpeg-encoder-check
- description
- Check FFmpeg encoder availability before video encoding to avoid library mismatches
02 资源文件 1
- 其他.skill_id34 B
03 SKILL.md 正文
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
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.