[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6KFHAPCZ33CA9WQD6MKR5BW":3,"skill-same:01M6KFHAPCZ33CA9WQD6MKR5BW":61},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":28,"linkOnly":29,"markdownContent":30,"markdownBody":31,"frontMatter":32,"refName":33,"commitSha":34,"skillDirectory":35,"forksCount":14,"repositoryHtmlUrl":36,"repositoryHomepageUrl":6,"ownerHtmlUrl":37,"ownerBlogUrl":38,"ownerDescription":39,"updatedAt":40,"install":41,"resources":54},"01M6KFHAPCZ33CA9WQD6MKR5BW","ffmpeg-graceful-degradation",null,"Graceful degradation workflow for ffmpeg encoding failures with progressive fallback strategies","xyliu-cs\u002FOpenSpace-GDPval","xyliu-cs","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F89236536?v=4","01M6KF8Z1V4TXS86CKSH48BY8T","xy","01M6KF8Z67443W0SHXM85JEF0B",0,"MIT","https:\u002F\u002Fgithub.com\u002Fxyliu-cs\u002FOpenSpace-GDPval\u002Fblob\u002Fmain\u002Fgdpval_bench\u002Fskills\u002Fffmpeg-graceful-degradation\u002FSKILL.md",[],[19,20,21,22,23,24,25,26,27],"ffmpeg","degradation","ffmpeg graceful degradation","workflow","encoding","fallback","strategies","with","for","2026-11-10 10:12:30",false,"---\nname: ffmpeg-graceful-degradation\ndescription: Graceful degradation workflow for ffmpeg encoding failures with progressive fallback strategies\n---\n\n# FFmpeg Graceful Degradation\n\nWhen 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.\n\n## Overview\n\nThe 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.\n\n## Step 1: Probe Encoder Availability\n\nBefore any encoding work, check what encoders are available:\n\n```bash\nffmpeg -encoders | grep -E \"libx264|libopenh264|mpeg4\"\n```\n\nExpected output shows which encoders are present:\n- `libx264` - Preferred H.264 encoder (may be missing)\n- `libopenh264` - Alternative H.264 (often has library issues)\n- `mpeg4` - Universal fallback (always available)\n\n## Step 2: Test Encoding on Single Short Clip\n\nNever start batch processing without validation. Extract and test a short segment:\n\n```bash\n# Extract 5-second test clip\nffmpeg -y -i input.mp4 -ss 0 -t 5 -c copy test_clip.mp4\n\n# Attempt encode with preferred codec\nffmpeg -y -i test_clip.mp4 -c:v libx264 -preset fast test_output.mp4\n```\n\nCheck the exit code and output for errors. Common failures:\n- `libopenh264.so: wrong ELF class`\n- `Encoder libx264 not found`\n- Library version mismatches\n\n## Step 3: Progressive Fallback Strategy\n\nIf the preferred encoder fails, try these fallbacks in order:\n\n### Fallback A: Copy Mode (No Re-encoding)\n```bash\nffmpeg -y -i input.mp4 -c:v copy -c:a copy output.mp4\n```\nFast, lossless, but doesn't change codec\u002Fformat.\n\n### Fallback B: MPEG4 Codec\n```bash\nffmpeg -y -i input.mp4 -c:v mpeg4 -q:v 3 -c:a copy output.mp4\n```\nUniversal compatibility, larger file sizes, always available.\n\n### Fallback C: Install MoviePy (Bundles Working FFmpeg)\n```bash\npip install moviepy\n```\n\nThen use Python instead of raw ffmpeg:\n```python\nfrom moviepy.editor import VideoFileClip, concatenate_videoclips\n\n# Single clip processing\nclip = VideoFileClip(\"input.mp4\")\nclip.write_videofile(\"output.mp4\", codec=\"libx264\")\n\n# Concatenate multiple clips\nclips = [VideoFileClip(f) for f in clip_files]\nfinal = concatenate_videoclips(clips)\nfinal.write_videofile(\"output.mp4\", codec=\"libx264\")\n```\n\nMoviePy bundles its own ffmpeg binary, avoiding system library issues.\n\n## Step 4: Implementation Pattern\n\nHere's a complete graceful degradation workflow:\n\n```python\nimport subprocess\nimport os\n\ndef safe_video_encode(input_path, output_path, clips=None):\n    \"\"\"\n    Encode video with graceful degradation fallbacks.\n    \n    Args:\n        input_path: Single input file path, or\n        clips: List of clip paths for concatenation\n    \n    Returns:\n        True if successful, False otherwise\n    \"\"\"\n    \n    # Step 1: Check encoder availability\n    result = subprocess.run(\n        [\"ffmpeg\", \"-encoders\"],\n        capture_output=True, text=True\n    )\n    has_libx264 = \"libx264\" in result.stdout\n    has_mpeg4 = \"mpeg4\" in result.stdout\n    \n    # Step 2: If concatenating, prepare clips with moviepy\n    if clips:\n        try:\n            from moviepy.editor import VideoFileClip, concatenate_videoclips\n            loaded_clips = [VideoFileClip(c) for c in clips]\n            final = concatenate_videoclips(loaded_clips)\n            final.write_videofile(output_path, codec=\"libx264\", logger=None)\n            return True\n        except Exception as e:\n            print(f\"MoviePy failed: {e}\")\n    \n    # Step 3: Try ffmpeg with progressive fallbacks\n    encoders_to_try = []\n    if has_libx264:\n        encoders_to_try.append(\"libx264\")\n    encoders_to_try.append(\"mpeg4\")  # Always available\n    \n    for codec in encoders_to_try:\n        cmd = [\n            \"ffmpeg\", \"-y\",\n            \"-i\", input_path,\n            \"-c:v\", codec,\n            \"-c:a\", \"copy\",\n            output_path\n        ]\n        result = subprocess.run(cmd, capture_output=True, text=True)\n        if result.returncode == 0:\n            return True\n    \n    # Step 4: Last resort - copy mode\n    cmd = [\"ffmpeg\", \"-y\", \"-i\", input_path, \"-c\", \"copy\", output_path]\n    result = subprocess.run(cmd, capture_output=True, text=True)\n    return result.returncode == 0\n```\n\n## Decision Flow\n\n```\nStart\n  │\n  ▼\nCheck encoders (ffmpeg -encoders)\n  │\n  ├─ libx264 available? ──Yes──► Try libx264\n  │         │                       │\n  │         No                      └─► Success? ──Yes──► Done\n  │         │                                      │\n  │         ▼                                      No\n  │    Test short clip                             │\n  │         │                                      ▼\n  │         ▼                               Try -c:v copy\n  │    Encode fails? ──Yes──► Check libopenh264    │\n  │         │                       │              │\n  │         No                      Broken         ▼\n  │         │                       │         Try mpeg4\n  │         ▼                       ▼              │\n  │      Done                  Install moviepy     │\n  │                              │                 │\n  │                              ▼                 │\n  │                         Use VideoFileClip ◄────┘\n  │                         concatenate_videoclips\n  │                              │\n  │                              ▼\n  │                            Done\n  │\n  ▼\nEnd\n```\n\n## Key Principles\n\n1. **Test first, batch later** - Always validate on a short clip\n2. **Fail fast, fallback gracefully** - Don't waste time on doomed encodings\n3. **MoviePy as safety net** - Its bundled ffmpeg avoids system issues\n4. **Copy mode preserves content** - Even if quality isn't ideal\n\n## Common Error Patterns\n\n| Error Message | Cause | Solution |\n|--------------|-------|----------|\n| `libopenh264.so: wrong ELF class` | Library architecture mismatch | Use moviepy or mpeg4 |\n| `Encoder libx264 not found` | FFmpeg built without x264 | Use mpeg4 fallback |\n| `Broken pipe` | Process killed mid-operation | Try copy mode first |\n| `Invalid data found` | Corrupt or incompatible input | Re-extract source |\n\n## When to Use This Skill\n\n- Processing user-uploaded videos (unknown codecs\u002Fformats)\n- Running in containers with limited codec support\n- Batch processing where failure would be costly\n- Cross-platform deployments with varying ffmpeg builds","# FFmpeg Graceful Degradation\n\nWhen 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.\n\n## Overview\n\nThe 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.\n\n## Step 1: Probe Encoder Availability\n\nBefore any encoding work, check what encoders are available:\n\n```bash\nffmpeg -encoders | grep -E \"libx264|libopenh264|mpeg4\"\n```\n\nExpected output shows which encoders are present:\n- `libx264` - Preferred H.264 encoder (may be missing)\n- `libopenh264` - Alternative H.264 (often has library issues)\n- `mpeg4` - Universal fallback (always available)\n\n## Step 2: Test Encoding on Single Short Clip\n\nNever start batch processing without validation. Extract and test a short segment:\n\n```bash\n# Extract 5-second test clip\nffmpeg -y -i input.mp4 -ss 0 -t 5 -c copy test_clip.mp4\n\n# Attempt encode with preferred codec\nffmpeg -y -i test_clip.mp4 -c:v libx264 -preset fast test_output.mp4\n```\n\nCheck the exit code and output for errors. Common failures:\n- `libopenh264.so: wrong ELF class`\n- `Encoder libx264 not found`\n- Library version mismatches\n\n## Step 3: Progressive Fallback Strategy\n\nIf the preferred encoder fails, try these fallbacks in order:\n\n### Fallback A: Copy Mode (No Re-encoding)\n```bash\nffmpeg -y -i input.mp4 -c:v copy -c:a copy output.mp4\n```\nFast, lossless, but doesn't change codec\u002Fformat.\n\n### Fallback B: MPEG4 Codec\n```bash\nffmpeg -y -i input.mp4 -c:v mpeg4 -q:v 3 -c:a copy output.mp4\n```\nUniversal compatibility, larger file sizes, always available.\n\n### Fallback C: Install MoviePy (Bundles Working FFmpeg)\n```bash\npip install moviepy\n```\n\nThen use Python instead of raw ffmpeg:\n```python\nfrom moviepy.editor import VideoFileClip, concatenate_videoclips\n\n# Single clip processing\nclip = VideoFileClip(\"input.mp4\")\nclip.write_videofile(\"output.mp4\", codec=\"libx264\")\n\n# Concatenate multiple clips\nclips = [VideoFileClip(f) for f in clip_files]\nfinal = concatenate_videoclips(clips)\nfinal.write_videofile(\"output.mp4\", codec=\"libx264\")\n```\n\nMoviePy bundles its own ffmpeg binary, avoiding system library issues.\n\n## Step 4: Implementation Pattern\n\nHere's a complete graceful degradation workflow:\n\n```python\nimport subprocess\nimport os\n\ndef safe_video_encode(input_path, output_path, clips=None):\n    \"\"\"\n    Encode video with graceful degradation fallbacks.\n    \n    Args:\n        input_path: Single input file path, or\n        clips: List of clip paths for concatenation\n    \n    Returns:\n        True if successful, False otherwise\n    \"\"\"\n    \n    # Step 1: Check encoder availability\n    result = subprocess.run(\n        [\"ffmpeg\", \"-encoders\"],\n        capture_output=True, text=True\n    )\n    has_libx264 = \"libx264\" in result.stdout\n    has_mpeg4 = \"mpeg4\" in result.stdout\n    \n    # Step 2: If concatenating, prepare clips with moviepy\n    if clips:\n        try:\n            from moviepy.editor import VideoFileClip, concatenate_videoclips\n            loaded_clips = [VideoFileClip(c) for c in clips]\n            final = concatenate_videoclips(loaded_clips)\n            final.write_videofile(output_path, codec=\"libx264\", logger=None)\n            return True\n        except Exception as e:\n            print(f\"MoviePy failed: {e}\")\n    \n    # Step 3: Try ffmpeg with progressive fallbacks\n    encoders_to_try = []\n    if has_libx264:\n        encoders_to_try.append(\"libx264\")\n    encoders_to_try.append(\"mpeg4\")  # Always available\n    \n    for codec in encoders_to_try:\n        cmd = [\n            \"ffmpeg\", \"-y\",\n            \"-i\", input_path,\n            \"-c:v\", codec,\n            \"-c:a\", \"copy\",\n            output_path\n        ]\n        result = subprocess.run(cmd, capture_output=True, text=True)\n        if result.returncode == 0:\n            return True\n    \n    # Step 4: Last resort - copy mode\n    cmd = [\"ffmpeg\", \"-y\", \"-i\", input_path, \"-c\", \"copy\", output_path]\n    result = subprocess.run(cmd, capture_output=True, text=True)\n    return result.returncode == 0\n```\n\n## Decision Flow\n\n```\nStart\n  │\n  ▼\nCheck encoders (ffmpeg -encoders)\n  │\n  ├─ libx264 available? ──Yes──► Try libx264\n  │         │                       │\n  │         No                      └─► Success? ──Yes──► Done\n  │         │                                      │\n  │         ▼                                      No\n  │    Test short clip                             │\n  │         │                                      ▼\n  │         ▼                               Try -c:v copy\n  │    Encode fails? ──Yes──► Check libopenh264    │\n  │         │                       │              │\n  │         No                      Broken         ▼\n  │         │                       │         Try mpeg4\n  │         ▼                       ▼              │\n  │      Done                  Install moviepy     │\n  │                              │                 │\n  │                              ▼                 │\n  │                         Use VideoFileClip ◄────┘\n  │                         concatenate_videoclips\n  │                              │\n  │                              ▼\n  │                            Done\n  │\n  ▼\nEnd\n```\n\n## Key Principles\n\n1. **Test first, batch later** - Always validate on a short clip\n2. **Fail fast, fallback gracefully** - Don't waste time on doomed encodings\n3. **MoviePy as safety net** - Its bundled ffmpeg avoids system issues\n4. **Copy mode preserves content** - Even if quality isn't ideal\n\n## Common Error Patterns\n\n| Error Message | Cause | Solution |\n|--------------|-------|----------|\n| `libopenh264.so: wrong ELF class` | Library architecture mismatch | Use moviepy or mpeg4 |\n| `Encoder libx264 not found` | FFmpeg built without x264 | Use mpeg4 fallback |\n| `Broken pipe` | Process killed mid-operation | Try copy mode first |\n| `Invalid data found` | Corrupt or incompatible input | Re-extract source |\n\n## When to Use This Skill\n\n- Processing user-uploaded videos (unknown codecs\u002Fformats)\n- Running in containers with limited codec support\n- Batch processing where failure would be costly\n- Cross-platform deployments with varying ffmpeg builds",{"name":5,"description":7},"main","af1b40a42167d09c30b3a63000aa14ace4c1e229","gdpval_bench\u002Fskills\u002Fffmpeg-graceful-degradation","https:\u002F\u002Fgithub.com\u002Fxyliu-cs\u002FOpenSpace-GDPval","https:\u002F\u002Fgithub.com\u002Fxyliu-cs","https:\u002F\u002Fxyliu-cs.github.io","PhD Student in CS, CUHK-Shenzhen.","2026-04-06 20:32:15",{"source":8,"skillName":5,"commands":42,"prompt":52,"zipAvailable":53},[43,46,49],{"tool":44,"command":45},"npx","npx skills add xyliu-cs\u002FOpenSpace-GDPval --skill ffmpeg-graceful-degradation",{"tool":47,"command":48},"bunx","bunx skills add xyliu-cs\u002FOpenSpace-GDPval --skill ffmpeg-graceful-degradation",{"tool":50,"command":51},"pnpm","pnpm dlx skills add xyliu-cs\u002FOpenSpace-GDPval --skill ffmpeg-graceful-degradation","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fxyliu-cs\u002FOpenSpace-GDPval\u002Fblob\u002Fmain\u002Fgdpval_bench\u002Fskills\u002Fffmpeg-graceful-degradation\u002FSKILL.md",true,[55],{"path":56,"resourceType":57,"resourceTypeDesc":58,"sizeBytes":59,"sourceHtmlUrl":60},".skill_id","OTHER","其他",41,"https:\u002F\u002Fgithub.com\u002Fxyliu-cs\u002FOpenSpace-GDPval\u002Fblob\u002Fmain\u002Fgdpval_bench\u002Fskills\u002Fffmpeg-graceful-degradation\u002F.skill_id",[62,75,83,98,118,134],{"skillNo":63,"name":64,"nameZh":6,"description":65,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":66,"categories":67,"keywords":68,"publishedAt":28},"01M6KG8MF1S664SWBDENYRSCK8","zip-export-deliverable","Ensures codebase deliverables are properly exported as ZIP archives through a dedicated finalization step","https:\u002F\u002Fgithub.com\u002Fxyliu-cs\u002FOpenSpace-GDPval\u002Fblob\u002Fmain\u002Fgdpval_bench\u002Fskills\u002Fzip-export-deliverable\u002FSKILL.md",[],[69,70,71,72,73,74],"zip export deliverable","zip","export","deliverables","codebase","as",{"skillNo":76,"name":77,"nameZh":6,"description":78,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":79,"categories":80,"keywords":81,"publishedAt":28},"01M6KG8GAZWHHEK7VNJDW0ME21","zip-deliverable-finalization","Ensure codebase deliverables are properly packaged as ZIP exports in a dedicated final step","https:\u002F\u002Fgithub.com\u002Fxyliu-cs\u002FOpenSpace-GDPval\u002Fblob\u002Fmain\u002Fgdpval_bench\u002Fskills\u002Fzip-deliverable-finalization\u002FSKILL.md",[],[82,70,72,73,74],"zip deliverable finalization",{"skillNo":84,"name":85,"nameZh":6,"description":86,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":87,"categories":88,"keywords":89,"publishedAt":28},"01M6KG8CMQQ1PYMNTSRZ9VS1MD","zero-iteration-failure-analysis","Identify and handle agent failures with 0 iterations as pre-execution system issues","https:\u002F\u002Fgithub.com\u002Fxyliu-cs\u002FOpenSpace-GDPval\u002Fblob\u002Fmain\u002Fgdpval_bench\u002Fskills\u002Fzero-iteration-failure-analysis\u002FSKILL.md",[],[90,91,92,93,94,26,95,96,74,97],"failure analysis","ZeRO","analysis","iteration","zero iteration failure analysis","issues","execution","system",{"skillNo":99,"name":100,"nameZh":6,"description":101,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":102,"categories":103,"keywords":104,"publishedAt":28},"01M6KG86W3PA07FT9W58YHHERM","write-file-fallback-report","Generate professional documents using write_file when primary data sources fail, leveraging embedded domain knowledge instead of external retrieval","https:\u002F\u002Fgithub.com\u002Fxyliu-cs\u002FOpenSpace-GDPval\u002Fblob\u002Fmain\u002Fgdpval_bench\u002Fskills\u002Fwrite-file-fallback-report\u002FSKILL.md",[],[24,105,106,107,108,109,110,111,112,113,114,115,116,117],"write","file","report","write file fallback report","domain","professional","sources","retrieval","generate","embedded","documents","data","knowledge",{"skillNo":119,"name":120,"nameZh":6,"description":121,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":122,"categories":123,"keywords":124,"publishedAt":28},"01M6KG82GAEY3GG77CMGCK1C2T","fallback-doc-with-delegation","Generate professional documents after tool failures using shell_agent for complex formats or write_file for simple text\u002Fmarkdown","https:\u002F\u002Fgithub.com\u002Fxyliu-cs\u002FOpenSpace-GDPval\u002Fblob\u002Fmain\u002Fgdpval_bench\u002Fskills\u002Fwrite-file-fallback-report-enhanced\u002FSKILL.md",[],[125,26,24,126,127,128,115,113,106,129,130,131,105,132,110,133,27],"fallback doc with delegation","doc","delegation","shell","markdown","tool","text","simple","formats",{"skillNo":135,"name":136,"nameZh":6,"description":137,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":138,"categories":139,"keywords":140,"publishedAt":28},"01M6KG7WT7GX5NYCGEFHW22NV7","context-anchored-fallback-report","Generate documents with write_file when retrieval tools fail, with explicit guardrails against task context drift","https:\u002F\u002Fgithub.com\u002Fxyliu-cs\u002FOpenSpace-GDPval\u002Fblob\u002Fmain\u002Fgdpval_bench\u002Fskills\u002Fwrite-file-fallback-report-enhanced-4bc5c2\u002FSKILL.md",[],[24,107,141,142,113,106,143,144,105,145,146,112,26,147,115],"context","context anchored fallback report","Guardrails","Tools","task","drift","context drift"]