ffmpeg-graceful-degradation
यह क्या करती है
यह स्किल FFmpeg से वीडियो एन्कोडिंग की फ़ॉलबैक योजना बताती है, एन्कोडर जाँचने से लेकर दूसरे विकल्पों तक। यह उन लोगों के लिए है जो कई वीडियो प्रोसेस करते हैं और एन्कोडिंग एरर से पूरा बैच रुक जाता है।
कब इस्तेमाल करें
- ✓जब कोडेक या लाइब्रेरी एरर की वजह से FFmpeg एन्कोडिंग विफल हो।
- ✓जब मुझे वीडियो का बैच प्रोसेस करना है और पूरा बैच विफल नहीं होना चाहिए।
- ✓जब मैं चाहता हूँ कि पूरा काम शुरू होने से पहले एक छोटा टेस्ट क्लिप जाँचा जाए।
Skill का लिंक
https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/ffmpeg-graceful-degradation/SKILL.mdइसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।
कैसे इस्तेमाल करें
सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।
पेस्ट करने के लिए तैयार मैसेज
Claude Code, Codex या Cursor के लिए: प्रोजेक्ट फ़ोल्डर में चलाएँ और skill इंस्टॉल हो जाएगी।
SKILL.md डाउनलोड करें और अपने एजेंट के skills फ़ोल्डर में रखें।
AI से क्या माँगें: उदाहरण
“FFmpeg एन्कोड क्लिपों के बैच पर बार-बार विफल हो रहा है। कृपया पहले एक छोटी क्लिप परखिए और ऐसा तरीका खोजिए जो पूरा हो जाए।”
हर हफ़्ते 5 नई skills, 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
- अपडेट की गई
- 1/11/2026
कमेंट
- …
इस repository की और skills
agentpilot
7.8kआपके एजेंट को AgentPilot से प्रोजेक्ट को चरण-दर-चरण सुधारने में मदद करती है, जिसमें बदलाव सुझाए, परखे और स्कोर किए जाते हैं।
openspace
7.8kआपके एजेंट को OpenSpace सेट करने में मदद करती है, जो एजेंट स्किल्स सहेजता और वापस लाता है, और MCP के ज़रिए आपके AI ऐप से जुड़ता है।
rsi-arena
7.8kआपके एजेंट को AIME और Terminal-Bench जैसे मानक AI बेंचमार्क टेस्ट सेट करने और चलाने में मदद करती है, ताकि सुधार के तरीकों की तुलना हो सके।
experiment-guide
7.8kआपके एजेंट को छोटे प्रयोग बनाने, उनके नतीजे पढ़ने और जाँच के दौरान उपयोगी निष्कर्ष लिखने में मदद करती है।
मिलती-जुलती skills
taste-application
280kयह आपके एजेंट को किसी खास style में videos बनाने में मदद करता है। यह किसी reference video की editing rhythm कॉपी कर सकता है, नए scenes बना सकता है, colors ठीक कर सकता है, और सब कुछ दूसरे footage के साथ जोड़कर edit कर सकता है।
taste-distillation
280kयह आपके एजेंट को videos का विश्लेषण करके style pack बनाने देता है। इसमें colors, cutting rhythm और visual elements शामिल होते हैं, जिन्हें नई videos में उसी look के साथ दोबारा इस्तेमाल किया जा सकता है।
ui-demo
280kयह आपके एजेंट से साफ-सुथरे UI demo videos रिकॉर्ड करवाता है। tutorials बनाने या यह दिखाने के लिए उपयोगी है कि web app कैसे काम करता है।