| name | instagram-reel-remix |
| description | Autonomously remix an Instagram Reel for the Zero Proof sobriety app — download the video, analyze the original hook text, generate new hook copy and a conversion-focused CTA, get one user confirmation, then render the final video. Use when given an Instagram Reel URL and asked to remix it for Zero Proof. Produces a single H.264/AAC .mp4 saved to video-output/. |
Instagram Reel Remix — Zero Proof (Autonomous)
Goal
Turn any Instagram Reel meme into a Zero Proof branded video that drives downloads and ultimately paying customers. The hook adapts the meme's existing premise to the sobriety niche. The CTA drives conversion to the Zero Proof app.
Autonomous Flow
Run steps 1–5 silently. At step 6, pause for one user confirmation. Then execute steps 7–13 without interruption. Only surface errors.
Pre-flight — Run First, Silently
Detect OS and install missing deps accordingly:
_install() {
local pkg=$1
if [[ "$OSTYPE" == "darwin"* ]]; then
brew install "$pkg"
elif command -v apt-get &>/dev/null; then
sudo apt-get install -y "$pkg"
elif command -v dnf &>/dev/null; then
sudo dnf install -y "$pkg"
elif command -v pacman &>/dev/null; then
sudo pacman -S --noconfirm "$pkg"
else
echo "ERROR: Cannot auto-install $pkg — unsupported package manager. Install manually and retry." >&2
exit 1
fi
}
if ! command -v yt-dlp &>/dev/null; then
if [[ "$OSTYPE" == "darwin"* ]]; then
brew install yt-dlp
else
pip3 install yt-dlp --user 2>/dev/null || pip install yt-dlp --user
fi
fi
command -v ffmpeg &>/dev/null || _install ffmpeg
command -v magick &>/dev/null || _install imagemagick
ffmpeg -filters 2>/dev/null | grep -q drawtext \
&& echo "drawtext=yes" || echo "drawtext=no (PNG overlay will be used)"
If any install fails, stop and surface the error.
Step 1 — Download Source Video
WORK_DIR="$(pwd)/reel-remix-work"
mkdir -p "$WORK_DIR"
yt-dlp --no-playlist -o "$WORK_DIR/original.mp4" "<INSTAGRAM_URL>"
Verify it downloaded. If yt-dlp fails (geo-block, login-required, private), surface the error — do not continue.
Step 2 — Inspect the Video
ffprobe -v quiet \
-show_entries stream=codec_name,width,height,duration \
-show_entries format=duration \
-of default "$WORK_DIR/original.mp4"
Extract and store:
VIDEO_W — width (typically 720)
VIDEO_H — height (typically 1280)
AUDIO_DUR — format duration (the true total length; this is the master clock)
Extract 3 probe frames and auto-detect where the video content starts (= height of the text zone):
ffmpeg -i "$WORK_DIR/original.mp4" \
-vf "select=eq(n\,0)+eq(n\,15)+eq(n\,30)" \
-vsync 0 "$WORK_DIR/probe_%d.png" -y 2>/dev/null
TEXT_ZONE_H=9999
for f in "$WORK_DIR"/probe_*.png; do
OFFSET=$(magick "$f" -fuzz 8% -trim -format "%O" info: 2>/dev/null \
| grep -oE '\+[0-9]+$' | tr -d '+')
[ -n "$OFFSET" ] && [ "$OFFSET" -lt "$TEXT_ZONE_H" ] && TEXT_ZONE_H=$OFFSET
done
if [ "$TEXT_ZONE_H" -eq 9999 ] || [ "$TEXT_ZONE_H" -lt 50 ]; then
echo "ERROR: Could not detect text zone (TEXT_ZONE_H=$TEXT_ZONE_H). Inspect probe frames manually." >&2
exit 1
fi
TEXT_ZONE_H=$(( TEXT_ZONE_H + 150 ))
echo "TEXT_ZONE_H=$TEXT_ZONE_H (with 150px buffer)"
Read $WORK_DIR/probe_1.png to visually confirm the text zone and identify:
HOOK_BG — background color of the text zone (e.g. black or white) — match exactly
HOOK_FG — foreground/text color (e.g. white or black) — match exactly
- The original hook text verbatim — read every line carefully, this is the input for copy generation
Step 3 — Generate Hook Copy Options
Using the original hook text and meme context, generate 3 hook options for the user to choose from.
Rules for each option:
- Keep the meme's structural premise (setup / punchline or before / after)
- Replace the original topic with a sobriety / Zero Proof angle
- The hook must feel native to the format — short, punchy, relatable to people in recovery or sober-curious
- Line 1: setup (max ~12 words). Line 2: punchline / contrast (max ~10 words, ends with
: if the video reveals the punchline visually)
- Goal: stop the scroll → create curiosity → prime the viewer to care about sobriety
Example angles (use variety, don't repeat the same angle across 3 options):
- Identity shift: "Me before sobriety vs. me now:"
- Recovery pride: "My old self needed 5 drinks for this. / Me now, completely sober:"
- Relatability: "Nobody told me getting sober would make me THIS fun:"
- Social proof angle: "Everyone said I'd be boring without alcohol. / 365 days sober later:"
- Milestone: "1 year sober and I still don't miss it:"
Step 4 — Generate CTA Options
Generate 3 CTA options (2–3 lines each). Each should:
- Drive a specific action: download the Zero Proof app
- Feel conversational, not ad-copy stiff
- Create urgency or relevance to what the user just watched
- Vary the angle: curiosity, social proof, benefit, challenge
Examples:
- "Ready to track your own journey? / Download the Zero Proof app — / it's free to start."
- "See how far you've come. / Zero Proof helps you visualize / every day of your sobriety."
- "Your sober streak deserves a home. / Download Zero Proof today."
Step 5 — Propose Output Path
Generate:
FOLDER — {MM-DD-YY}-{topic-slug} (today's date + 2–3 word slug from meme topic)
FILENAME — 3–4 keyword-rich SEO words, no generics. Think: what would someone search on Instagram?
- Good:
sober-dance-freedom.mp4, alcohol-free-confidence.mp4
- Bad:
reel.mp4, video1.mp4, final.mp4
Step 6 — Confirmation Checkpoint (ONE PAUSE)
Present to the user in this exact format — do not render until confirmed:
PROPOSED REMIX — Zero Proof Reel
━━━ HOOK OPTIONS ━━━
[1] Line 1 / Line 2
[2] Line 1 / Line 2
[3] Line 1 / Line 2
━━━ CTA OPTIONS ━━━
[A] Full CTA text (2-3 lines)
[B] Full CTA text (2-3 lines)
[C] Full CTA text (2-3 lines)
━━━ OUTPUT ━━━
video-output/{FOLDER}/{FILENAME}
CTA duration: 3 seconds
Reply with hook # and CTA letter (e.g. "2A") or request changes.
Wait for the user's reply. Accept changes if requested, then confirm once more if the changes are substantial.
Step 7 — Generate Hook Overlay PNG
Use the chosen hook text. drawtext is unavailable — always use ImageMagick PNG overlay.
Resolve a font name that works with this ImageMagick build (use logical font names, NOT file paths):
if [[ "$OSTYPE" == "darwin"* ]]; then
FONT="Helvetica"
else
magick -list font 2>/dev/null | grep -qi "DejaVu-Sans" && FONT="DejaVu-Sans" || FONT=""
fi
FONT_ARG=${FONT:+-font "$FONT"}
Split the hook into Line 1 and Line 2, then produce an overlay that fully covers the original text zone with the matching background color and text color:
Text is centered both horizontally and vertically within the detected text zone. Offsets are computed from TEXT_ZONE_H — no hardcoded values:
LINE1_Y=$(( TEXT_ZONE_H / 2 - 40 ))
LINE2_Y=$(( TEXT_ZONE_H / 2 + 40 ))
magick -size ${VIDEO_W}x${TEXT_ZONE_H} xc:${HOOK_BG} \
$FONT_ARG \
-pointsize 48 \
-fill ${HOOK_FG} \
-draw "gravity North text 0,${LINE1_Y} '{{LINE_1}}'" \
-draw "gravity North text 0,${LINE2_Y} '{{LINE_2}}'" \
"$WORK_DIR/hook_overlay.png"
Read the PNG to verify text is centered within the zone and fully covers the original text before continuing.
Step 8 — Generate CTA Frame PNG
Use black background with white text (matches the style of the hook zone). Place each line with -draw text at explicit vertical offsets centered in the frame:
magick -size ${VIDEO_W}x${VIDEO_H} xc:black \
$FONT_ARG \
-pointsize 54 \
-fill white \
-draw "gravity Center text 0,-50 '{{CTA_LINE_1}}'" \
-draw "gravity Center text 0,50 '{{CTA_LINE_2}}'" \
"$WORK_DIR/cta_frame.png"
For 3-line CTAs add a third -draw at text 0,150. Read the PNG to verify text is centered before continuing.
Step 9 — Extract Original Audio
ffmpeg -i "$WORK_DIR/original.mp4" \
-vn -c:a copy \
"$WORK_DIR/audio.aac" -y
Step 10 — Build Full Remixed Video (no audio)
Overlay the hook PNG on the full video — do not trim any content:
ffmpeg -i "$WORK_DIR/original.mp4" \
-i "$WORK_DIR/hook_overlay.png" \
-filter_complex "[0:v][1:v]overlay=0:0" \
-an -c:v libx264 -preset fast \
"$WORK_DIR/remixed_full.mp4" -y
Step 11 — Build Silent CTA Clip
CTA_DUR=3
ffmpeg -loop 1 -i "$WORK_DIR/cta_frame.png" \
-t ${CTA_DUR} -r 30 -an \
-c:v libx264 -preset fast -pix_fmt yuv420p \
"$WORK_DIR/cta_silent.mp4" -y
Step 12 — Concatenate + Mux Final Output
Full video plays completely, then CTA is appended. Audio is looped to cover the full duration (original + CTA), so the reel sounds continuous throughout.
cat > "$WORK_DIR/concat.txt" << EOF
file '$WORK_DIR/remixed_full.mp4'
file '$WORK_DIR/cta_silent.mp4'
EOF
ffmpeg -f concat -safe 0 -i "$WORK_DIR/concat.txt" \
-c:v libx264 -preset fast \
"$WORK_DIR/video_only.mp4" -y
TOTAL_DUR=$(ffprobe -v quiet -show_entries format=duration -of csv=p=0 "$WORK_DIR/video_only.mp4")
ffmpeg -stream_loop -1 -i "$WORK_DIR/audio.aac" \
-t "$TOTAL_DUR" \
-c:a aac \
"$WORK_DIR/audio_looped.m4a" -y
OUTPUT_DIR="$(pwd)/video-output/${FOLDER}"
mkdir -p "$OUTPUT_DIR"
ffmpeg -i "$WORK_DIR/video_only.mp4" \
-i "$WORK_DIR/audio_looped.m4a" \
-c:v copy -c:a copy -shortest \
"$OUTPUT_DIR/${FILENAME}" -y
Verify:
ffprobe -v quiet \
-show_entries format=duration,size \
-show_entries stream=codec_name,width,height,duration \
-of default "$OUTPUT_DIR/${FILENAME}"
Confirm: duration ≈ AUDIO_DUR + 3s (CTA appended), both video and audio streams match, h264 + aac.
Report the final output path to the user.
Key Principles
- Audio covers the full output — loop the original audio to fill video + CTA duration so the reel is never silent
- PNG overlay only — ImageMagick overlays work regardless of FFmpeg build (drawtext requires libfreetype which may be absent)
- Intermediate files are silent — no audio until the final mux step
- One confirmation only — do not ask the user anything else unless there is an actual error
- Working directory — all intermediate files go into
$(pwd)/reel-remix-work/; never use /tmp
- Output path —
$(pwd)/video-output/{MM-DD-YY}-{topic}/{3-4-word-seo-keyword-filename}.mp4