[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6HXKM4MZY0G23NE764BH83W":3,"skill-same:01M6HXKM4MZY0G23NE764BH83W":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":36,"repositoryHtmlUrl":37,"repositoryHomepageUrl":6,"ownerHtmlUrl":38,"ownerBlogUrl":39,"ownerDescription":6,"updatedAt":40,"install":41,"resources":54},"01M6HXKM4MZY0G23NE764BH83W","ffmpeg-graceful-degradation",null,"Graceful degradation workflow for ffmpeg encoding failures with progressive fallback strategies","HKUDS\u002FAgentPilot","HKUDS","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F118165258?v=4","01M6HW8VRNZP64G0P4MVJW2KKQ","✨Data Intelligence Lab@HKU✨","01M6HW8VWZVHBRHYH3T330PFWV",8029,"MIT","https:\u002F\u002Fgithub.com\u002FHKUDS\u002FAgentPilot\u002Fblob\u002Fmain\u002Fopenspace\u002Flegacy\u002Fv1\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","6b84b0689ca0d9e7b1e4061188ff6b60758e0f8a","openspace\u002Flegacy\u002Fv1\u002Fgdpval_bench\u002Fskills\u002Fffmpeg-graceful-degradation",944,"https:\u002F\u002Fgithub.com\u002FHKUDS\u002FAgentPilot","https:\u002F\u002Fgithub.com\u002FHKUDS","https:\u002F\u002Fsites.google.com\u002Fview\u002Fchaoh","2026-11-12 22:26:39",{"source":8,"skillName":5,"commands":42,"prompt":52,"zipAvailable":53},[43,46,49],{"tool":44,"command":45},"npx","npx skills add HKUDS\u002FAgentPilot --skill ffmpeg-graceful-degradation",{"tool":47,"command":48},"bunx","bunx skills add HKUDS\u002FAgentPilot --skill ffmpeg-graceful-degradation",{"tool":50,"command":51},"pnpm","pnpm dlx skills add HKUDS\u002FAgentPilot --skill ffmpeg-graceful-degradation","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FHKUDS\u002FAgentPilot\u002Fblob\u002Fmain\u002Fopenspace\u002Flegacy\u002Fv1\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\u002FHKUDS\u002FAgentPilot\u002Fblob\u002Fmain\u002Fopenspace\u002Flegacy\u002Fv1\u002Fgdpval_bench\u002Fskills\u002Fffmpeg-graceful-degradation\u002F.skill_id",[62,81,100,120,142,165],{"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},"01M6HYB297NDABRERJRVG0K8R0","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.","https:\u002F\u002Fgithub.com\u002FHKUDS\u002FAgentPilot\u002Fblob\u002Fmain\u002Fplugins\u002Fagentpilot\u002Fskills\u002Fagentpilot\u002FSKILL.md",[],[64,69,70,26,71,72,73,74,75,76,77,78,79,80],"prepare","requests","missing","installation","rsi","up","use","user","work","SET","run","experiments",{"skillNo":82,"name":83,"nameZh":6,"description":84,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":85,"categories":86,"keywords":87,"publishedAt":28},"01M6HYAYWXTTE1J7DJM0MFNQ4H","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.","https:\u002F\u002Fgithub.com\u002FHKUDS\u002FAgentPilot\u002Fblob\u002Fmain\u002Fopenspace\u002Fopenspace\u002Fskills\u002Fremember\u002FSKILL.md",[],[83,88,89,90,91,92,93,94,95,96,97,98,99],"memory","review","auto","openspace","changes","facts","detect","entries","local","conflicts","stale","duplicates",{"skillNo":101,"name":102,"nameZh":6,"description":103,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":104,"categories":105,"keywords":106,"publishedAt":28},"01M6HYAVMPM4SBDV60R2B5HPV8","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.","https:\u002F\u002Fgithub.com\u002FHKUDS\u002FAgentPilot\u002Fblob\u002Fmain\u002Fopenspace\u002Fopenspace\u002Fhost_skills\u002Fskill-discovery\u002FSKILL.md",[],[107,108,109,91,110,111,112,113,114,115,116,117,118,119],"skill discovery","discovery","reusable","step by step","tokens","packages","help","cloud","reliability","capabilities","browse","search","Tools",{"skillNo":121,"name":122,"nameZh":6,"description":123,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":124,"categories":125,"keywords":126,"publishedAt":28},"01M6HYAR811B3RB0M50RBEDGN6","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.","https:\u002F\u002Fgithub.com\u002FHKUDS\u002FAgentPilot\u002Fblob\u002Fmain\u002Fopenspace\u002Fopenspace\u002Fhost_skills\u002Fdelegate-task\u002FSKILL.md",[],[127,128,129,91,130,131,132,133,134,109,90,75,135,136,137,27,138,139,140,141],"delegate","task","delegate task","time","improve","desktop automation","worker","community","autonomous","tool","stack","share","tasks","automation","MCP",{"skillNo":143,"name":144,"nameZh":6,"description":145,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":146,"categories":147,"keywords":148,"publishedAt":28},"01M6HYAM9FSGV6E52AYENDQXYH","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.","https:\u002F\u002Fgithub.com\u002FHKUDS\u002FAgentPilot\u002Fblob\u002Fmain\u002Fopenspace\u002Flegacy\u002Fv1\u002Fshowcase\u002Fskills\u002Fwrite-special-chars-ts-check\u002FSKILL.md",[],[149,150,151,152,153,154,155,156,157,158,159,160,161,162,27,163,164],"write special chars ts check","write","check","type","files","filters","only","template","file","python","typescript","output","Existing","type-checking","errors","script",{"skillNo":166,"name":167,"nameZh":6,"description":168,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":169,"categories":170,"keywords":171,"publishedAt":28},"01M6HYAH05HGV7SVWSVR8PJRQD","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 \u002Ftmp helper scripts.","https:\u002F\u002Fgithub.com\u002FHKUDS\u002FAgentPilot\u002Fblob\u002Fmain\u002Fopenspace\u002Flegacy\u002Fv1\u002Fshowcase\u002Fskills\u002Fwrite-special-chars-readback\u002FSKILL.md",[],[172,173,150,26,27,164,174,175,176,177,178,156,157,179,180,158],"write special chars readback","readback","helper","post","via","scripts","read","verification","cleanup"]