[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6KJ5WMP1SFQHYXS5CAJH7TS":3,"skill-same:01M6KJ5WMP1SFQHYXS5CAJH7TS":59},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":27,"linkOnly":28,"markdownContent":29,"markdownBody":30,"frontMatter":31,"refName":32,"commitSha":33,"skillDirectory":34,"forksCount":13,"repositoryHtmlUrl":35,"repositoryHomepageUrl":6,"ownerHtmlUrl":36,"ownerBlogUrl":6,"ownerDescription":37,"updatedAt":38,"install":39,"resources":52},"01M6KJ5WMP1SFQHYXS5CAJH7TS","ffmpeg-graceful-degradation",null,"Graceful degradation workflow for ffmpeg encoding failures with progressive fallback strategies","AG064\u002FOpenSpace","AG064","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F184930299?v=4","01M6KHVFG7TB73NHX3RDYSTMH2","01M6KHVFMM7XA2PZA9Z83PHS3V",0,"MIT","https:\u002F\u002Fgithub.com\u002FAG064\u002FOpenSpace\u002Fblob\u002Fmain\u002Fgdpval_bench\u002Fskills\u002Fffmpeg-graceful-degradation\u002FSKILL.md",[],[18,19,20,21,22,23,24,25,26],"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","ff671ef61ed6587c49bd54c81cdc751c0b99e363","gdpval_bench\u002Fskills\u002Fffmpeg-graceful-degradation","https:\u002F\u002Fgithub.com\u002FAG064\u002FOpenSpace","https:\u002F\u002Fgithub.com\u002FAG064","AG064, E.Mi.\r\n\r\nA person who thinks all the time, yet all they have to think about is nothing. I want to improve the world and work on open source projects","2026-10-08 06:53:48",{"source":8,"skillName":5,"commands":40,"prompt":50,"zipAvailable":51},[41,44,47],{"tool":42,"command":43},"npx","npx skills add AG064\u002FOpenSpace --skill ffmpeg-graceful-degradation",{"tool":45,"command":46},"bunx","bunx skills add AG064\u002FOpenSpace --skill ffmpeg-graceful-degradation",{"tool":48,"command":49},"pnpm","pnpm dlx skills add AG064\u002FOpenSpace --skill ffmpeg-graceful-degradation","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FAG064\u002FOpenSpace\u002Fblob\u002Fmain\u002Fgdpval_bench\u002Fskills\u002Fffmpeg-graceful-degradation\u002FSKILL.md",true,[53],{"path":54,"resourceType":55,"resourceTypeDesc":56,"sizeBytes":57,"sourceHtmlUrl":58},".skill_id","OTHER","其他",41,"https:\u002F\u002Fgithub.com\u002FAG064\u002FOpenSpace\u002Fblob\u002Fmain\u002Fgdpval_bench\u002Fskills\u002Fffmpeg-graceful-degradation\u002F.skill_id",[60,83,99,108,133,149],{"skillNo":61,"name":62,"nameZh":6,"description":63,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":64,"categories":65,"keywords":66,"publishedAt":27},"01M6KKMPWA0B5SCCH766F8M5EA","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\u002FAG064\u002FOpenSpace\u002Fblob\u002Fmain\u002Fshowcase\u002Fskills\u002Fwrite-special-chars-ts-check\u002FSKILL.md",[],[67,68,69,70,71,72,26,73,74,75,76,77,78,79,80,81,82],"write special chars ts check","check","write","filters","Existing","type-checking","errors","script","output","type","files","only","template","file","python","typescript",{"skillNo":84,"name":85,"nameZh":6,"description":86,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":87,"categories":88,"keywords":89,"publishedAt":27},"01M6KKMJXVBNVEY3TRK055F4A7","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\u002FAG064\u002FOpenSpace\u002Fblob\u002Fmain\u002Fshowcase\u002Fskills\u002Fwrite-special-chars-readback\u002FSKILL.md",[],[90,91,69,79,92,93,80,81,94,95,96,97,98,26,74,25],"readback","write special chars readback","cleanup","read","scripts","verification","via","post","helper",{"skillNo":100,"name":101,"nameZh":6,"description":102,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":103,"categories":104,"keywords":105,"publishedAt":27},"01M6KKMEGX9M9NC105J0W3Q5B9","write-special-chars-heredoc","Workaround for write_file failures caused by special characters (apostrophes, backticks, template literals) by using a Python heredoc script executed via shell.","https:\u002F\u002Fgithub.com\u002FAG064\u002FOpenSpace\u002Fblob\u002Fmain\u002Fshowcase\u002Fskills\u002Fwrite-special-chars-heredoc\u002FSKILL.md",[],[69,106,81,26,96,79,107,80,74],"write special chars heredoc","shell",{"skillNo":109,"name":110,"nameZh":6,"description":111,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":112,"categories":113,"keywords":114,"publishedAt":27},"01M6KKM8EJ2AATVHZBNB916WT0","worldmonitor-reference","Curated architecture index of the WorldMonitor open-source dashboard. Reference for extracting patterns — vanilla TypeScript, Panel class hierarchy, service layer, CSS grid, API edge functions, refresh scheduler, and 60+ data source integrations.","https:\u002F\u002Fgithub.com\u002FAG064\u002FOpenSpace\u002Fblob\u002Fmain\u002Fshowcase\u002Fskills\u002Fworldmonitor-reference\u002FSKILL.md",[],[115,116,117,118,82,119,120,121,122,123,26,124,125,126,127,128,129,130,131,132],"reference","worldmonitor","worldmonitor reference","dashboard","css","architecture","extracting","hierarchy","source","layer","panel","patterns","edge functions","integrations","open","api","data","scheduler",{"skillNo":134,"name":135,"nameZh":6,"description":136,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":137,"categories":138,"keywords":139,"publishedAt":27},"01M6KKM39PHYK627F19GE2B9XN","virtual-list","Implement efficient virtual scrolling for rendering large lists with DOM recycling, chunk-based rendering, and performance optimizations","https:\u002F\u002Fgithub.com\u002FAG064\u002FOpenSpace\u002Fblob\u002Fmain\u002Fshowcase\u002Fskills\u002Fvirtual-list\u002FSKILL.md",[],[140,141,142,143,26,144,25,145,146,147,148],"virtual list","list","virtual","chunk","dom","rendering","recycling","implement","performance",{"skillNo":150,"name":151,"nameZh":6,"description":152,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":9,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":153,"categories":154,"keywords":155,"publishedAt":27},"01M6KKKY7T2P61Y0JH54CDEJKQ","verify-directory-structure","Diagnose and resolve file access issues by first verifying the directory structure.","https:\u002F\u002Fgithub.com\u002FAG064\u002FOpenSpace\u002Fblob\u002Fmain\u002Fshowcase\u002Fskills\u002Fverify-directory-structure\u002FSKILL.md",[],[156,157,158,159,160,161,80,162,163,164],"directory","verify","structure","verify directory structure","access","first","issues","diagnose","file access"]