muapi-youtube-shorts
Auto-generate viral 9:16 YouTube Shorts (or TikTok / Reels clips) from a long-form video.
Paste into Claude, ChatGPT or Cursor.
Read the source173 lines
| 1 | |
| 2 | slug muapi-youtube-shorts |
| 3 | name muapi-youtube-shorts |
| 4 | version "2.0.0" |
| 5 | description Auto-generate viral 9:16 YouTube Shorts (or TikTok / Reels clips) from a long-form video. Thin platform-aware wrapper around the AI Clipping skill — picks sensible defaults for short-form social platforms (9:16, 30–60s sweet spot) and delegates the actual highlight extraction + crop to muapi.ai's `/ai-clipping` endpoint. |
| 6 | acceptLicenseTerms true |
| 7 | |
| 8 | |
| 9 | # YouTube Shorts Generator |
| 10 | |
| 11 | **Long video → ranked vertical short clips, tuned for short-form social.** |
| 12 | |
| 13 | This skill is a platform-aware preset over the [AI Clipping] primitive. It picks the right aspect ratio and clip count for the target platform and delegates highlight extraction, dedupe, and face-tracked auto-crop to muapi.ai's managed `/ai-clipping` endpoint. |
| 14 | |
| 15 | Reference implementation: https://github.com/SamurAIGPT/AI-Youtube-Shorts-Generator |
| 16 | Underlying API: https://muapi.ai/playground/ai-clipping |
| 17 | |
| 18 | |
| 19 | |
| 20 | ## When to Use This vs. AI Clipping |
| 21 | |
| 22 | | Use this skill when… | Use [AI Clipping] directly when… | |
| 23 | |:---|:---| |
| 24 | | Target is YouTube Shorts / TikTok / Reels | You want full control over aspect / count | |
| 25 | | You want platform-tuned defaults | You want raw timestamps (`--coords-only`) | |
| 26 | | You'd rather pass `--platform tiktok` than think about ratios | You're integrating into a custom renderer | |
| 27 | |
| 28 | |
| 29 | |
| 30 | ## Agent Execution Protocol |
| 31 | |
| 32 | ### Step 1 — Collect Inputs |
| 33 | |
| 34 | | Input | Default | Notes | |
| 35 | |:---|:---|:---| |
| 36 | | `--source` | — | YouTube URL, hosted mp4 URL, or local file | |
| 37 | | `--platform` | `shorts` | `shorts` \| `tiktok` \| `reels` \| `feed` (sets ratio + count defaults) | |
| 38 | | `--num-clips` | platform default | Override clip count | |
| 39 | | `--aspect-ratio` | platform default | Override aspect ratio | |
| 40 | |
| 41 | If the user gave only a URL, run with platform defaults — don't block. |
| 42 | |
| 43 | |
| 44 | |
| 45 | ### Step 2 — Verify Prerequisites |
| 46 | |
| 47 | `muapi-cli` installed and authed (`muapi auth configure`) |
| 48 | `MUAPI_API_KEY` available |
| 49 | |
| 50 | That's it. Transcription, highlight ranking, dedupe, and cropping all run server-side — no `ffmpeg`, no Python, no Whisper, no LLM keys needed locally. |
| 51 | |
| 52 | |
| 53 | |
| 54 | ### Step 3 — Run the Pipeline |
| 55 | |
| 56 | |
| 57 | bash library/social/youtube-shorts/scripts/run-youtube-shorts.sh \ |
| 58 | --source "<YOUTUBE_URL>" \ |
| 59 | --platform shorts \ |
| 60 | --num-clips 5 \ |
| 61 | --view |
| 62 | |
| 63 | |
| 64 | The script: |
| 65 | Resolves the source (uploads local files to muapi CDN if needed). |
| 66 | Picks platform defaults if `--aspect-ratio` / `--num-clips` aren't passed. |
| 67 | Calls `muapi edit clipping` (the `/ai-clipping` endpoint) with the chosen params. |
| 68 | Polls until done, prints a ranked summary, optionally downloads / opens clips. |
| 69 | |
| 70 | |
| 71 | |
| 72 | ## What Happens Server-Side |
| 73 | |
| 74 | The `/ai-clipping` endpoint runs the full pipeline: |
| 75 | |
| 76 | **Transcribes** the audio. |
| 77 | **Ranks highlights** through a virality framework — hook moments, emotional peaks, opinion bombs, revelation moments, conflict, quotable lines, story peaks, practical value. |
| 78 | **Dedupes** overlapping candidates by score. |
| 79 | **Top-N selects** and **face-tracks** vertical crops. |
| 80 | |
| 81 | Each clip ships with score (0–100), opening hook line, and a one-sentence "why it works" reason. |
| 82 | |
| 83 | |
| 84 | |
| 85 | ## Platform Defaults |
| 86 | |
| 87 | | Platform | Flag | Aspect | Default clips | Notes | |
| 88 | |:---|:---|:---|:---|:---| |
| 89 | | YouTube Shorts | `--platform shorts` | `9:16` | 3 | Hook in first 1s | |
| 90 | | TikTok | `--platform tiktok` | `9:16` | 5 | Higher energy, longer ok | |
| 91 | | Instagram Reels | `--platform reels` | `9:16` | 3 | Hook in first 1s | |
| 92 | | Instagram Feed | `--platform feed` | `1:1` | 3 | Static-feel works well | |
| 93 | |
| 94 | Override any default with `--aspect-ratio` / `--num-clips`. |
| 95 | |
| 96 | |
| 97 | |
| 98 | ## Quick Invocation Patterns |
| 99 | |
| 100 | **Single video, defaults:** |
| 101 | |
| 102 | bash run-youtube-shorts.sh --source "https://youtube.com/watch?v=VIDEO_ID" |
| 103 | |
| 104 | |
| 105 | **TikTok preset — 5 clips, view in player:** |
| 106 | |
| 107 | bash run-youtube-shorts.sh --source "<URL>" --platform tiktok --view |
| 108 | |
| 109 | |
| 110 | **Square Instagram feed clips:** |
| 111 | |
| 112 | bash run-youtube-shorts.sh --source "<URL>" --platform feed --num-clips 3 |
| 113 | |
| 114 | |
| 115 | **Batch — `urls.txt` with one URL per line:** |
| 116 | |
| 117 | xargs -a urls.txt -I{} bash run-youtube-shorts.sh --source "{}" |
| 118 | |
| 119 | |
| 120 | **Async submit (returns request_id, poll later):** |
| 121 | |
| 122 | REQUEST_ID=$(bash run-youtube-shorts.sh --source "<URL>" --async --output-json - | jq -r '.request_id') |
| 123 | muapi predict wait "$REQUEST_ID" --download ./outputs |
| 124 | |
| 125 | |
| 126 | |
| 127 | |
| 128 | ## Output Schema |
| 129 | |
| 130 | |
| 131 | { |
| 132 | "source_video_url": "...", |
| 133 | "shorts": [ |
| 134 | { |
| 135 | "title": "The one mistake that cost me $50K", |
| 136 | "start_time": 124.3, |
| 137 | "end_time": 187.6, |
| 138 | "score": 92, |
| 139 | "hook_sentence": "Nobody talks about this, but it killed my first startup...", |
| 140 | "virality_reason": "Opens with a number + regret, peaks on a contrarian lesson", |
| 141 | "clip_url": "https://.../short_1.mp4" |
| 142 | } |
| 143 | ] |
| 144 | } |
| 145 | |
| 146 | |
| 147 | When reporting back, surface for each clip: rank, score, time range, title, hook, and clip URL. |
| 148 | |
| 149 | |
| 150 | |
| 151 | ## Common Mistakes to Avoid |
| 152 | |
| 153 | **Wrong aspect ratio for the platform** — Shorts / TikTok / Reels are `9:16`. The platform preset handles this; only override if you know why. |
| 154 | **Padding to hit `--num-clips`** — if the API returns fewer survivors, return what you have. Don't ship low-score filler. |
| 155 | **Re-running on a 404'd clip URL** — re-fetch the same `request_id` with `muapi predict wait <id>` rather than re-clipping. |
| 156 | |
| 157 | |
| 158 | |
| 159 | ## Failure Modes |
| 160 | |
| 161 | **API key missing or rejected** — surface the error; don't fabricate a key. |
| 162 | **Job timed out** — bump `--poll-timeout` and retry. |
| 163 | **Source URL not reachable** — upload the file via `muapi upload file` and pass the returned URL. |
| 164 | **Fewer clips returned than requested** — source had fewer rankable highlights. Return what came back with a note. |
| 165 | |
| 166 | |
| 167 | |
| 168 | ## Done Criteria |
| 169 | |
| 170 | The skill is done when: |
| 171 | `result.shorts` has up to `num_clips` entries, each with a working `clip_url`. |
| 172 | The user has been shown the ranked list (score, time range, title, hook, URL). |
| 173 | If `--output-json` was set, the file exists and parses. |