Communitygithub.com

reel-captions-from-ae-presets

Build animated reel captions for Premiere sequences from the user's After Effects text-animation presets (.aep), timed to speech, centred and safe-zone aware.

What is reel-captions-from-ae-presets?

reel-captions-from-ae-presets is a Claude Code agent skill that build animated reel captions for Premiere sequences from the user's After Effects text-animation presets (.aep), timed to speech, centred and safe-zone aware.

Works with~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/ibrahimgerges1/reel-captions-skill/tree/HEAD/reel-captions-from-ae-presets

Ask in your favorite AI

Open a new chat with this agent skill pre-loaded.

Documentation

Reel captions from After Effects presets

Use this when the user gives a Premiere project (.prproj) and/or reel audio plus an After Effects file of caption/hook text presets, and wants captions on vertical reels (TikTok / Instagram / Shorts). The deliverable is a new AEP: a copy of their preset file with one Reel N Captions comp per reel (1080x1920, sequence fps, transparent), built from duplicates of their presets. Never modify the original preset comps. Also deliver a fallback ExtendScript (.jsx) that builds the same thing inside After Effects.

Reply in the user's language.

1. Read the inputs

Premiere (.prproj) is gzipped XML. gunzip -c, then parse with ElementTree, resolving ObjectRef→ObjectID and ObjectURef→ObjectUID.

  • Sequences: <Sequence ObjectUID> with <Name>; Node/Properties/MZ.InPoint / MZ.OutPoint (ticks; 254016000000 per second; -400000 = no In point → use the whole sequence).
  • Frame size/rate: VideoTrackGroup FrameRect (e.g. 0,0,1080,1920) and TrackGroup/FrameRate in ticks per frame (8475667200 = 29.97).
  • Clips: TrackGroups → Tracks → ClipTrack/ClipItems/TrackItems/TrackItem → ClipTrackItem/TrackItem/Start|End (Start missing = 0) → SubClip → Clip (inner Clip, or AudioClip/Clip for RemixClip) InPoint/OutPoint. Some track groups have no Tracks — skip them.
  • Work out which source clip is the talking head between In and Out, and where the end card starts (captions must stop there).
  • "From in to out" = In point to Out point.

Media: the project only links to footage on the user's machine. If you can read the project's media folder (local file access, or a folder-access tool in hosted environments), use it; otherwise ask the user to export one audio file per reel (In→Out) and ideally one still frame per reel (to check the face position). Never guess the transcript.

Presets (.aep): pip install aep-parser (installs py_aep; import py_aep). py_aep.parse(path) → app.project.compositions. Inspect every comp: layers, text (layer.text.source_text.value → .text .font .font_size .fill_color), CONTROLS effects (sliders), and expressions. If the user uploads a new version, diff it against the previous one so you know exactly what changed.

Expected preset layout

