--- name: beat-sync-reel description: Generates Instagram Reels where product image cuts are synced to audio beats. Accepts audio as a local file, URL, or search query. Uses librosa for beat detection, FFmpeg Ken Burns for scene animation, and Pillow for text overlays. No AI video generation — fully free, fast, and scalable. user-invocable: true allowed-tools: Bash, Read, Write, Edit, Grep, Glob, WebSearch argument-hint: "[product-url-or-image-paths] [audio-source]" --- # Beat-Sync Reel Generator Takes product images and a trending audio track, detects beats, and produces an Instagram Reel where every image cut lands exactly on a beat. Fast, free (no API credits), and scalable. --- ## Requirements - **Python 3** with `librosa` and `Pillow` packages - **FFmpeg** installed - **yt-dlp** installed (for URL/search audio input) --- ## Input The user provides: 1. **Audio** (required) — one of three formats: - **Local file path** — e.g. `/path/to/trending-audio.mp3` - **URL** — Instagram Reel, TikTok, or YouTube link. Download with: `yt-dlp -x --audio-format mp3 -o "audio.%(ext)s" ""` - **Audio name** — e.g. "Nashe Si Chadh Gayi". Web search for it, find a YouTube/SoundCloud source, download with yt-dlp. 2. **Product images** (required) — one of: - **List of image file paths** — local JPG/PNG files - **Product page URL** — scrape images using these methods in order until one works: 1. **Shopify JSON** — append `.json` to the product URL and extract image URLs from the response 2. **HTML scraping with referrer** — `curl` with `-H "Referer: "` and a browser user-agent, then parse `` tags 3. **Chrome DevTools** — navigate to the page, extract image URLs via JavaScript, download each 3. **Audio segment** (optional) — `start` and `end` timestamps in seconds to use a specific portion of the audio. Defaults to 0-15s. 4. **Beat frequency** (optional) — cut on every Nth beat. Defaults to `2` (every 2nd beat, ~1.3s per image at typical tempos). Use `1` for fast cuts, `4` for slower. 5. **Product info** (optional) — brand name, product name, price, CTA URL. Used for end card. If not provided, skip end card. 6. **Style preset** (optional) — for end card text. One of: `minimal`, `luxury`, `bold`, `editorial`, `clean`. Defaults to `clean`. See Style Presets table below for font details. --- ## Pipeline ### Step 1: Resolve Audio Based on input type: **Local file:** ```bash # Just verify it exists and get duration ffprobe -v quiet -print_format json -show_format "audio.mp3" ``` **URL (Instagram/TikTok/YouTube):** ```bash yt-dlp -x --audio-format mp3 -o "/audio.%(ext)s" "" ``` **Audio name (search):** 1. Web search for `"