ffmpeg-graceful-degradation
하는 일
이 스킬은 FFmpeg 인코딩의 대체 계획을 설명합니다. 인코더 확인부터 다른 방법 시도까지 이어집니다. 인코딩 오류 때문에 작업이 자주 멈추는 많은 비디오를 처리하는 사람에게 맞습니다.
사용하는 경우
- ✓코덱 누락이나 라이브러리 오류 때문에 FFmpeg 인코딩이 실패할 때.
- ✓비디오 묶음을 처리해야 하는데 전체 묶음이 실패하지 않게 하고 싶을 때.
- ✓전체 실행 전에 짧은 테스트 클립을 확인하고 싶은 경우.
스킬 링크
https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/ffmpeg-graceful-degradation/SKILL.md복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.
사용 방법
가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
AI에게 요청하는 예시
“FFmpeg 인코딩이 클립 묶음에서 계속 실패합니다. 짧은 클립으로 먼저 테스트하고 끝까지 처리되는 방법을 찾아 주세요.”
매주 새 스킬 5개. 읽는 데 1분.
작동 방식
AI는 사용 가능한 인코더를 점검하고 짧은 테스트를 실행한 뒤, 스트림 복사에서 다른 코덱, 마지막으로 moviepy까지 대체 목록을 따라 내려가며 묶음을 처리합니다.
기술 내용 (원본 SKILL.md)
작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.
FFmpeg Graceful Degradation
When processing videos with ffmpeg, encoding failures are common due to codec availability, library version mismatches, or system configuration issues. This skill provides a systematic fallback strategy to ensure video processing completes successfully.
Overview
The pattern involves: (1) probing encoder availability upfront, (2) testing on a short clip before batch processing, (3) progressive fallback through copy mode, alternative codecs, and finally moviepy, (4) using moviepy as a reliable bundled alternative.
Step 1: Probe Encoder Availability
Before any encoding work, check what encoders are available:
ffmpeg -encoders | grep -E "libx264|libopenh264|mpeg4"
Expected output shows which encoders are present:
libx264- Preferred H.264 encoder (may be missing)libopenh264- Alternative H.264 (often has library issues)mpeg4- Universal fallback (always available)
Step 2: Test Encoding on Single Short Clip
Never start batch processing without validation. Extract and test a short segment:
# Extract 5-second test clip
ffmpeg -y -i input.mp4 -ss 0 -t 5 -c copy test_clip.mp4
# Attempt encode with preferred codec
ffmpeg -y -i test_clip.mp4 -c:v libx264 -preset fast test_output.mp4
Check the exit code and output for errors. Common failures:
libopenh264.so: wrong ELF classEncoder libx264 not found- Library version mismatches
Step 3: Progressive Fallback Strategy
If the preferred encoder fails, try these fallbacks in order:
Fallback A: Copy Mode (No Re-encoding)
ffmpeg -y -i input.mp4 -c:v copy -c:a copy output.mp4
Fast, lossless, but doesn't change codec/format.
Fallback B: MPEG4 Codec
ffmpeg -y -i input.mp4 -c:v mpeg4 -q:v 3 -c:a copy output.mp4
Universal compatibility, larger file sizes, always available.
Fallback C: Install MoviePy (Bundles Working FFmpeg)
pip install moviepy
Then use Python instead of raw ffmpeg:
from moviepy.editor import VideoFileClip, concatenate_videoclips
# Single clip processing
clip = VideoFileClip("input.mp4")
clip.write_videofile("output.mp4", codec="libx264")
# Concatenate multiple clips
clips = [VideoFileClip(f) for f in clip_files]
final = concatenate_videoclips(clips)
final.write_videofile("output.mp4", codec="libx264")
MoviePy bundles its own ffmpeg binary, avoiding system library issues.
Step 4: Implementation Pattern
Here's a complete graceful degradation workflow:
import subprocess
import os
def safe_video_encode(input_path, output_path, clips=None):
"""
Encode video with graceful degradation fallbacks.
Args:
input_path: Single input file path, or
clips: List of clip paths for concatenation
Returns:
True if successful, False otherwise
"""
# Step 1: Check encoder availability
result = subprocess.run(
["ffmpeg", "-encoders"],
capture_output=True, text=True
)
has_libx264 = "libx264" in result.stdout
has_mpeg4 = "mpeg4" in result.stdout
# Step 2: If concatenating, prepare clips with moviepy
if clips:
try:
from moviepy.editor import VideoFileClip, concatenate_videoclips
loaded_clips = [VideoFileClip(c) for c in clips]
final = concatenate_videoclips(loaded_clips)
final.write_videofile(output_path, codec="libx264", logger=None)
return True
except Exception as e:
print(f"MoviePy failed: {e}")
# Step 3: Try ffmpeg with progressive fallbacks
encoders_to_try = []
if has_libx264:
encoders_to_try.append("libx264")
encoders_to_try.append("mpeg4") # Always available
for codec in encoders_to_try:
cmd = [
"ffmpeg", "-y",
"-i", input_path,
"-c:v", codec,
"-c:a", "copy",
output_path
]
result = subprocess.run(cmd, capture_output=True, text=True)
if result.returncode == 0:
return True
# Step 4: Last resort - copy mode
cmd = ["ffmpeg", "-y", "-i", input_path, "-c", "copy", output_path]
result = subprocess.run(cmd, capture_output=True, text=True)
return result.returncode == 0
Decision Flow
Start
│
▼
Check encoders (ffmpeg -encoders)
│
├─ libx264 available? ──Yes──► Try libx264
│ │ │
│ No └─►
자주 묻는 질문
moviepy는 무엇인가요?
비디오 편집용 Python 라이브러리로, 가이드가 대체 수단으로 사용합니다.
테스트 클립을 먼저 쓰는 이유는 무엇인가요?
짧은 테스트로 전체 묶음을 처리하기 전에 코덱 문제를 발견할 수 있습니다.
어떤 오류가 흔한가요?
libopenh264의 잘못된 ELF 클래스나 인코더를 찾을 수 없음 같은 오류를 가이드가 나열합니다.
상세 정보
작성자의 원본 설명
Graceful degradation workflow for ffmpeg encoding failures with progressive fallback strategies
repo: HKUDS/AgentPilot
인기도
- GitHub 스타
- 7.8k
- 순위
- #12887
- 라이선스
- MIT
- 업데이트
- 2026. 11. 1.
댓글
- …
이 저장소의 다른 스킬
agentpilot
7.8k작업을 준비하고 AgentPilot 루프를 실행해 변경을 제안, 테스트, 점수화하면서 프로젝트를 단계적으로 개선하도록 돕습니다.
openspace
7.8k에이전트 스킬을 저장하고 가져오는 도구인 OpenSpace를 설정하고, MCP를 통해 AI 앱에 연결하도록 돕습니다.
rsi-arena
7.8kAIME나 Terminal-Bench 같은 표준 AI 벤치마크 테스트를 설정하고 실행해 서로 다른 개선 방법을 비교하도록 돕습니다.
experiment-guide
7.8k프로그램을 개선하는 방법을 조사하면서 작은 실험을 계획하고, 결과를 읽고, 발견 사항을 기록하도록 돕습니다.
비슷한 스킬
taste-application
280k특정 스타일의 영상을 에이전트가 만들도록 돕습니다. 참고 영상의 편집 리듬을 살려 새 장면과 색을 더하고 영상을 편집합니다.
taste-distillation
280k영상을 분석해 스타일 팩을 만들도록 에이전트를 돕습니다. 색, 컷 리듬, 시각 요소를 포함하며 같은 느낌의 새 영상을 만드는 데 재사용할 수 있습니다.
ui-demo
280k에이전트가 완성도 높은 UI 데모 영상을 녹화하도록 돕습니다. 튜토리얼을 만들거나 웹 앱의 작동 방식을 보여 줄 때 유용합니다.