The skill works with any hook/caption preset family built like this (names are examples — adapt to the user's file):

  • A CONTROLS null with sliders: Start Delay (f), Word Delay (f), Pop Duration (f), Overshoot, Keyword Gap (f), Keyword Start (f) (an expression counting the LINE 1 words), an optional Keyword Flicker checkbox, and label/gradient colours.
  • LINE 1: the normal line (e.g. Montserrat Bold 72) with a word-by-word pop animator.
  • KEYWORD: the emphasis line underneath (larger, e.g. 84–104 px).
  • Optional KEYWORD LABEL shape (a box behind the keyword).
  • A TEXT BLOCK (move me) null that positions the whole block (e.g. at 540,1040), and a guide background layer.
  • Optionally a static CAPTION_Regular comp.

All animation should be expression-driven, so changing the text re-times automatically. Example of a family that works well: four hook styles — a glow style (lowercase keyword), a navy label, a gradient label, an outline pop — plus a regular caption. Note which styles are readable on video (light-mode styles usually are not) and ask the user which to use if unclear.

2. Transcribe

pip install faster-whisper (add --break-system-packages where the system Python requires it). The bundled PyAV may reject metadata_errors; decode with ffmpeg instead:

b = subprocess.run(['ffmpeg','-v','error','-i',p,'-ac','1','-ar','16000','-f','f32le','-'],capture_output=True).stdout
audio = np.frombuffer(b, np.float32)
segs,_ = WhisperModel('small.en',device='cpu',compute_type='int8').transcribe(audio, language='en', word_timestamps=True, beam_size=5)

Use a multilingual model (e.g. small) and the right language for non-English reels. Merge continuation tokens (no leading space: $2+,000, a+.m., pre+-scheduled) and join 80 year old → 80-year-old.

3. Write the caption script (by hand, per reel)

Rules that work well for talking-head reels:

  • Complete, declarative sentences — no missing words. Every spoken word appears in order. Only drop fillers: so, and, then, like, I mean, you know, cause, hey, stutters ("just just"). Tiny grammar fixes are allowed ("There is grants" → "THERE ARE GRANTS") — mention them to the user.
  • One or two lines per caption depending on the speech: LINE 1 = normal line (UPPERCASE), KEYWORD = emphasis line underneath (case as in the preset sample). Short phrases may be a single line (LINE 1 only, or KEYWORD only).
  • Use the hook presets for every caption (consistent look) — don't mix static regular lines with animated hooks. Pick one base style plus an alternate; use label styles for money, offers, urgency and calls to action. Never leave KEYWORD empty on a label style (the empty box would show) — use a non-label style for LINE-1-only captions, and disable KEYWORD LABEL if KEYWORD is empty.
  • Width limit 840 px per line (centred → x 120–960, clear of the TikTok/IG right-rail buttons). Measure with the real fonts: find the font files (system fonts folder, or download the family, e.g. Montserrat from Google Fonts), make static instances of variable fonts with fonttools varLib.instancer ... wght=700 (Bold) etc., then PIL.ImageFont.getlength; apply the preset's tracking (e.g. KEYWORD −10). Rough capacity at the sizes above: LINE 1 ≈ 17 chars, KEYWORD ≈ 13–15 chars.

Format: one caption per line preset | LINE 1 | KEYWORD (number the user's styles, e.g. 1 = glow, 3 = navy label…). Align each caption word to transcript tokens in order; allow skipping only filler tokens and inserting only tiny words (an, the, are); error if a real spoken word would be skipped — that guarantees completeness.

4. Timing (per caption)

  • start = first spoken word − 4 frames (so the first LINE 1 word pops as it's spoken); KEYWORD-only caption: start = keyword time − (4 + 9·0.6)/30. Keep ≥ 0.4 s between starts. Snap to the sequence fps.
  • end = next caption start (if the pause is < 0.9 s) else last word + 0.5 s; the last caption ends at last word + 0.7 s, capped at the end-card start.
  • Make the keyword land on its spoken word but stay readable: target = min(t_kw, end − 0.45), ks = (target − start)·30 frames. Set the copy's CONTROLS: Word Delay (f) = clamp((ks − 9.4 − 1)/(n−1), 2, 10) and Keyword Gap (f) = clamp(ks − 9.4 − (n−1)·WordDelay, 0, 30) where n = LINE 1 word count. For LINE-1-only captions spread the words until end − 0.35 s. (The constants assume Start Delay 4 f and Pop Duration 9 f — recompute from the user's CONTROLS if different.)
  • Print a check table (start, end, keyword pop vs spoken, widths) and fix any caption shorter than ~0.5 s or with the keyword visible < 0.35 s by re-splitting the text.

5. Build the AEP with py_aep

app = py_aep.parse(SRC); p = app.project; C = {c.name: c for c in p.compositions}
root = p.root_folder.add_folder('REEL CAPTIONS')
rc = root.add_comp('Reel 1 Captions', 1080, 1920, 1.0, dur, 30000/1001)
d = C[preset].duplicate(); d.name = ...; d.parent_folder = parts_folder; d.frame_rate = 30000/1001
st = L['LINE 1'].text.source_text; v = st.value; v.text = '...'; st.value = v
list(effect.properties)[0].value = 4.0          # CONTROLS slider
L['LINE 1'].transform.position.expression = L1_POS
ly = rc.add(d); ly.start_time = s; ly.in_point = s; ly.out_point = min(e, s + d.duration)
p.save(OUT)   # fails if OUT exists — delete it first

Positions take 3 values ([540, 960, 0]). In the copies only:

  • Set the comp frame rate to the sequence fps (a 30 fps comp nested in 29.97 looks jittery).
  • Turn off keyword flicker if the user doesn't want it (flicker usually lives in KEYWORD Opacity, not Scale).
  • Replace a left-aligned block layout with centred lines and vertical centring for single-line captions:
// LINE 1 Position
var KW = thisComp.layer("KEYWORD");
var a  = sourceRectAtTime(outPoint - thisComp.frameDuration, false);
var kwEmpty = String(KW.text.sourceText).replace(/\s/g, "").length == 0;
[-(a.left + a.width / 2), kwEmpty ? 55 : value[1]];
// KEYWORD Position
function popEase(p, s) { p = Math.min(Math.max(p, 0), 1); var q = p - 1; return q * q * ((s + 1) * q + s) + 1; }
var c = thisComp.layer("CONTROLS"), fd = thisComp.frameDuration;
var b = sourceRectAtTime(outPoint - fd, false);
var l1Empty = String(thisComp.layer("LINE 1").text.sourceText).replace(/\s/g, "").length == 0;
var st = c.effect("Keyword Start (f)")(1) * fd;
var d  = Math.max(1, c.effect("Keyword Pop (f)")(1)) * fd;
var e  = popEase((time - inPoint - st) / d, c.effect("Overshoot")(1));
var rise = c.effect("Keyword Rise (px)")(1) * (1 - e);
[0, (l1Empty ? 30 : value[1] + b.top + b.height / 2) + rise];

Adjust effect names to the user's CONTROLS. Keep the TEXT BLOCK at the preset position (block centre ≈ y 1070 — centre, slightly low, under the face). Caption layers in the reel comp sit at the default comp centre.

6. Verify before delivering

  • Re-parse the output: every original preset comp must be identical to the input (walk all properties, values, expressions, layer in/out) — report "presets unchanged".
  • Check that a duplicate keeps all preset expressions and has the new text, controls and frame rate.
  • Simulate the new position expressions in Node with a mocked thisComp / sourceRectAtTime to confirm the centring maths.
  • node -e "new Function(src)" to syntax-check the fallback JSX.
  • State clearly that the AEP was built without opening After Effects.

7. Fallback JSX

Generate an ExtendScript that, with the user's preset AEP open, does the same: findComp(name).duplicate(), set text via property("ADBE Text Properties").property("ADBE Text Document") getValue→.text→setValue, set the two position expressions, set CONTROLS sliders via layer("CONTROLS").property("ADBE Effect Parade").property(name).property(1).setValue(v), frameRate, rc.layers.add(d) with startTime/inPoint/outPoint, inside app.beginUndoGroup. Embed the caption data as JSON.

8. Deliver

Save the AEP and JSX next to the user's project (or the environment's outputs folder) and share them. In the reply: Premiere steps (File › Import the AEP, pick Reel N Captions, put it on the top track at the reel's In point), what changed, word fixes, any very short captions in fast speech, and how to nudge the whole block (Y Position of the layers in each Reel Captions comp). Keep it short.

Related Skills