Skip to content

51 free video effects for Claude Code: drop in a talking-head clip, type /effects orbit. Face tracking, behind-your-head layers. From Hop Studio by @vibha.in.progress

22 starter video effects skill for Claude

Vibha-Ramprakash3183ca255f94
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..b63d8e7
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,4 @@
+.venv/
+__pycache__/
+*.pyc
+.DS_Store
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..8a03976
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,24 @@
+MIT License
+
+Copyright (c) 2026 Vibha Ramprakash
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+
+The fonts in fonts/ and the models in models/ keep their own licences
+(see README.md, fonts/*.txt and models/NOTICE.md).
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..0d5f638
--- /dev/null
+++ b/README.md
@@ -0,0 +1,84 @@
+# 22 Video Effects for Claude
+
+Drop your video into Claude, type `/effects` and the name of an effect. That's the whole edit.
+
+Made by [@vibha.in.progress](https://instagram.com/vibha.in.progress) 💛
+
+![All 22 effects](assets/preview.jpg)
+
+## Install (one line)
+
+Open the Terminal app (or the terminal inside Claude Code) and paste:
+
+```bash
+git clone https://github.com/Vibha-Ramprakash/claude-video-effects ~/.claude/skills/effects
+```
+
+Then restart Claude Code. That's it.
+
+> Not sure how? Open Claude Code and paste: **"Install the skill from github.com/Vibha-Ramprakash/claude-video-effects into ~/.claude/skills/effects"**. Claude will do it for you.
+
+## Use it
+
+1. Open Claude Code (the app or the terminal).
+2. Drag your video into the chat.
+3. Type the effect you want:
+
+```
+/effects orbit from 3 to 6 seconds
+/effects spotlight when I say "kill the lights", with the word Claudit behind me
+/effects comment-box at the end, typing EFFECTS
+```
+
+The very first time, Claude sets itself up (about 2 minutes). It needs `ffmpeg` and Python, and it installs them for you if they're missing.
+
+Claude checks a few frames first, fixes anything that covers your face, then renders `yourvideo_effects.mp4` right next to your original. Your audio stays as it was.
+
+You can stack effects in one go: *"Add locked-on from 6 to 10s, then orbit from 10 to 13s, then a reject stamp on 'no'."*
+
+## The 22 effects
+
+| # | Type this | What happens |
+|---|---|---|
+| 1 | `noise` | Reels pile up behind your head |
+| 2 | `lineup` | Numbered tiles fan out above your head |
+| 3 | `locked-on` | Brackets lock onto your face and the camera follows you |
+| 4 | `orbit` | Your reels circle your head, behind you at the top |
+| 5 | `lean-in` | A quick punch-in on one word |
+| 6 | `backdrop-word` | A giant word drops in behind you |
+| 7 | `spotlight` | Kill the lights, keep you lit |
+| 8 | `the-bill` | Your instructions print out like a receipt |
+| 9 | `moody` | A moody colour grade |
+| 10 | `swipe` | A before and after slider |
+| 11 | `todo` | A checklist beside your head that ticks off as you talk |
+| 12 | `comment-box` | An Instagram comment types itself and posts |
+| 13 | `tap` | A Follow button flips to Following |
+| 14 | `pause-point` | Freeze frame with a hand-drawn arrow |
+| 15 | `uninstall` | A glitchy uninstall bar breaks the frame |
+| 16 | `reel-frame` | Your video shrinks into a reel card |
+| 17 | `shortcut-rain` | Keyboard keys rain down behind you |
+| 18 | `reject-stamp` | A big red stamp slams down |
+| 19 | `countdown-flip` | A 3, 2, 1 flip clock above your head |
+| 20 | `rabbit-hole` | The room tunnels away behind you |
+| 21 | `cover-star` | You become a magazine cover |
+| 22 | `scribble` | Marker doodles draw themselves around you |
+
+Every effect follows your face. Anything that would cover your face goes behind your head instead.
+
+**Tips**
+- Vertical phone videos with you in frame work best.
+- Say the timing in plain words ("when I say 'watch'"). Claude finds the exact second.
+- Want your own reels in `orbit` or `noise`? Give Claude a folder of screenshots.
+- It renders in 1080p. Ask for 4K if you want it (slower).
+
+## Honest notes
+- These are **starter versions**. They won't match the exact edit in my reel, which also has sound design and hand-tuned timing.
+- It drafts, you approve. Watch the result before you post.
+- No sounds or captions are added. Add those in CapCut.
+- My full edit style is coming later. Follow [@vibha.in.progress](https://instagram.com/vibha.in.progress) to hear first.
+
+## If something goes wrong
+Just tell Claude what you see ("the word covers my face", "it's too fast"). It will fix the plan and render again.
+
+## Credits
+Face tracking: [OpenCV YuNet](https://github.com/opencv/opencv_zoo) (MIT). Person cut-out: [MediaPipe Selfie Segmenter](https://ai.google.dev/edge/mediapipe/solutions/vision/image_segmenter) (Apache 2.0). Fonts: Archivo Black, Instrument Serif, Space Mono, Inter (SIL OFL) and Permanent Marker (Apache 2.0); licences are in `fonts/`. Everything else: MIT, see `LICENSE`.
diff --git a/SKILL.md b/SKILL.md
new file mode 100644
index 0000000..65495f8
--- /dev/null
+++ b/SKILL.md
@@ -0,0 +1,74 @@
+---
+name: effects
+description: Add any of 22 video effects to a talking-head video (orbit, spotlight, the bill, lean-in, swipe, backdrop word, comment box and more). Effects track the speaker's face and can sit behind their head. Use when the user types /effects, names one of the effects, or asks to add an effect, zoom, grade, sticker or animation to their video.
+---
+
+# Effects: 22 starter video effects (by @vibha.in.progress)
+
+The user is usually not technical. Keep replies short and friendly, do the work for them, and never ask them to run commands themselves.
+
+All paths below are relative to this skill's folder (the folder this SKILL.md is in). Use its absolute path in commands.
+
+## 1. First run: set up (once)
+Run `bash scripts/setup.sh`. It prints `READY` when done (the first time takes 1 to 3 minutes).
+- `NEED_FFMPEG`: install it for them. On a Mac: `brew install ffmpeg` (if `brew` is missing, tell them to install Homebrew from brew.sh first). On Windows: `winget install ffmpeg`.
+- `NEED_PYTHON`: install Python 3.12 (Mac: `brew install [email protected]`, Windows: `winget install Python.Python.3.12`), then run setup again.
+- On Windows, the Python is at `.venv\Scripts\python.exe` instead of `.venv/bin/python`.
+
+## 2. Get the video and the effect
+- Video: the user drags the file into the chat, or gives a path. A vertical phone video works best.
+- Effect: from `/effects <name>`, or from what they describe. Match their words to the table below. Unsure? Show them the list.
+
+## 3. Find the timing
+- If they say "on the word X" or "when I say ...", run `.venv/bin/python scripts/words.py <video>` and use those times.
+- If they give no timing, apply the effect for the whole clip, or ask which part (one short question).
+- Short windows look best: 1.5 to 4 seconds per effect.
+
+## 4. Draft, check, render
+1. Write the plan next to their video as `<video-name>_effects.json`:
+ ```json
+ {"effects": [
+ {"fx": "orbit", "start": 3.2, "end": 6.0},
+ {"fx": "backdrop-word", "start": 14.0, "end": 16.3, "text": "CLAUDE"}
+ ]}
+ ```
+2. Check frames first (fast): `.venv/bin/python scripts/fx.py --plan <plan.json> <video> <folder>/check.png --still 4.5,15.2`, using the middle of each effect. Look at the PNGs yourself. Fix the text, timing or options if something looks off (covers the face, cut off by the edge, unreadable).
+3. Render: `.venv/bin/python scripts/fx.py --plan <plan.json> <video> <video-name>_effects.mp4`. The output keeps their original audio. It renders at 1080p by default; add `--width 2160` for 4K (slower).
+4. Tell them where the file is. Remind them in one line to watch it before posting: it drafts, they approve.
+
+A single effect needs no plan: `.venv/bin/python scripts/fx.py orbit <video> <out.mp4> --start 3 --end 6 --text "..." --opt key=value`.
+
+## The 22 effects
+| # | `fx` name | What it does | Options (all optional) |
+|---|---|---|---|
+| 1 | `noise` | Reels pile up behind your head, one every quarter second | `images` (folder of screenshots or clips), `size` |
+| 2 | `lineup` | Numbered tiles fan out in an arc above your head | `text` (tile names joined with `\|`) |
+| 3 | `locked-on` | Corner brackets snap onto your face, the camera follows you | `zoom` (default 1.35), `text` (tag) |
+| 4 | `orbit` | Your reels circle your head: in front at the bottom, behind at the top | `images`, `count`, `speed`, `size` |
+| 5 | `lean-in` | A fast punch-in on one word | `zoom` (default 1.45, max 2), `speed` |
+| 6 | `backdrop-word` | A giant word drops in behind you | `text`, `color` (hex), `font` (`bold` or `serif`) |
+| 7 | `spotlight` | Kills the lights, keeps you lit | `text` (glowing word behind you), `color`, `push` |
+| 8 | `the-bill` | Prints your instructions like a receipt into the wall above your head | `text` (lines joined with `\|`) |
+| 9 | `moody` | A moody colour grade | `grade` (`moody`, `bw`, `warm`, `cool`, `pop`) |
+| 10 | `swipe` | A before and after slider sweeps across you | `grade` (the "after" look) |
+| 11 | `todo` | A checklist card beside your head ticks off as you talk | `text` (items with `\|`), `ticks` (video seconds with `\|`), `title` |
+| 12 | `comment-box` | An Instagram comment bar types a word and posts it | `text` (default EFFECTS) |
+| 13 | `tap` | A Follow button pops up and flips to Following | `at` (video second of the flip), `x`, `y` (0 to 1), `color` |
+| 14 | `pause-point` | Freezes the frame and points at you with a hand-drawn arrow | `text` (label), `color`, `label_x` |
+| 15 | `uninstall` | A glitchy uninstall bar breaks the frame apart | `text` |
+| 16 | `reel-frame` | Your video shrinks into an Instagram reel card | `text` (handle) |
+| 17 | `shortcut-rain` | Keyboard keys rain down behind you | `text` (keys with `\|`), `count` |
+| 18 | `reject-stamp` | A big red stamp slams onto the screen | `text`, `color`, `angle`, `y` |
+| 19 | `countdown-flip` | A 3, 2, 1 flip clock above your head | `from` |
+| 20 | `rabbit-hole` | The frame tunnels into itself, spinning | `ratio`, `speed`, `spin` |
+| 21 | `cover-star` | You become a magazine cover, title behind your head | `text` (title), `lines` (with `\|`), `issue`, `color` |
+| 22 | `scribble` | Marker doodles draw themselves around you | `text` (label), `color` |
+
+Aliases work too: `bill`, `to-do`, `follow`, `stamp`, `countdown`, `cover`, `rain`, `pause`.
+
+## Rules
+- Never cover the face. Everything either goes behind the person or avoids the face by itself; if a check frame still shows text over the face, move it (`x`, `y`) or shorten the text.
+- Effects run in the order listed. Put camera effects (`locked-on`, `lean-in`, `spotlight`) first when they overlap others.
+- Zoom never goes past 2x, so the video stays sharp.
+- This skill adds visuals only. Sound effects and captions are up to the user (CapCut works well).
+- These are starter versions. Be honest about that if the user compares them to a reel they saw.
diff --git a/assets/preview.jpg b/assets/preview.jpg
new file mode 100644
index 0000000..1b111ca
Binary files /dev/null and b/assets/preview.jpg differ
diff --git a/fonts/ArchivoBlack-Regular.ttf b/fonts/ArchivoBlack-Regular.ttf
new file mode 100644
index 0000000..82d07de
Binary files /dev/null and b/fonts/ArchivoBlack-Regular.ttf differ
diff --git a/fonts/InstrumentSerif-Italic.ttf b/fonts/InstrumentSerif-Italic.ttf
new file mode 100644
index 0000000..192c3ed
Binary files /dev/null and b/fonts/InstrumentSerif-Italic.ttf differ
diff --git a/fonts/Inter.ttf b/fonts/Inter.ttf
new file mode 100644
index 0000000..047c92f
Binary files /dev/null and b/fonts/Inter.ttf differ
diff --git a/fonts/LICENSE-PermanentMarker.txt b/fonts/LICENSE-PermanentMarker.txt
new file mode 100644
index 0000000..d645695
--- /dev/null
+++ b/fonts/LICENSE-PermanentMarker.txt
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/fonts/OFL-ArchivoBlack.txt b/fonts/OFL-ArchivoBlack.txt
new file mode 100644
index 0000000..8894736
--- /dev/null
+++ b/fonts/OFL-ArchivoBlack.txt
@@ -0,0 +1,93 @@
+Copyright 2017 The Archivo Black Project Authors (https://github.com/Omnibus-Type/ArchivoBlack)
+
+This Font Software is licensed under the SIL Open Font License, Version 1.1.
+This license is copied below, and is also available with a FAQ at:
+http://scripts.sil.org/OFL
+
+
+-----------------------------------------------------------
+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
+-----------------------------------------------------------
+
+PREAMBLE
+The goals of the Open Font License (OFL) are to stimulate worldwide
+development of collaborative font projects, to support the font creation
+efforts of academic and linguistic communities, and to provide a free and
+open framework in which fonts may be shared and improved in partnership
+with others.
+
+The OFL allows the licensed fonts to be used, studied, modified and
+redistributed freely as long as they are not sold by themselves. The
+fonts, including any derivative works, can be bundled, embedded,
+redistributed and/or sold with any software provided that any reserved
+names are not used by derivative works. The fonts and derivatives,
+however, cannot be released under any other type of license. The
+requirement for fonts to remain under this license does not apply
+to any document created using the fonts or their derivatives.
+
+DEFINITIONS
+"Font Software" refers to the set of files released by the Copyright
+Holder(s) under this license and clearly marked as such. This may
+include source files, build scripts and documentation.
+
+"Reserved Font Name" refers to any names specified as such after the
+copyright statement(s).
+
+"Original Version" refers to the collection of Font Software components as
+distributed by the Copyright Holder(s).
+
+"Modified Version" refers to any derivative made by adding to, deleting,
+or substituting -- in part or in whole -- any of the components of the
+Original Version, by changing formats or by porting the Font Software to a
+new environment.
+
+"Author" refers to any designer, engineer, programmer, technical
+writer or other person who contributed to the Font Software.
+
+PERMISSION & CONDITIONS
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of the Font Software, to use, study, copy, merge, embed, modify,
+redistribute, and sell modified and unmodified copies of the Font
+Software, subject to the following conditions:
+
+1) Neither the Font Software nor any of its individual components,
+in Original or Modified Versions, may be sold by itself.
+
+2) Original or Modified Versions of the Font Software may be bundled,
+redistributed and/or sold with any software, provided that each copy
+contains the above copyright notice and this license. These can be
+included either as stand-alone text files, human-readable headers or
+in the appropriate machine-readable metadata fields within text or
+binary files as long as those fields can be easily viewed by the user.
+
+3) No Modified Version of the Font Software may use the Reserved Font
+Name(s) unless explicit written permission is granted by the corresponding
+Copyright Holder. This restriction only applies to the primary font name as
+presented to the users.
+
+4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
+Software shall not be used to promote, endorse or advertise any
+Modified Version, except to acknowledge the contribution(s) of the
+Copyright Holder(s) and the Author(s) or with their explicit written
+permission.
+
+5) The Font Software, modified or unmodified, in part or in whole,
+must be distributed entirely under this license, and must not be
+distributed under any other license. The requirement for fonts to
+remain under this license does not apply to any document created
+using the Font Software.
+
+TERMINATION
+This license becomes null and void if any of the above conditions are
+not met.
+
+DISCLAIMER
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
+OTHER DEALINGS IN THE FONT SOFTWARE.
diff --git a/fonts/OFL-InstrumentSerif.txt b/fonts/OFL-InstrumentSerif.txt
new file mode 100644
index 0000000..669ce79
--- /dev/null
+++ b/fonts/OFL-InstrumentSerif.txt
@@ -0,0 +1,93 @@
+Copyright 2022 The Instrument Serif Project Authors (https://github.com/Instrument/instrument-serif)
+
+This Font Software is licensed under the SIL Open Font License, Version 1.1.
+This license is copied below, and is also available with a FAQ at:
+https://scripts.sil.org/OFL
+
+
+-----------------------------------------------------------
+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
+-----------------------------------------------------------
+
+PREAMBLE
+The goals of the Open Font License (OFL) are to stimulate worldwide
+development of collaborative font projects, to support the font creation
+efforts of academic and linguistic communities, and to provide a free and
+open framework in which fonts may be shared and improved in partnership
+with others.
+
+The OFL allows the licensed fonts to be used, studied, modified and
+redistributed freely as long as they are not sold by themselves. The
+fonts, including any derivative works, can be bundled, embedded,
+redistributed and/or sold with any software provided that any reserved
+names are not used by derivative works. The fonts and derivatives,
+however, cannot be released under any other type of license. The
+requirement for fonts to remain under this license does not apply
+to any document created using the fonts or their derivatives.
+
+DEFINITIONS
+"Font Software" refers to the set of files released by the Copyright
+Holder(s) under this license and clearly marked as such. This may
+include source files, build scripts and documentation.
+
+"Reserved Font Name" refers to any names specified as such after the
+copyright statement(s).
+
+"Original Version" refers to the collection of Font Software components as
+distributed by the Copyright Holder(s).
+
+"Modified Version" refers to any derivative made by adding to, deleting,
+or substituting -- in part or in whole -- any of the components of the
+Original Version, by changing formats or by porting the Font Software to a
+new environment.
+
+"Author" refers to any designer, engineer, programmer, technical
+writer or other person who contributed to the Font Software.
+
+PERMISSION & CONDITIONS
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of the Font Software, to use, study, copy, merge, embed, modify,
+redistribute, and sell modified and unmodified copies of the Font
+Software, subject to the following conditions:
+
+1) Neither the Font Software nor any of its individual components,
+in Original or Modified Versions, may be sold by itself.
+
+2) Original or Modified Versions of the Font Software may be bundled,
+redistributed and/or sold with any software, provided that each copy
+contains the above copyright notice and this license. These can be
+included either as stand-alone text files, human-readable headers or
+in the appropriate machine-readable metadata fields within text or
+binary files as long as those fields can be easily viewed by the user.
+
+3) No Modified Version of the Font Software may use the Reserved Font
+Name(s) unless explicit written permission is granted by the corresponding
+Copyright Holder. This restriction only applies to the primary font name as
+presented to the users.
+
+4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
+Software shall not be used to promote, endorse or advertise any
+Modified Version, except to acknowledge the contribution(s) of the
+Copyright Holder(s) and the Author(s) or with their explicit written
+permission.
+
+5) The Font Software, modified or unmodified, in part or in whole,
+must be distributed entirely under this license, and must not be
+distributed under any other license. The requirement for fonts to
+remain under this license does not apply to any document created
+using the Font Software.
+
+TERMINATION
+This license becomes null and void if any of the above conditions are
+not met.
+
+DISCLAIMER
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
+OTHER DEALINGS IN THE FONT SOFTWARE.
diff --git a/fonts/OFL-Inter.txt b/fonts/OFL-Inter.txt
new file mode 100644
index 0000000..21f6aff
--- /dev/null
+++ b/fonts/OFL-Inter.txt
@@ -0,0 +1,93 @@
+Copyright 2020 The Inter Project Authors (https://github.com/rsms/inter)
+
+This Font Software is licensed under the SIL Open Font License, Version 1.1.
+This license is copied below, and is also available with a FAQ at:
+https://scripts.sil.org/OFL
+
+
+-----------------------------------------------------------
+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
+-----------------------------------------------------------
+
+PREAMBLE
+The goals of the Open Font License (OFL) are to stimulate worldwide
+development of collaborative font projects, to support the font creation
+efforts of academic and linguistic communities, and to provide a free and
+open framework in which fonts may be shared and improved in partnership
+with others.
+
+The OFL allows the licensed fonts to be used, studied, modified and
+redistributed freely as long as they are not sold by themselves. The
+fonts, including any derivative works, can be bundled, embedded,
+redistributed and/or sold with any software provided that any reserved
+names are not used by derivative works. The fonts and derivatives,
+however, cannot be released under any other type of license. The
+requirement for fonts to remain under this license does not apply
+to any document created using the fonts or their derivatives.
+
+DEFINITIONS
+"Font Software" refers to the set of files released by the Copyright
+Holder(s) under this license and clearly marked as such. This may
+include source files, build scripts and documentation.
+
+"Reserved Font Name" refers to any names specified as such after the
+copyright statement(s).
+
+"Original Version" refers to the collection of Font Software components as
+distributed by the Copyright Holder(s).
+
+"Modified Version" refers to any derivative made by adding to, deleting,
+or substituting -- in part or in whole -- any of the components of the
+Original Version, by changing formats or by porting the Font Software to a
+new environment.
+
+"Author" refers to any designer, engineer, programmer, technical
+writer or other person who contributed to the Font Software.
+
+PERMISSION & CONDITIONS
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of the Font Software, to use, study, copy, merge, embed, modify,
+redistribute, and sell modified and unmodified copies of the Font
+Software, subject to the following conditions:
+
+1) Neither the Font Software nor any of its individual components,
+in Original or Modified Versions, may be sold by itself.
+
+2) Original or Modified Versions of the Font Software may be bundled,
+redistributed and/or sold with any software, provided that each copy
+contains the above copyright notice and this license. These can be
+included either as stand-alone text files, human-readable headers or
+in the appropriate machine-readable metadata fields within text or
+binary files as long as those fields can be easily viewed by the user.
+
+3) No Modified Version of the Font Software may use the Reserved Font
+Name(s) unless explicit written permission is granted by the corresponding
+Copyright Holder. This restriction only applies to the primary font name as
+presented to the users.
+
+4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
+Software shall not be used to promote, endorse or advertise any
+Modified Version, except to acknowledge the contribution(s) of the
+Copyright Holder(s) and the Author(s) or with their explicit written
+permission.
+
+5) The Font Software, modified or unmodified, in part or in whole,
+must be distributed entirely under this license, and must not be
+distributed under any other license. The requirement for fonts to
+remain under this license does not apply to any document created
+using the Font Software.
+
+TERMINATION
+This license becomes null and void if any of the above conditions are
+not met.
+
+DISCLAIMER
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
+OTHER DEALINGS IN THE FONT SOFTWARE.
diff --git a/fonts/OFL-SpaceMono.txt b/fonts/OFL-SpaceMono.txt
new file mode 100644
index 0000000..a72b0a7
--- /dev/null
+++ b/fonts/OFL-SpaceMono.txt
@@ -0,0 +1,93 @@
+Copyright 2016 The Space Mono Project Authors (https://github.com/googlefonts/spacemono)
+
+This Font Software is licensed under the SIL Open Font License, Version 1.1.
+This license is copied below, and is also available with a FAQ at:
+http://scripts.sil.org/OFL
+
+
+-----------------------------------------------------------
+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
+-----------------------------------------------------------
+
+PREAMBLE
+The goals of the Open Font License (OFL) are to stimulate worldwide
+development of collaborative font projects, to support the font creation
+efforts of academic and linguistic communities, and to provide a free and
+open framework in which fonts may be shared and improved in partnership
+with others.
+
+The OFL allows the licensed fonts to be used, studied, modified and
+redistributed freely as long as they are not sold by themselves. The
+fonts, including any derivative works, can be bundled, embedded,
+redistributed and/or sold with any software provided that any reserved
+names are not used by derivative works. The fonts and derivatives,
+however, cannot be released under any other type of license. The
+requirement for fonts to remain under this license does not apply
+to any document created using the fonts or their derivatives.
+
+DEFINITIONS
+"Font Software" refers to the set of files released by the Copyright
+Holder(s) under this license and clearly marked as such. This may
+include source files, build scripts and documentation.
+
+"Reserved Font Name" refers to any names specified as such after the
+copyright statement(s).
+
+"Original Version" refers to the collection of Font Software components as
+distributed by the Copyright Holder(s).
+
+"Modified Version" refers to any derivative made by adding to, deleting,
+or substituting -- in part or in whole -- any of the components of the
+Original Version, by changing formats or by porting the Font Software to a
+new environment.
+
+"Author" refers to any designer, engineer, programmer, technical
+writer or other person who contributed to the Font Software.
+
+PERMISSION & CONDITIONS
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of the Font Software, to use, study, copy, merge, embed, modify,
+redistribute, and sell modified and unmodified copies of the Font
+Software, subject to the following conditions:
+
+1) Neither the Font Software nor any of its individual components,
+in Original or Modified Versions, may be sold by itself.
+
+2) Original or Modified Versions of the Font Software may be bundled,
+redistributed and/or sold with any software, provided that each copy
+contains the above copyright notice and this license. These can be
+included either as stand-alone text files, human-readable headers or
+in the appropriate machine-readable metadata fields within text or
+binary files as long as those fields can be easily viewed by the user.
+
+3) No Modified Version of the Font Software may use the Reserved Font
+Name(s) unless explicit written permission is granted by the corresponding
+Copyright Holder. This restriction only applies to the primary font name as
+presented to the users.
+
+4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
+Software shall not be used to promote, endorse or advertise any
+Modified Version, except to acknowledge the contribution(s) of the
+Copyright Holder(s) and the Author(s) or with their explicit written
+permission.
+
+5) The Font Software, modified or unmodified, in part or in whole,
+must be distributed entirely under this license, and must not be
+distributed under any other license. The requirement for fonts to
+remain under this license does not apply to any document created
+using the Font Software.
+
+TERMINATION
+This license becomes null and void if any of the above conditions are
+not met.
+
+DISCLAIMER
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
+OTHER DEALINGS IN THE FONT SOFTWARE.
diff --git a/fonts/PermanentMarker-Regular.ttf b/fonts/PermanentMarker-Regular.ttf
new file mode 100644
index 0000000..3218fc5
Binary files /dev/null and b/fonts/PermanentMarker-Regular.ttf differ
diff --git a/fonts/SpaceMono-Bold.ttf b/fonts/SpaceMono-Bold.ttf
new file mode 100644
index 0000000..2c4f268
Binary files /dev/null and b/fonts/SpaceMono-Bold.ttf differ
diff --git a/models/NOTICE.md b/models/NOTICE.md
new file mode 100644
index 0000000..678dc0c
--- /dev/null
+++ b/models/NOTICE.md
@@ -0,0 +1,4 @@
+# Models
+
+- `yunet.onnx`: YuNet face detector (face_detection_yunet_2023mar) from https://github.com/opencv/opencv_zoo, MIT licence.
+- `selfie_segmenter.tflite`: MediaPipe Selfie Segmenter from https://ai.google.dev/edge/mediapipe/solutions/vision/image_segmenter, Apache License 2.0.
diff --git a/models/selfie_segmenter.tflite b/models/selfie_segmenter.tflite
new file mode 100644
index 0000000..a4ebd47
Binary files /dev/null and b/models/selfie_segmenter.tflite differ
diff --git a/models/yunet.onnx b/models/yunet.onnx
new file mode 100644
index 0000000..f9beb30
Binary files /dev/null and b/models/yunet.onnx differ
diff --git a/requirements.txt b/requirements.txt
new file mode 100644
index 0000000..73b8aaa
--- /dev/null
+++ b/requirements.txt
@@ -0,0 +1,4 @@
+numpy
+opencv-python
+pillow
+mediapipe
diff --git a/scripts/fx.py b/scripts/fx.py
new file mode 100755
index 0000000..bb29991
--- /dev/null
+++ b/scripts/fx.py
@@ -0,0 +1,871 @@
+#!/usr/bin/env python3
+"""22 starter video effects for Claude, by @vibha.in.progress
+
+One effect: python fx.py orbit in.mp4 out.mp4 --start 3.2 --end 6
+Many effects: python fx.py --plan plan.json in.mp4 out.mp4
+Quick check: python fx.py --plan plan.json in.mp4 check.png --still 4.5
+List them: python fx.py --list
+"""
+import argparse, json, math, os, random, subprocess, sys
+import numpy as np
+import cv2
+from PIL import Image, ImageDraw, ImageFont, ImageFilter
+
+ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
+FONT = {k: os.path.join(ROOT, 'fonts', v) for k, v in {
+ 'bold': 'ArchivoBlack-Regular.ttf', 'serif': 'InstrumentSerif-Italic.ttf', 'mono': 'SpaceMono-Bold.ttf',
+ 'hand': 'PermanentMarker-Regular.ttf', 'ui': 'Inter.ttf'}.items()}
+CREAM, INK, PEACH, YELLOW = (244, 233, 216), (22, 22, 24), (255, 183, 165), (255, 214, 10)
+NAMES = ['The Noise', 'The Lineup', 'Locked On', 'Orbit', 'Lean-In', 'Backdrop Word', 'Spotlight', 'The Bill',
+ 'Moody', 'Swipe', 'The To-Do', 'Comment Box', 'The Tap', 'Pause & Point', 'Uninstall', 'Reel Frame',
+ 'Shortcut Rain', 'Reject Stamp', 'Countdown Flip', 'Rabbit Hole', 'Cover Star', 'Scribble']
+EFFECTS = {}
+ALIASES = {'the-noise': 'noise', 'the-lineup': 'lineup', 'bill': 'the-bill', 'to-do': 'todo', 'the-todo': 'todo', 'the-to-do': 'todo',
+ 'the-tap': 'tap', 'follow': 'tap', 'comment': 'comment-box', 'pause': 'pause-point', 'pause-and-point': 'pause-point',
+ 'backdrop': 'backdrop-word', 'stamp': 'reject-stamp', 'countdown': 'countdown-flip', 'cover': 'cover-star', 'rain': 'shortcut-rain'}
+
+
+def effect(name, desc):
+ def deco(fn):
+ EFFECTS[name] = (fn, desc)
+ return fn
+ return deco
+
+
+# ---------- small helpers ----------
+def clamp(x, a=0.0, b=1.0): return max(a, min(b, x))
+def ease_out(x): x = clamp(x); return 1 - (1 - x) ** 3
+def ease_inout(x): x = clamp(x); return 3 * x * x - 2 * x * x * x
+def ease_back(x): x = clamp(x); s = 1.7; x -= 1; return x * x * ((s + 1) * x + s) + 1
+def ramp(c, e, t_in=0.25, t_out=0.2): return clamp(c.lt / t_in) * clamp((e.d - c.lt) / t_out) if t_out else clamp(c.lt / t_in)
+def rgb(v, default):
+ if v is None: return default
+ if isinstance(v, (list, tuple)): return tuple(int(x) for x in v[:3])
+ v = str(v).lstrip('#'); return tuple(int(v[i:i + 2], 16) for i in (0, 2, 4))
+
+
+_fc = {}
+def font(kind, size):
+ k = (kind, int(size))
+ if k not in _fc:
+ f = ImageFont.truetype(FONT[kind], max(6, int(size)))
+ if kind == 'ui':
+ try: f.set_variation_by_axes([24, 640])
+ except Exception: pass
+ _fc[k] = f
+ return _fc[k]
+
+
+def text_img(s, size, kind='bold', fill=(255, 255, 255), stroke=0, stroke_fill=INK, shadow=0, glow=None):
+ f = font(kind, size)
+ bb = f.getbbox(s, stroke_width=stroke)
+ pad = int(size * 0.2 + shadow * 2.5 + (glow[1] * 2.5 if glow else 0)) + 4
+ w, h = bb[2] - bb[0] + 2 * pad, bb[3] - bb[1] + 2 * pad
+ pos = (pad - bb[0], pad - bb[1])
+ im = Image.new('RGBA', (w, h), (0, 0, 0, 0))
+ if shadow:
+ sh = Image.new('RGBA', (w, h), (0, 0, 0, 0))
+ ImageDraw.Draw(sh).text((pos[0], pos[1] + shadow * 0.5), s, font=f, fill=(0, 0, 0, 160), stroke_width=stroke)
+ im = Image.alpha_composite(im, sh.filter(ImageFilter.GaussianBlur(shadow)))
+ if glow:
+ g = Image.new('RGBA', (w, h), (0, 0, 0, 0))
+ ImageDraw.Draw(g).text(pos, s, font=f, fill=tuple(glow[0]) + (255,), stroke_width=int(size * 0.04))
+ g = g.filter(ImageFilter.GaussianBlur(glow[1]))
+ im = Image.alpha_composite(Image.alpha_composite(im, g), g)
+ ImageDraw.Draw(im).text(pos, s, font=f, fill=tuple(fill) + (255,), stroke_width=stroke, stroke_fill=tuple(stroke_fill) + (255,))
+ return im
+
+
+def fit_text(s, max_w, kind='bold', start=400, **kw):
+ size = start
+ while size > 10 and font(kind, size).getlength(s) > max_w: size = int(size * 0.92)
+ return text_img(s, size, kind, **kw)
+
+
+def rrect(w, h, r, fill, outline=None, width=0):
+ im = Image.new('RGBA', (int(w), int(h)), (0, 0, 0, 0))
+ ImageDraw.Draw(im).rounded_rectangle([0, 0, int(w) - 1, int(h) - 1], int(r), fill=fill, outline=outline, width=width)
+ return im
+
+
+def shadowed(im, blur=18, dy=10, alpha=120):
+ pad = blur * 2 + abs(dy)
+ out = Image.new('RGBA', (im.width + 2 * pad, im.height + 2 * pad), (0, 0, 0, 0))
+ a = im.split()[3].point(lambda v: v * alpha // 255)
+ sh = Image.new('RGBA', im.size, (0, 0, 0, 255)); sh.putalpha(a)
+ out.paste(sh, (pad, pad + dy), sh)
+ out = out.filter(ImageFilter.GaussianBlur(blur))
+ out.alpha_composite(im, (pad, pad))
+ return out
+
+
+def to_np(im): return np.asarray(im.convert('RGBA'), dtype=np.float32) / 255.0
+
+
+def comp(c, layer, x, y, alpha=1.0, behind=False, guard=False):
+ """Alpha-composite an RGBA layer with its top-left at (x, y).
+ behind=True hides it wherever the person is (so it sits behind you).
+ guard=True only hides it where it would cover your face."""
+ L = to_np(layer) if isinstance(layer, Image.Image) else layer
+ h, w = L.shape[:2]; x, y = int(round(x)), int(round(y))
+ x0, y0, x1, y1 = max(0, x), max(0, y), min(c.W, x + w), min(c.H, y + h)
+ if x1 <= x0 or y1 <= y0 or alpha <= 0: return
+ L = L[y0 - y:y1 - y, x0 - x:x1 - x]
+ a = L[..., 3:4] * alpha
+ m = c.m[y0:y1, x0:x1, None]
+ if behind: a = a * (1 - m)
+ elif guard:
+ yy, xx = np.ogrid[y0:y1, x0:x1]
+ e = ((xx - c.fx) / (c.fw * 0.95)) ** 2 + ((yy - c.fy) / (c.fw * 1.35)) ** 2
+ a = a * (1 - np.clip((1.2 - e) / 0.3, 0, 1)[..., None] * m)
+ dst = c.img[y0:y1, x0:x1]
+ dst[:] = dst * (1 - a) + L[..., :3] * a
+
+
+def place(c, im, cx, cy, scale=1.0, rot=0.0, alpha=1.0, behind=False, guard=False):
+ """Draw a PIL image centred on (cx, cy), scaled and rotated (degrees, counter-clockwise)."""
+ if scale <= 0.01 or alpha <= 0: return
+ if abs(scale - 1) > 0.005:
+ im = im.resize((max(1, int(im.width * scale)), max(1, int(im.height * scale))), Image.BILINEAR)
+ if abs(rot) > 0.05: im = im.rotate(rot, Image.BICUBIC, expand=True)
+ comp(c, im, cx - im.width / 2, cy - im.height / 2, alpha, behind, guard)
+
+
+def camera(c, zoom, cx, cy):
+ """Zoom the whole frame (and the person mask) towards (cx, cy). Capped at 2x so it stays sharp."""
+ zoom = min(zoom, 2.0)
+ if zoom <= 1.002: return
+ cw, ch = c.W / zoom, c.H / zoom
+ x0 = clamp(cx - cw / 2, 0, c.W - cw); y0 = clamp(cy - ch / 2, 0, c.H - ch)
+ M = np.float32([[zoom, 0, -x0 * zoom], [0, zoom, -y0 * zoom]])
+ c.img = cv2.warpAffine(c.img, M, (c.W, c.H), flags=cv2.INTER_CUBIC, borderMode=cv2.BORDER_REFLECT)
+ c.m = cv2.warpAffine(c.m, M, (c.W, c.H), flags=cv2.INTER_LINEAR)
+ c.fx, c.fy, c.fw = (c.fx - x0) * zoom, (c.fy - y0) * zoom, c.fw * zoom
+
+
+def face_cam(c, zoom, head_at=0.40):
+ """Zoom on the face, keeping it at `head_at` of the frame height."""
+ z = min(zoom, 2.0)
+ camera(c, z, c.fx, c.fy + (c.H / z) * (0.5 - head_at))
+
+
+def grade(img, kind='moody'):
+ lum = (img @ np.float32([0.299, 0.587, 0.114]))[..., None]
+ if kind == 'bw':
+ g = np.clip((lum - 0.5) * 1.25 + 0.5, 0, 1); return np.repeat(g, 3, axis=2)
+ if kind == 'warm': return np.clip(img * np.float32([1.08, 1.0, 0.86]) + 0.02, 0, 1)
+ if kind == 'cool': return np.clip(img * np.float32([0.9, 1.0, 1.1]), 0, 1)
+ if kind == 'pop':
+ o = lum + (img - lum) * 1.35; return np.clip((o - 0.5) * 1.12 + 0.5, 0, 1)
+ # moody: a little darker, softer colour, teal shadows, warm highlights, gentle contrast
+ o = lum + (img - lum) * 0.6
+ o = np.power(np.clip(o, 0, 1), 1.3) * 0.88
+ o = o + (1 - lum) * np.float32([-0.03, 0.035, 0.065]) + lum * np.float32([0.05, 0.015, -0.04])
+ o = np.clip((o - 0.42) * 1.12 + 0.42, 0, 1)
+ return o
+
+
+_vig = {}
+def vignette(c, strength=0.35):
+ k = (c.W, c.H)
+ if k not in _vig:
+ yy, xx = np.ogrid[0:c.H, 0:c.W]
+ d = ((xx - c.W / 2) / (c.W * 0.75)) ** 2 + ((yy - c.H / 2) / (c.H * 0.7)) ** 2
+ _vig[k] = np.clip(d, 0, 1).astype(np.float32)
+ c.img *= (1 - strength * _vig[k])[..., None]
+
+
+def card(im, w, radius=0.07):
+ """A reel-shaped (9:16) rounded card with a soft shadow."""
+ h = int(w * 16 / 9)
+ src = im.convert('RGB'); sw, sh = src.size
+ s = max(w / sw, h / sh)
+ src = src.resize((max(w, int(sw * s)), max(h, int(sh * s))), Image.LANCZOS)
+ l, t = (src.width - w) // 2, (src.height - h) // 2
+ src = src.crop((l, t, l + w, t + h)).convert('RGBA')
+ m = Image.new('L', (w, h), 0); ImageDraw.Draw(m).rounded_rectangle([0, 0, w - 1, h - 1], int(w * radius), fill=255)
+ src.putalpha(m)
+ ImageDraw.Draw(src).rounded_rectangle([0, 0, w - 1, h - 1], int(w * radius), outline=(0, 0, 0, 70), width=2)
+ return shadowed(src, blur=max(6, w // 16), dy=w // 22, alpha=150)
+
+
+def vary(im, i):
+ """Give each card its own look, so a pile of frames reads as different reels."""
+ kind = ('pop', 'bw', 'warm', 'cool', 'moody')[i % 5]
+ a = np.asarray(im.convert('RGB'), np.float32) / 255
+ return Image.fromarray((grade(a, kind) * 255).astype(np.uint8))
+
+
+def cached(e, key, fn):
+ if key not in e.state: e.state[key] = fn()
+ return e.state[key]
+
+
+# ---------- the 22 effects ----------
+@effect('noise', 'reels pile up behind your head, one every quarter second')
+def fx_noise(c, e):
+ cw = int(c.W * float(e.o.get('size', 0.34)))
+ def setup():
+ rnd = random.Random(7); n = min(16, max(4, int(e.d / 0.22)))
+ return [(rnd.uniform(0.14, 0.86), rnd.uniform(0.12, 0.52), rnd.uniform(-7, 7)) for _ in range(n)]
+ pos = cached(e, 'pos', setup)
+ cards = cached(e, 'cards', lambda: [card(vary(im, i) if e.o.get('images') is None else im, cw) for i, im in enumerate(e.cards)])
+ out = clamp((e.d - c.lt) / 0.2)
+ for i, (x, y, r) in enumerate(pos):
+ t0 = i * 0.22
+ if c.lt < t0: break
+ k = ease_back((c.lt - t0) / 0.25)
+ place(c, cards[i % len(cards)], x * c.W, y * c.H, 0.6 + 0.4 * k, r, clamp((c.lt - t0) / 0.08) * out, behind=True)
+
+
+@effect('lineup', 'numbered tiles fan out in an arc above your head')
+def fx_lineup(c, e):
+ names = e.o.get('text', '|'.join(NAMES)).split('|')
+ tw = int(c.W * 0.105)
+ def tile(i, name):
+ im = rrect(tw, int(tw * 1.25), tw * 0.16, (24, 24, 28, 225), (255, 255, 255, 60), 2)
+ d = ImageDraw.Draw(im)
+ num = text_img(f'{i + 1:02d}', tw * 0.42, 'serif', CREAM)
+ im.alpha_composite(num, ((tw - num.width) // 2, int(tw * 0.04)))
+ words = name.split(' ')
+ lines = [' '.join(words[:len(words) // 2 or 1]), ' '.join(words[len(words) // 2 or 1:])] if len(name) > 10 else [name]
+ f = font('ui', tw * 0.15)
+ for j, ln in enumerate([l for l in lines if l]):
+ d.text((tw / 2, tw * (0.78 + 0.19 * j)), ln, font=f, fill=(255, 255, 255, 235), anchor='mm')
+ return shadowed(im, 8, 5, 90)
+ tiles = cached(e, 'tiles', lambda: [tile(i, n) for i, n in enumerate(names)])
+ n = len(tiles); outer = math.ceil(n / 2 + 0.5); inner = n - outer
+ cx, cy = c.W / 2 * 0.6 + c.fx * 0.4, c.fy + c.fw * 0.3
+ slots = []
+ for row, cnt, R in ((0, outer, c.W * 0.47), (1, inner, c.W * 0.33)):
+ for k in range(cnt):
+ a = math.pi * (0.94 - 0.88 * k / max(1, cnt - 1))
+ slots.append((cx + R * math.cos(a), cy - R * math.sin(a) * 1.05, math.degrees(a - math.pi / 2) * 0.3))
+ out = clamp((e.d - c.lt) / 0.2)
+ for i, (x, y, r) in enumerate(slots[:n]):
+ t0 = 0.035 * i
+ if c.lt < t0: continue
+ k = ease_back((c.lt - t0) / 0.3)
+ place(c, tiles[i], x, y + (1 - k) * 40, 0.5 + 0.5 * k, r, clamp((c.lt - t0) / 0.1) * out, behind=True)
+
+
+@effect('locked-on', 'corner brackets snap onto your face and the camera follows you')
+def fx_locked_on(c, e):
+ face_cam(c, 1 + (float(e.o.get('zoom', 1.35)) - 1) * ease_out(c.lt / 0.6))
+ snap = ease_out(c.lt / 0.22); s = c.fw * 0.85 * (1 + 0.6 * (1 - snap))
+ al = clamp(c.lt / 0.12) * clamp((e.d - c.lt) / 0.2)
+ size = int(2 * s + 40); im = Image.new('RGBA', (size, int(size * 1.25)), (0, 0, 0, 0)); d = ImageDraw.Draw(im)
+ x0, y0, x1, y1 = 20, 20, size - 20, im.height - 20; L = int(s * 0.32); wd = max(4, int(c.W / 200))
+ for (px, py, dx, dy) in ((x0, y0, 1, 1), (x1, y0, -1, 1), (x0, y1, 1, -1), (x1, y1, -1, -1)):
+ d.line([(px, py + dy * L), (px, py), (px + dx * L, py)], fill=(255, 255, 255, 255), width=wd, joint='curve')
+ place(c, shadowed(im, 6, 2, 120), c.fx, c.fy, alpha=al)
+ tag = text_img(e.o.get('text', 'LOCKED ON').upper(), c.W * 0.022, 'mono', INK)
+ pill = rrect(tag.width + 10, tag.height, tag.height / 2, (255, 255, 255, 235)); pill.alpha_composite(tag, (5, 0))
+ place(c, pill, c.fx, c.fy + s * 1.25 + pill.height, alpha=clamp((c.lt - 0.15) / 0.15) * al, guard=True)
+
+
+@effect('orbit', 'your reels circle your head: in front at the bottom, behind you at the top')
+def fx_orbit(c, e):
+ K = int(e.o.get('count', 6)); cw = int(c.W * float(e.o.get('size', 0.2)))
+ cards = cached(e, 'cards', lambda: [card(vary(im, i) if e.o.get('images') is None else im, cw) for i, im in enumerate(e.cards)])
+ intro, out = ease_out(c.lt / 0.4), clamp((e.d - c.lt) / 0.25)
+ rx, ry = c.W * 0.38 * intro, max(c.fw * 1.5, c.H * 0.1)
+ oy = c.fy + c.fw * 0.9
+ items = []
+ for i in range(K):
+ th = i * 2 * math.pi / K + c.lt * float(e.o.get('speed', 1.9))
+ items.append((math.sin(th), th, i))
+ for depth, th, i in sorted(items):
+ place(c, cards[i % len(cards)], c.fx + rx * math.cos(th), oy + ry * math.sin(th), (0.78 + 0.24 * (depth + 1) / 2) * (0.5 + 0.5 * intro),
+ -6 * math.cos(th), out * clamp(c.lt / 0.15), behind=depth < 0, guard=depth >= 0)
+
+
+@effect('lean-in', 'a fast punch-in on one word')
+def fx_lean_in(c, e):
+ z = float(e.o.get('zoom', 1.45))
+ face_cam(c, 1 + (z - 1) * ease_out(c.lt / float(e.o.get('speed', 0.18))), 0.42)
+
+
+@effect('backdrop-word', 'a giant word drops in behind you')
+def fx_backdrop_word(c, e):
+ word = e.o.get('text', 'CLAUDE')
+ im = cached(e, 'w', lambda: fit_text(word, c.W * 0.94, e.o.get('font', 'bold'), fill=rgb(e.o.get('color'), CREAM), shadow=10))
+ k = ease_back(c.lt / 0.42)
+ y_end = c.fy - c.fw * 1.05
+ y = -im.height + (y_end + im.height) * k
+ place(c, im, c.W / 2 * 0.6 + c.fx * 0.4, y, alpha=clamp((e.d - c.lt) / 0.2), behind=True)
+
+
+_grid = {}
+def grid(c):
+ if (c.W, c.H) not in _grid:
+ yy, xx = np.mgrid[0:c.H, 0:c.W].astype(np.float32); _grid[(c.W, c.H)] = (xx, yy)
+ return _grid[(c.W, c.H)]
+
+
+@effect('spotlight', 'kill the lights, keep you lit')
+def fx_spotlight(c, e):
+ face_cam(c, 1 + (float(e.o.get('push', 1.1)) - 1) * ease_inout(c.lt / e.d))
+ k = ramp(c, e, 0.3, 0.25)
+ xx, yy = grid(c)
+ d = ((xx - c.fx) / (c.W * 0.5)) ** 2 + ((yy - (c.fy + c.H * 0.2)) / (c.H * 0.46)) ** 2
+ pool = np.clip(1 - d, 0, 1) ** 1.6
+ bright = 1 - k * (1 - (0.2 + 0.45 * pool))
+ f = bright * (1 - c.m) + c.m * (1 + 0.04 * k)
+ if e.o.get('text'):
+ word = e.o['text']; col = rgb(e.o.get('color'), PEACH)
+ im = cached(e, 'w', lambda: fit_text(word, c.W * 0.9, e.o.get('font', 'serif'), fill=col, glow=(col, 26)))
+ c.img *= f[..., None]
+ place(c, im, c.W / 2, c.fy - c.fw * 1.1, alpha=k, behind=True)
+ else:
+ c.img *= f[..., None]
+
+
+@effect('the-bill', 'prints every instruction like a ticket, into the wall above your head')
+def fx_bill(c, e):
+ lines = e.o.get('text', 'ORDER #1021|1x orbit|1x spotlight|1x lean-in|cut the dead air|TOTAL: 1 prompt').split('|')
+ def build():
+ pw = int(c.W * 0.5); lh = int(pw * 0.085); pad = int(pw * 0.08)
+ h = pad * 2 + lh * (len(lines) + 1)
+ im = Image.new('RGBA', (pw, h), CREAM + (255,)); d = ImageDraw.Draw(im)
+ f = font('mono', lh * 0.62)
+ for i, ln in enumerate(lines):
+ y = pad + lh * i + (lh if i == len(lines) - 1 else 0)
+ if i == len(lines) - 1:
+ for x in range(pad, pw - pad, 14): d.line([(x, y - lh * 0.45), (x + 7, y - lh * 0.45)], fill=INK + (140,), width=2)
+ d.text((pad, y), ln, font=f, fill=INK + (255,))
+ return im
+ rec = cached(e, 'r', build)
+ slot_y, sw = c.H * 0.075, c.W * 0.62
+ max_h = max(80, c.fy - c.fw * 1.3 - slot_y)
+ s = min(1.0, max_h / rec.height)
+ pr = ease_inout(c.lt / (e.d * 0.75)); L = int(rec.height * pr)
+ al = clamp((e.d - c.lt) / 0.25)
+ cx = c.W / 2
+ if L > 2:
+ paper = rec.crop((0, 0, rec.width, L))
+ z = 14; jag = Image.new('RGBA', (rec.width, L + z), (0, 0, 0, 0)); jag.paste(paper, (0, 0))
+ ImageDraw.Draw(jag).polygon([(x, L) for x in range(0, rec.width + 1, 2 * z)] + [(rec.width, L)] +
+ [(x + z, L + z) for x in range(rec.width - 2 * z, -1, -2 * z)], fill=CREAM + (255,))
+ paper = shadowed(jag, 10, 6, 90)
+ if s < 1: paper = paper.resize((int(paper.width * s), int(paper.height * s)), Image.BILINEAR)
+ comp(c, paper, cx - paper.width / 2, slot_y - 10 * s, al, behind=True)
+ slot = rrect(sw, c.H * 0.03, c.H * 0.015, (30, 30, 34, 255), (90, 90, 96, 255), 3)
+ place(c, shadowed(slot, 10, 6, 140), cx, slot_y, alpha=al * clamp(c.lt / 0.15), behind=True)
+
+
+@effect('moody', 'a moody colour grade: darker, softer, teal shadows')
+def fx_moody(c, e):
+ k = ramp(c, e, 0.35, 0)
+ c.img = c.img * (1 - k) + grade(c.img, e.o.get('grade', 'moody')) * k
+ vignette(c, 0.4 * k)
+
+
+@effect('swipe', 'a before and after slider that sweeps across you')
+def fx_swipe(c, e):
+ after = grade(c.img, e.o.get('grade', 'moody'))
+ p = c.lt / e.d
+ sp = 1.05 - 0.95 * ease_inout(p / 0.5) if p < 0.5 else 0.1 + 0.4 * ease_inout((p - 0.5) / 0.4)
+ xx, yy = grid(c)
+ line = sp * c.W + 0.22 * (yy - c.H / 2)
+ a = np.clip((xx - line) / 3 + 0.5, 0, 1)[..., None]
+ c.img = c.img * (1 - a) + after * a
+ hy = c.H * 0.62; hx = sp * c.W + 0.22 * (hy - c.H / 2)
+ edge = np.clip(1 - np.abs(xx - line) / 3.5, 0, 1)[..., None]
+ c.img = c.img * (1 - edge) + edge
+ r = int(c.W * 0.035); h = Image.new('RGBA', (2 * r + 4, 2 * r + 4), (0, 0, 0, 0)); d = ImageDraw.Draw(h)
+ d.ellipse([2, 2, 2 * r + 2, 2 * r + 2], fill=(255, 255, 255, 255))
+ d.text((r + 2, r + 2), '< >', font=font('mono', r * 0.7), fill=INK + (255,), anchor='mm')
+ place(c, shadowed(h, 8, 4, 110), hx, hy)
+ for lab, x in (('before', 0.14), ('after', 0.86)):
+ t = text_img(lab, c.W * 0.03, 'serif', INK); pill = rrect(t.width + 16, t.height, t.height / 2, (255, 255, 255, 225))
+ pill.alpha_composite(t, (8, 0)); place(c, pill, c.W * x, c.H * 0.88)
+
+
+@effect('todo', 'a checklist card beside your head that ticks off as you talk')
+def fx_todo(c, e):
+ items = e.o.get('text', 'drop your video into Claude|install the skill|type /effects').split('|')
+ # ticks = video seconds when each item gets ticked (e.g. when you say it); default is evenly spaced
+ ticks = [float(t) - e.start for t in str(e.o['ticks']).split('|')] if e.o.get('ticks') else [e.d * (i + 1) / (len(items) + 1) for i in range(len(items))]
+ cw = int(c.W * 0.5); lh = int(cw * 0.13); pad = int(cw * 0.07)
+ im = rrect(cw, pad * 2 + lh * (len(items) + 1), cw * 0.07, (250, 248, 242, 235)); d = ImageDraw.Draw(im)
+ done = sum(c.lt >= t for t in ticks)
+ d.text((pad, pad), e.o.get('title', 'TO DO').upper(), font=font('ui', lh * 0.42), fill=(200, 140, 20, 255))
+ d.text((cw - pad, pad), f'{done} of {len(items)}', font=font('ui', lh * 0.36), fill=(120, 120, 120, 255), anchor='ra')
+ f = font('ui', lh * 0.4)
+ for i, it in enumerate(items):
+ y = pad + lh * (i + 1); bx = lh * 0.42
+ d.rounded_rectangle([pad, y + lh * 0.12, pad + bx, y + lh * 0.12 + bx], 6, outline=(160, 160, 160, 255), width=3)
+ d.text((pad + bx * 1.5, y + lh * 0.1), it, font=f, fill=INK + (255,))
+ if c.lt >= ticks[i]:
+ k = ease_out((c.lt - ticks[i]) / 0.25)
+ d.rounded_rectangle([pad, y + lh * 0.12, pad + bx, y + lh * 0.12 + bx], 6, fill=(52, 199, 89, 255))
+ d.line([(pad + bx * .22, y + lh * .12 + bx * .52), (pad + bx * .42, y + lh * .12 + bx * .74), (pad + bx * .8, y + lh * .12 + bx * .28)], fill=(255, 255, 255, 255), width=4)
+ tw = f.getlength(it) * k
+ d.line([(pad + bx * 1.5, y + lh * 0.36), (pad + bx * 1.5 + tw, y + lh * 0.36)], fill=INK + (255,), width=3)
+ left = c.fx > c.W / 2
+ x = c.W * 0.05 + cw / 2 if left else c.W * 0.95 - cw / 2
+ pop = ease_back(c.lt / 0.3)
+ place(c, shadowed(im, 14, 8, 90), x, max(im.height / 2 + c.H * 0.06, c.fy - c.fw * 1.4), 0.8 + 0.2 * pop, 0, clamp(c.lt / 0.12) * clamp((e.d - c.lt) / 0.2), behind=True)
+
+
+def heart(size, color=(255, 48, 64)):
+ s = int(size); im = Image.new('RGBA', (s, s), (0, 0, 0, 0)); d = ImageDraw.Draw(im)
+ pts = [(s / 2 + s * 0.48 * (16 * math.sin(t) ** 3) / 16, s * 0.46 - s * 0.46 * (13 * math.cos(t) - 5 * math.cos(2 * t) - 2 * math.cos(3 * t) - math.cos(4 * t)) / 16)
+ for t in np.linspace(0, 2 * math.pi, 60)]
+ d.polygon(pts, fill=color + (255,)); return im
+
+
+@effect('comment-box', 'an Instagram comment bar types your word and posts it')
+def fx_comment_box(c, e):
+ word = e.o.get('text', 'EFFECTS')
+ bw, bh = int(c.W * 0.9), int(c.W * 0.11)
+ slide = ease_out(c.lt / 0.3); y = c.H * 0.8 + (1 - slide) * c.H * 0.25
+ type_t, post_t = 0.35, 0.35 + 0.08 * len(word) + 0.25
+ typed = word[:int(clamp((c.lt - type_t) / (0.08 * len(word))) * len(word) + 0.001)] if c.lt < post_t else ''
+ im = rrect(bw, bh, bh / 2, (255, 255, 255, 245)); d = ImageDraw.Draw(im)
+ r = bh * 0.32; d.ellipse([bh * 0.2, bh / 2 - r, bh * 0.2 + 2 * r, bh / 2 + r], fill=(214, 41, 118, 255))
+ f = font('ui', bh * 0.3)
+ if typed: d.text((bh * 0.95, bh / 2), typed + ('|' if int(c.lt * 4) % 2 else ''), font=f, fill=INK + (255,), anchor='lm')
+ elif c.lt < post_t: d.text((bh * 0.95, bh / 2), 'Add a comment...', font=f, fill=(150, 150, 150, 255), anchor='lm')
+ d.text((bw - bh * 0.4, bh / 2), 'Post', font=f, fill=((0, 149, 246, 255) if typed else (180, 210, 240, 255)), anchor='rm')
+ al = clamp((e.d - c.lt) / 0.2)
+ place(c, shadowed(im, 14, 6, 100), c.W / 2, y, alpha=al, guard=True)
+ if c.lt >= post_t:
+ k = ease_back((c.lt - post_t) / 0.3)
+ b = rrect(int(c.W * 0.52), int(bh * 0.85), bh * 0.3, (255, 255, 255, 240)); bd = ImageDraw.Draw(b)
+ bd.text((bh * 0.3, b.height * 0.32), 'you', font=font('ui', bh * 0.2), fill=(120, 120, 120, 255), anchor='lm')
+ bd.text((bh * 0.3, b.height * 0.66), word, font=font('ui', bh * 0.3), fill=INK + (255,), anchor='lm')
+ hk = ease_back((c.lt - post_t - 0.3) / 0.3)
+ if hk > 0:
+ hh = heart(bh * 0.4 * hk); b.alpha_composite(hh, (int(b.width - bh * 0.3 - hh.width), int(b.height / 2 - hh.height / 2)))
+ place(c, shadowed(b, 12, 5, 90), c.W * 0.07 + b.width / 2, y - bh * 1.05, 0.7 + 0.3 * k, 0, al * clamp((c.lt - post_t) / 0.1), guard=True)
+
+
+@effect('tap', 'a Follow button pops up and flips to Following')
+def fx_tap(c, e):
+ at = float(e.o['at']) - e.start if 'at' in e.o else e.d * 0.45 # 'at' = video second of the tap
+ bw, bh = int(c.W * 0.3), int(c.W * 0.09)
+ x = clamp(float(e.o['x']) * c.W if 'x' in e.o else c.fx + c.fw * 1.9, bw / 2 + 30, c.W - bw / 2 - 30)
+ y = clamp(float(e.o['y']) * c.H if 'y' in e.o else c.fy + c.fw * 1.6, bh + 30, c.H - bh - 30)
+ on = c.lt >= at
+ col = rgb(e.o.get('color'), (124, 92, 255)) if on else (0, 149, 246)
+ im = rrect(bw, bh, bh * 0.28, col + (255,)); d = ImageDraw.Draw(im)
+ d.text((bw / 2, bh / 2), 'Following' if on else '+ Follow', font=font('ui', bh * 0.4), fill=(255, 255, 255, 255), anchor='mm')
+ pop = ease_back(c.lt / 0.3)
+ sq = 1.0
+ if on: q = (c.lt - at) / 0.3; sq = 1 - 0.12 * math.sin(math.pi * clamp(q)) if q < 1 else 1
+ place(c, shadowed(im, 12, 6, 110), x, y, (0.6 + 0.4 * pop) * sq, 0, clamp(c.lt / 0.1) * clamp((e.d - c.lt) / 0.2), guard=True)
+ if on and c.lt - at < 0.4:
+ q = (c.lt - at) / 0.4; r = int(bh * (0.3 + 0.9 * q)); ring = Image.new('RGBA', (2 * r + 8, 2 * r + 8), (0, 0, 0, 0))
+ ImageDraw.Draw(ring).ellipse([4, 4, 2 * r + 4, 2 * r + 4], outline=(255, 255, 255, int(220 * (1 - q))), width=5)
+ place(c, ring, x, y, guard=True)
+
+
+def hand_path(d, pts, color, width, frac):
+ n = max(2, int(len(pts) * clamp(frac)))
+ if frac > 0: d.line(pts[:n], fill=color, width=width, joint='curve')
+ return pts[n - 1]
+
+
+def arrow_pts(x0, y0, x1, y1, bend=0.25, n=40):
+ mx, my = (x0 + x1) / 2 - (y1 - y0) * bend, (y0 + y1) / 2 + (x1 - x0) * bend
+ return [((1 - t) ** 2 * x0 + 2 * (1 - t) * t * mx + t * t * x1, (1 - t) ** 2 * y0 + 2 * (1 - t) * t * my + t * t * y1) for t in np.linspace(0, 1, n)]
+
+
+def arrow_head(d, pts, color, width, size):
+ (xa, ya), (xb, yb) = pts[-4], pts[-1]; a = math.atan2(yb - ya, xb - xa)
+ for s in (2.6, -2.6):
+ d.line([(xb, yb), (xb + size * math.cos(a + s), yb + size * math.sin(a + s))], fill=color, width=width)
+
+
+@effect('pause-point', 'freeze the frame and point at something with a hand-drawn arrow')
+def fx_pause_point(c, e):
+ if 'f' not in e.state: e.state['f'] = (c.img.copy(), c.m.copy(), c.fx, c.fy, c.fw)
+ img, m, c.fx, c.fy, c.fw = e.state['f']; c.img, c.m = img.copy(), m
+ face_cam(c, 1 + 0.06 * ease_out(c.lt / e.d), 0.4)
+ c.img = c.img * 0.92 + grade(c.img, 'bw') * 0.08
+ col = rgb(e.o.get('color'), YELLOW) + (255,)
+ lay = Image.new('RGBA', (c.W, c.H), (0, 0, 0, 0)); d = ImageDraw.Draw(lay)
+ d.rounded_rectangle([c.W * 0.05, c.H * 0.06, c.W * 0.05 + c.W * 0.1, c.H * 0.06 + c.W * 0.1], 16, fill=(0, 0, 0, 150))
+ for bx in (0.075, 0.11): d.rectangle([c.W * bx, c.H * 0.06 + c.W * 0.025, c.W * (bx + 0.017), c.H * 0.06 + c.W * 0.075], fill=(255, 255, 255, 230))
+ tx, ty = c.W * float(e.o.get('label_x', 0.72)), c.fy - c.fw * 2.2
+ pts = arrow_pts(tx - c.W * 0.05, ty + c.W * 0.06, c.fx + c.fw * 0.75, c.fy - c.fw * 0.35, 0.3)
+ k = ease_out((c.lt - 0.15) / 0.4)
+ hand_path(d, pts, col, max(6, c.W // 140), k)
+ if k >= 0.99: arrow_head(d, pts, col, max(6, c.W // 140), c.W * 0.04)
+ comp(c, to_np(lay), 0, 0)
+ lab = text_img(e.o.get('text', 'look here'), c.W * 0.07, 'hand', col[:3], shadow=6)
+ place(c, lab, tx, ty - lab.height * 0.2, 0.7 + 0.3 * ease_back(c.lt / 0.3), -6, clamp(c.lt / 0.1), guard=True)
+
+
+@effect('uninstall', 'a glitchy uninstall bar that breaks the frame apart')
+def fx_uninstall(c, e):
+ p = clamp(c.lt / e.d); g = p ** 1.6
+ rnd = np.random.default_rng(int(c.t * 30))
+ sh = int(g * c.W * 0.025)
+ if sh: c.img = np.stack([np.roll(c.img[..., 0], sh, 1), c.img[..., 1], np.roll(c.img[..., 2], -sh, 1)], -1)
+ for _ in range(int(2 + g * 10)):
+ y0 = int(rnd.uniform(0, c.H)); hh = int(rnd.uniform(8, 60)); off = int(rnd.uniform(-1, 1) * g * c.W * 0.08)
+ c.img[y0:y0 + hh] = np.roll(c.img[y0:y0 + hh], off, 1)
+ if p > 0.82:
+ q = (p - 0.82) / 0.18; f = 1 + int(q * 40)
+ small = cv2.resize(c.img, (max(1, c.W // f), max(1, c.H // f)), interpolation=cv2.INTER_AREA)
+ c.img = cv2.resize(small, (c.W, c.H), interpolation=cv2.INTER_NEAREST) * (1 - 0.6 * q)
+ bw, bh = int(c.W * 0.7), int(c.W * 0.2)
+ im = rrect(bw, bh, 22, (245, 245, 247, 240)); d = ImageDraw.Draw(im)
+ d.text((bw * 0.06, bh * 0.28), e.o.get('text', 'Uninstalling...'), font=font('ui', bh * 0.18), fill=INK + (255,), anchor='lm')
+ d.rounded_rectangle([bw * 0.06, bh * 0.56, bw * 0.94, bh * 0.7], 8, fill=(215, 215, 220, 255))
+ d.rounded_rectangle([bw * 0.06, bh * 0.56, bw * 0.06 + bw * 0.88 * max(0.03, ease_inout(p)), bh * 0.7], 8, fill=(0, 122, 255, 255))
+ d.text((bw * 0.94, bh * 0.85), f'{int(ease_inout(p) * 100)}%', font=font('ui', bh * 0.13), fill=(110, 110, 110, 255), anchor='rm')
+ place(c, shadowed(im, 16, 8, 120), c.W / 2, c.H * 0.16, 0.8 + 0.2 * ease_back(c.lt / 0.3), 0, clamp(c.lt / 0.1))
+
+
+def reel_icons(size):
+ s = int(size); im = Image.new('RGBA', (s, int(s * 3.6)), (0, 0, 0, 0)); d = ImageDraw.Draw(im); w = max(3, s // 12)
+ h = heart(s * 0.8, (255, 255, 255)); im.alpha_composite(h, (int(s * 0.1), 0))
+ d.text((s / 2, s * 0.95), '26.9K', font=font('ui', s * 0.24), fill=(255, 255, 255, 255), anchor='mm')
+ d.ellipse([s * 0.15, s * 1.25, s * 0.85, s * 1.95], outline=(255, 255, 255, 255), width=w)
+ d.text((s / 2, s * 2.15), '412', font=font('ui', s * 0.24), fill=(255, 255, 255, 255), anchor='mm')
+ d.polygon([(s * 0.12, s * 2.75), (s * 0.9, s * 2.45), (s * 0.55, s * 3.25), (s * 0.45, s * 2.88)], outline=(255, 255, 255, 255), width=w)
+ return im
+
+
+@effect('reel-frame', 'your video shrinks into an Instagram reel card')
+def fx_reel_frame(c, e):
+ k = ease_out(c.lt / 0.35) * clamp((e.d - c.lt) / 0.3)
+ if k <= 0: return
+ s = 1 - 0.2 * k
+ small = cv2.resize(c.img, (c.W // 16, c.H // 16), interpolation=cv2.INTER_AREA)
+ bg = cv2.GaussianBlur(cv2.resize(small, (c.W, c.H), interpolation=cv2.INTER_LINEAR), (0, 0), 12) * (1 - 0.45 * k)
+ iw, ih = int(c.W * s), int(c.H * s)
+ inset = cv2.resize(c.img, (iw, ih), interpolation=cv2.INTER_AREA)
+ m = to_np(rrect(iw, ih, c.W * 0.05 * k + 1, (255, 255, 255, 255)))[..., 3:4]
+ x0, y0 = (c.W - iw) // 2, int((c.H - ih) * 0.42)
+ out = bg.copy(); reg = out[y0:y0 + ih, x0:x0 + iw]; reg[:] = reg * (1 - m) + inset * m
+ c.img = out
+ mm = np.zeros_like(c.m); mm[y0:y0 + ih, x0:x0 + iw] = cv2.resize(c.m, (iw, ih)); c.m = mm
+ c.fx, c.fy, c.fw = x0 + c.fx * s, y0 + c.fy * s, c.fw * s
+ ic = cached(e, 'ic', lambda: shadowed(reel_icons(c.W * 0.075), 6, 2, 120))
+ comp(c, ic, x0 + iw - ic.width - c.W * 0.01, y0 + ih * 0.52, k)
+ hdl = text_img(e.o.get('text', '@your.handle'), c.W * 0.032, 'ui', (255, 255, 255), shadow=4)
+ comp(c, hdl, x0 + c.W * 0.03, y0 + ih - hdl.height - c.W * 0.04, k)
+
+
+@effect('shortcut-rain', 'keyboard keys rain down behind you')
+def fx_shortcut_rain(c, e):
+ keys = e.o.get('text', 'cmd|/|C|V|Z|esc|tab|shift|enter|opt').split('|')
+ ks = int(c.W * 0.1)
+ def cap(k):
+ w = max(ks, int(font('mono', ks * 0.36).getlength(k) + ks * 0.5))
+ im = rrect(w, ks, ks * 0.18, (190, 190, 198, 255)); top = rrect(w - 8, ks - 14, ks * 0.16, (246, 246, 248, 255))
+ im.alpha_composite(top, (4, 3)); ImageDraw.Draw(im).text((w / 2, ks * 0.44), k, font=font('mono', ks * 0.36), fill=INK + (255,), anchor='mm')
+ return shadowed(im, 8, 6, 100)
+ caps = cached(e, 'caps', lambda: [cap(k) for k in keys])
+ parts = cached(e, 'p', lambda: [(random.Random(i).random(), random.Random(i + 99).random() * max(0.1, e.d - 0.8),
+ 0.45 + 0.4 * random.Random(i + 7).random(), random.Random(i + 3).uniform(-25, 25),
+ random.Random(i + 5).uniform(-60, 60)) for i in range(int(e.o.get('count', 26)))])
+ for i, (x, t0, v, r0, w) in enumerate(parts):
+ if c.lt < t0: continue
+ y = -ks + (c.lt - t0) * v * c.H
+ place(c, caps[i % len(caps)], c.W * (0.04 + 0.92 * x), y, 0.75 + 0.35 * v, r0 + w * (c.lt - t0), clamp((e.d - c.lt) / 0.2), behind=True)
+
+
+@effect('reject-stamp', 'a big red stamp slams onto the screen')
+def fx_reject_stamp(c, e):
+ word = e.o.get('text', 'REJECTED').upper(); col = rgb(e.o.get('color'), (214, 40, 40))
+ def build():
+ t = fit_text(word, c.W * 0.62, 'bold', 200, fill=col); pad = int(t.height * 0.12)
+ im = Image.new('RGBA', (t.width + 4 * pad, t.height + 2 * pad), (0, 0, 0, 0)); d = ImageDraw.Draw(im)
+ d.rounded_rectangle([3, 3, im.width - 4, im.height - 4], 18, outline=col + (255,), width=max(6, pad // 2))
+ im.alpha_composite(t, (2 * pad, pad))
+ a = np.asarray(im.split()[3], np.float32) * np.clip(np.random.default_rng(3).uniform(0.55, 1.6, (im.height, im.width)), 0, 1)
+ im.putalpha(Image.fromarray(a.astype(np.uint8)))
+ return im
+ st = cached(e, 's', build)
+ k = clamp(c.lt / 0.16); sc = 2.3 - 1.3 * k * k
+ if 0.16 < c.lt < 0.45:
+ a = (0.45 - c.lt) / 0.29 * c.W * 0.012; rnd = np.random.default_rng(int(c.t * 30))
+ M = np.float32([[1, 0, rnd.uniform(-a, a)], [0, 1, rnd.uniform(-a, a)]])
+ c.img = cv2.warpAffine(c.img, M, (c.W, c.H), borderMode=cv2.BORDER_REFLECT)
+ y = clamp(float(e.o['y']) * c.H if 'y' in e.o else c.fy + c.fw * 2.7, 0, c.H * 0.85)
+ place(c, st, c.W / 2, y, sc, float(e.o.get('angle', 12)), k * clamp((e.d - c.lt) / 0.2), guard=True)
+
+
+@effect('countdown-flip', 'a 3, 2, 1 flip clock above your head')
+def fx_countdown(c, e):
+ n0 = int(e.o.get('from', 3)); seg = e.d / n0
+ i = min(n0 - 1, int(c.lt / seg)); cur, prev = n0 - i, n0 - i + 1
+ f = clamp((c.lt - i * seg) / 0.3) if i > 0 else 1.0
+ tw, th = int(c.W * 0.3), int(c.W * 0.38)
+ def half(num, top):
+ im = rrect(tw, th, tw * 0.1, (30, 30, 34, 255)); d = ImageDraw.Draw(im)
+ d.text((tw / 2, th / 2), str(num), font=font('bold', th * 0.62), fill=CREAM + (255,), anchor='mm')
+ return im.crop((0, 0, tw, th // 2)) if top else im.crop((0, th // 2, tw, th))
+ hv = cached(e, 'h', lambda: {(n, t): half(n, t) for n in range(0, n0 + 2) for t in (True, False)})
+ im = Image.new('RGBA', (tw, th), (0, 0, 0, 0))
+ im.paste(hv[(cur, True)], (0, 0)); im.paste(hv[(prev if f < 1 else cur, False)], (0, th // 2))
+ if f < 0.5:
+ h = max(1, int(th / 2 * (1 - 2 * f))); fl = hv[(prev, True)].resize((tw, h)); im.paste(fl, (0, th // 2 - h))
+ elif f < 1:
+ h = max(1, int(th / 2 * (2 * f - 1))); fl = hv[(cur, False)].resize((tw, h)); im.paste(fl, (0, th // 2))
+ ImageDraw.Draw(im).line([(0, th // 2), (tw, th // 2)], fill=(0, 0, 0, 255), width=4)
+ y = max(th / 2 + c.H * 0.05, c.fy - c.fw * 2.3)
+ place(c, shadowed(im, 16, 10, 120), c.W / 2 * 0.6 + c.fx * 0.4, y, 0.7 + 0.3 * ease_back(c.lt / 0.3), 0, clamp((e.d - c.lt) / 0.2), behind=True)
+
+
+_rect = {}
+@effect('rabbit-hole', 'the frame tunnels into itself, spinning')
+def fx_rabbit_hole(c, e):
+ k = ease_out(c.lt / 0.4) * clamp((e.d - c.lt) / 0.3)
+ if k <= 0: return
+ if (c.W, c.H) not in _rect:
+ a = np.ones((c.H, c.W), np.float32); b = np.zeros((c.H, c.W), np.float32); t = max(4, c.W // 120)
+ b[:t] = b[-t:] = 1; b[:, :t] = b[:, -t:] = 1; _rect[(c.W, c.H)] = (a, b)
+ ones, border = _rect[(c.W, c.H)]
+ r = float(e.o.get('ratio', 0.62)); z = (c.lt * float(e.o.get('speed', 0.8))) % 1.0
+ src = c.img; cx, cy = c.fx, c.fy
+ out = None
+ for lev in range(0, 7):
+ s = r ** (lev - z * k) if lev else 1.0
+ ang = (lev - z) * float(e.o.get('spin', 10)) * k if lev else 0
+ if lev and s < 0.03: break
+ M = cv2.getRotationMatrix2D((cx, cy), ang, s)
+ if lev == 0:
+ out = src.copy(); continue
+ L = cv2.warpAffine(src, M, (c.W, c.H), flags=cv2.INTER_LINEAR)
+ a = cv2.warpAffine(ones, M, (c.W, c.H))[..., None] * k
+ bd = cv2.warpAffine(border, M, (c.W, c.H))[..., None] * k
+ out = out * (1 - a) + L * a
+ out = out * (1 - bd) + bd
+ m = c.m[..., None] * k # you stay in front while the room tunnels behind you
+ c.img = out * (1 - m) + src * m
+
+
+@effect('cover-star', 'you become a magazine cover, with the title behind your head')
+def fx_cover_star(c, e):
+ k = ease_out(c.lt / 0.35); al = clamp((e.d - c.lt) / 0.2)
+ c.img = c.img * (1 - 0.6 * k) + grade(c.img, 'pop') * 0.6 * k
+ title = e.o.get('text', 'VIBE').upper(); col = rgb(e.o.get('color'), (232, 36, 52))
+ mast = cached(e, 'm', lambda: fit_text(title, c.W * 0.92, 'bold', 600, fill=col))
+ mast_h = min(mast.height, c.H * 0.24)
+ place(c, mast, c.W / 2, c.H * 0.035 + mast_h / 2 - (1 - k) * mast_h, mast_h / mast.height, 0, al * k, behind=True)
+ iss = cached(e, 'i', lambda: text_img(e.o.get('issue', 'THE AI ISSUE · 2026'), c.W * 0.025, 'mono', (255, 255, 255), shadow=3))
+ place(c, iss, c.W / 2, c.H * 0.03, alpha=al * k, behind=True)
+ lines = e.o.get('lines', '22 effects|you can steal|no editor|needed').split('|')
+ y = c.H * 0.5
+ for j, ln in enumerate(lines):
+ big = j == 0
+ im = cached(e, ('l', j), lambda: text_img(ln, c.W * (0.085 if big else 0.045), 'serif' if big else 'bold', YELLOW if big else (255, 255, 255), shadow=5))
+ kj = ease_out((c.lt - 0.15 - 0.08 * j) / 0.3)
+ comp(c, im, c.W * 0.05 - (1 - kj) * 60, y, al * kj, guard=True); y += im.height * 0.86
+ def barcode():
+ rnd = random.Random(1); bw, bh = int(c.W * 0.16), int(c.W * 0.09)
+ im = Image.new('RGBA', (bw, bh), (255, 255, 255, 255)); d = ImageDraw.Draw(im); x = 8
+ while x < bw - 8:
+ w = rnd.choice((2, 2, 3, 5)); d.rectangle([x, 6, x + w - 1, bh - 18], fill=(0, 0, 0, 255)); x += w + rnd.choice((2, 3, 4))
+ return im
+ bc = cached(e, 'b', barcode)
+ comp(c, bc, c.W * 0.95 - bc.width, c.H * 0.93 - bc.height, al * k, guard=True)
+
+
+@effect('scribble', 'marker doodles draw themselves around you')
+def fx_scribble(c, e):
+ col = rgb(e.o.get('color'), YELLOW) + (255,); wd = max(6, c.W // 130)
+ lay = Image.new('RGBA', (c.W, c.H), (0, 0, 0, 0)); d = ImageDraw.Draw(lay)
+ rx, ry = c.fw * 1.0, c.fw * 1.3
+ angs = np.linspace(-1.9, -1.9 + 2 * math.pi * 1.08, 70)
+ ring = [(c.fx + rx * (1 + 0.04 * math.sin(3 * a)) * math.cos(a), c.fy + ry * (1 + 0.04 * math.cos(2 * a)) * math.sin(a)) for a in angs]
+ hand_path(d, ring, col, wd, ease_inout(c.lt / 0.5))
+ lx, ly = clamp(c.fx + c.fw * 2.3, c.W * 0.2, c.W * 0.8), max(c.H * 0.08, c.fy - c.fw * 2.4)
+ pts = arrow_pts(lx - c.fw * 0.3, ly + c.fw * 0.5, c.fx + rx * 0.85, c.fy - ry * 0.75, -0.3)
+ k2 = ease_out((c.lt - 0.45) / 0.35)
+ if k2 > 0: hand_path(d, pts, col, wd, k2)
+ if k2 >= 0.99: arrow_head(d, pts, col, wd, c.W * 0.035)
+ for j, (sx, sy) in enumerate(((c.fx - c.fw * 1.9, c.fy - c.fw * 1.2), (c.fx - c.fw * 1.5, c.fy + c.fw * 0.6), (c.fx + c.fw * 1.6, c.fy + c.fw * 0.3))):
+ ks = ease_back((c.lt - 0.8 - 0.1 * j) / 0.25) * c.fw * 0.28
+ if ks > 0:
+ d.line([(sx - ks, sy), (sx + ks, sy)], fill=col, width=wd); d.line([(sx, sy - ks), (sx, sy + ks)], fill=col, width=wd)
+ al = clamp((e.d - c.lt) / 0.2)
+ comp(c, to_np(lay), 0, 0, al)
+ if c.lt > 0.7:
+ lab = text_img(e.o.get('text', 'me!'), c.W * 0.075, 'hand', col[:3], shadow=6)
+ place(c, lab, lx, ly - lab.height * 0.15, 0.7 + 0.3 * ease_back((c.lt - 0.7) / 0.3), 8, al)
+
+
+# ---------- video in/out + tracking ----------
+def probe(path):
+ j = json.loads(subprocess.run(['ffprobe', '-v', 'error', '-select_streams', 'v:0', '-show_entries', 'stream=r_frame_rate:format=duration',
+ '-of', 'json', path], capture_output=True, text=True, check=True).stdout)
+ fr = j['streams'][0]['r_frame_rate']; num, den = fr.split('/'); fps = float(num) / float(den or 1)
+ png = subprocess.run(['ffmpeg', '-v', 'error', '-i', path, '-frames:v', '1', '-f', 'image2pipe', '-vcodec', 'png', '-'], capture_output=True, check=True).stdout
+ h, w = cv2.imdecode(np.frombuffer(png, np.uint8), cv2.IMREAD_COLOR).shape[:2]
+ return (fr if fps <= 30.5 else '30'), min(fps, 30.0), float(j['format']['duration']), w, h
+
+
+def read_frames(path, W, H, fr):
+ p = subprocess.Popen(['ffmpeg', '-v', 'error', '-i', path, '-vf', f'fps={fr},scale={W}:{H}:flags=bicubic,format=rgb24', '-f', 'rawvideo', '-'],
+ stdout=subprocess.PIPE, bufsize=10 ** 8)
+ n = W * H * 3
+ try:
+ while True:
+ b = p.stdout.read(n)
+ if len(b) < n: break
+ yield np.frombuffer(b, np.uint8).reshape(H, W, 3)
+ finally:
+ if p.poll() is None: p.kill()
+ p.stdout.close(); p.wait()
+
+
+def guided(I, p, r=8, eps=2e-3):
+ box = lambda x: cv2.boxFilter(x, -1, (2 * r + 1, 2 * r + 1))
+ mI, mp_ = box(I), box(p); a = (box(I * p) - mI * mp_) / (box(I * I) - mI * mI + eps); b = mp_ - a * mI
+ return np.clip(box(a) * I + box(b), 0, 1)
+
+
+class Tracker:
+ def __init__(self, aw, ah):
+ import mediapipe as mp
+ from mediapipe.tasks.python import vision
+ from mediapipe.tasks.python.core.base_options import BaseOptions
+ self.mp = mp
+ self.seg = vision.ImageSegmenter.create_from_options(vision.ImageSegmenterOptions(
+ base_options=BaseOptions(model_asset_path=os.path.join(ROOT, 'models', 'selfie_segmenter.tflite')),
+ running_mode=vision.RunningMode.VIDEO, output_confidence_masks=True, output_category_mask=False))
+ self.fd = cv2.FaceDetectorYN.create(os.path.join(ROOT, 'models', 'yunet.onnx'), '', (aw, ah), 0.6, 0.3, 20)
+ self.prev = None
+
+ def __call__(self, rgb, ms):
+ img = self.mp.Image(image_format=self.mp.ImageFormat.SRGB, data=np.ascontiguousarray(rgb))
+ ms_ = self.seg.segment_for_video(img, ms).confidence_masks
+ m = ms_[-1].numpy_view().astype(np.float32); m = m.reshape(m.shape[0], m.shape[1])
+ if m.shape[:2] != rgb.shape[:2]: m = cv2.resize(m, (rgb.shape[1], rgb.shape[0]))
+ m = guided(cv2.cvtColor(rgb, cv2.COLOR_RGB2GRAY).astype(np.float32) / 255, m)
+ m = np.clip((m - 0.5) * 1.6 + 0.5, 0, 1)
+ if self.prev is not None: m = 0.65 * m + 0.35 * self.prev
+ self.prev = m
+ _, f = self.fd.detect(cv2.cvtColor(rgb, cv2.COLOR_RGB2BGR))
+ face = None
+ if f is not None and len(f):
+ r = max(f, key=lambda r: r[2] * r[3] * r[-1]); face = (r[0] + r[2] / 2, r[1] + r[3] / 2, r[2])
+ else:
+ rows = np.where((m > 0.5).sum(1) > m.shape[1] * 0.01)[0]
+ if len(rows):
+ top = rows[0]; band = m[top:top + max(4, int(m.shape[0] * 0.06))] > 0.5; xs = np.where(band.any(0))[0]
+ fw = max(8.0, (xs.max() - xs.min()) * 0.8); face = (float(xs.mean()), top + fw * 0.7, fw)
+ return (m * 255).astype(np.uint8), face
+
+
+def smooth(vals, fps, tau=0.18):
+ idx = [i for i, v in enumerate(vals) if v is not None]
+ if not idx: return None
+ arr = np.array([vals[i] if vals[i] is not None else (np.nan,) * 3 for i in range(len(vals))], np.float64)
+ for k in range(3):
+ col = arr[:, k]; good = ~np.isnan(col); col[~good] = np.interp(np.where(~good)[0], np.where(good)[0], col[good]); arr[:, k] = col
+ a = 1 - math.exp(-1 / (fps * tau)) # forward then backward pass, so the smoothing has no lag
+ for i in range(1, len(arr)): arr[i] = arr[i - 1] + a * (arr[i] - arr[i - 1])
+ for i in range(len(arr) - 2, -1, -1): arr[i] = arr[i + 1] + a * (arr[i] - arr[i + 1])
+ return arr
+
+
+class Ctx: pass
+
+
+class Fx:
+ def __init__(self, d, fps):
+ self.name = d['fx']; self.start = float(d['start']); self.end = float(d['end']); self.d = max(0.05, self.end - self.start)
+ self.o = {k: v for k, v in d.items() if k not in ('fx', 'start', 'end')}; self.state = {}; self.cards = []
+
+
+def load_cards(folder, thumbs):
+ out = []
+ if folder and os.path.isdir(folder):
+ for n in sorted(os.listdir(folder)):
+ p = os.path.join(folder, n); ext = n.lower().rsplit('.', 1)[-1]
+ if ext in ('jpg', 'jpeg', 'png', 'webp'): out.append(Image.open(p).convert('RGB'))
+ elif ext in ('mp4', 'mov', 'm4v', 'webm'):
+ cap = cv2.VideoCapture(p); cap.set(cv2.CAP_PROP_POS_MSEC, 1000); ok, fr = cap.read(); cap.release()
+ if ok: out.append(Image.fromarray(cv2.cvtColor(fr, cv2.COLOR_BGR2RGB)))
+ return out or thumbs
+
+
+def main():
+ ap = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
+ ap.add_argument('args', nargs='*', help='[effect] input.mp4 output.mp4')
+ ap.add_argument('--plan'); ap.add_argument('--start', type=float); ap.add_argument('--end', type=float)
+ ap.add_argument('--text'); ap.add_argument('--images'); ap.add_argument('--opt', action='append', default=[], help='key=value')
+ ap.add_argument('--still', help='comma-separated seconds: save PNG check frames instead of a video')
+ ap.add_argument('--width', type=int, default=1080, help='short side of the output (1080 default, 2160 for 4K)')
+ ap.add_argument('--list', action='store_true')
+ a = ap.parse_args()
+ if a.list:
+ for i, (k, (_, d)) in enumerate(EFFECTS.items()): print(f'{i + 1:2d}. {k:15s} {d}')
+ return
+ if a.plan:
+ src, dst = a.args[0], a.args[1]; plan = json.load(open(a.plan))
+ plan = plan.get('effects', plan) if isinstance(plan, dict) else plan
+ else:
+ name, src, dst = a.args[0], a.args[1], a.args[2]
+ d = {'fx': name, 'start': a.start or 0.0, 'end': a.end if a.end is not None else 1e9}
+ if a.text: d['text'] = a.text
+ if a.images: d['images'] = a.images
+ for kv in a.opt: k, v = kv.split('=', 1); d[k] = v
+ plan = [d]
+ for d in plan:
+ d['fx'] = ALIASES.get(d['fx'].lower().lstrip('/'), d['fx'].lower().lstrip('/'))
+ if d['fx'] not in EFFECTS: sys.exit(f"Unknown effect '{d['fx']}'. Run --list to see all 22.")
+ fr, fps, dur, sw, sh = probe(src)
+ for d in plan: d['end'] = min(float(d['end']), dur)
+ if sw <= sh: W = a.width; H = int(round(a.width * sh / sw / 2)) * 2
+ else: H = a.width; W = int(round(a.width * sw / sh / 2)) * 2
+ aw = 540 if sw <= sh else int(round(540 * sw / sh / 2)) * 2; ah = int(round(aw * sh / sw / 2)) * 2
+ fxs = [Fx(d, fps) for d in plan]
+ inwin = lambda t: any(f.start - 0.5 <= t < f.end + 0.5 for f in fxs)
+ print(f'Pass 1: tracking you ({len(fxs)} effect{"s" * (len(fxs) > 1)})...', flush=True)
+ trk = Tracker(aw, ah); masks, faces, thumbs = {}, [], []
+ n_thumb = 10; thumb_at = {int(dur * fps * (j + 0.5) / n_thumb) for j in range(n_thumb)}
+ for i, fr_ in enumerate(read_frames(src, aw, ah, fr)):
+ t = i / fps
+ if i in thumb_at: thumbs.append(Image.fromarray(fr_.copy()))
+ if inwin(t):
+ m, f = trk(fr_, int(t * 1000)); masks[i] = m; faces.append(f)
+ else:
+ faces.append(None); trk.prev = None
+ sm = smooth(faces, fps)
+ if sm is None: sm = np.tile([aw / 2, ah * 0.33, aw * 0.15], (len(faces), 1))
+ for f in fxs:
+ if f.name in ('noise', 'orbit'): f.cards = load_cards(f.o.get('images'), thumbs)
+ stills = sorted({int(round(float(s) * fps)) for s in a.still.split(',')}) if a.still else None
+ enc = None
+ if not stills:
+ enc = subprocess.Popen(['ffmpeg', '-v', 'error', '-y', '-f', 'rawvideo', '-pix_fmt', 'rgb24', '-s', f'{W}x{H}', '-r', str(fr), '-i', '-',
+ '-i', src, '-map', '0:v', '-map', '1:a:0?', '-c:v', 'libx264', '-crf', '17', '-preset', 'medium', '-pix_fmt', 'yuv420p',
+ '-c:a', 'aac', '-b:a', '192k', '-shortest', '-movflags', '+faststart', dst], stdin=subprocess.PIPE)
+ print('Pass 2: adding the effects...', flush=True)
+ sc = W / aw; total = int(dur * fps)
+ for i, frame in enumerate(read_frames(src, W, H, fr)):
+ t = i / fps
+ act = [f for f in fxs if f.start <= t < f.end]
+ if stills is not None and i not in stills:
+ if i > stills[-1]: break
+ continue
+ if act:
+ c = Ctx(); c.W, c.H, c.t, c.fps = W, H, t, fps
+ c.img = frame.astype(np.float32) / 255.0
+ m = masks.get(i)
+ c.m = cv2.resize(m, (W, H), interpolation=cv2.INTER_LINEAR).astype(np.float32) / 255.0 if m is not None else np.zeros((H, W), np.float32)
+ fx_, fy_, fw_ = sm[min(i, len(sm) - 1)]; c.fx, c.fy, c.fw = fx_ * sc, fy_ * sc, max(fw_ * sc, W * 0.05)
+ for f in act:
+ c.lt = t - f.start; EFFECTS[f.name][0](c, f)
+ frame = (np.clip(c.img, 0, 1) * 255 + 0.5).astype(np.uint8)
+ if stills is not None:
+ out = dst if len(stills) == 1 else dst.replace('.png', f'_{t:.2f}.png')
+ cv2.imwrite(out, cv2.cvtColor(frame, cv2.COLOR_RGB2BGR)); print('saved', out)
+ else:
+ enc.stdin.write(frame.tobytes())
+ if i % int(fps * 5) == 0: print(f' {t:5.1f}s / {dur:.1f}s', flush=True)
+ if enc: enc.stdin.close(); enc.wait(); print('Done:', dst)
+
+
+if __name__ == '__main__':
+ main()
diff --git a/scripts/setup.sh b/scripts/setup.sh
new file mode 100755
index 0000000..87f44cf
--- /dev/null
+++ b/scripts/setup.sh
@@ -0,0 +1,27 @@
+#!/usr/bin/env bash
+# One-time setup for the effects skill. Safe to run again: it prints READY when everything is in place.
+set -e
+cd "$(dirname "$0")/.."
+
+if ! command -v ffmpeg >/dev/null 2>&1 || ! command -v ffprobe >/dev/null 2>&1; then
+ echo "NEED_FFMPEG: install ffmpeg first (Mac: brew install ffmpeg, Windows: winget install ffmpeg)"; exit 1
+fi
+if [ -x .venv/bin/python ] && .venv/bin/python -c "import mediapipe, cv2, PIL, numpy" 2>/dev/null; then echo READY; exit 0; fi
+
+PY=""
+for v in python3.12 python3.11 python3.13 python3.10 python3; do
+ if command -v "$v" >/dev/null 2>&1 && "$v" -c 'import sys; sys.exit(0 if sys.version_info[:2] >= (3, 10) else 1)' 2>/dev/null; then PY="$v"; break; fi
+done
+
+if [ -n "$PY" ]; then
+ "$PY" -m venv .venv
+ .venv/bin/python -m pip install -q --upgrade pip
+ .venv/bin/python -m pip install -q -r requirements.txt
+elif command -v uv >/dev/null 2>&1; then
+ uv venv -q -p 3.12 .venv
+ uv pip install -q -p .venv/bin/python -r requirements.txt
+else
+ echo "NEED_PYTHON: install Python 3.10 or newer (python.org/downloads), then run this again"; exit 1
+fi
+
+.venv/bin/python -c "import mediapipe, cv2, PIL, numpy; print('READY')"
diff --git a/scripts/words.py b/scripts/words.py
new file mode 100755
index 0000000..fe3e26c
--- /dev/null
+++ b/scripts/words.py
@@ -0,0 +1,29 @@
+#!/usr/bin/env python3
+"""Find when each word is said, so effects can land on the right word.
+
+usage: python words.py input.mp4 -> prints "12.34 word" lines and saves input.words.json
+Uses faster-whisper (installed into the skill's .venv on first run). On a Mac with mlx-whisper installed, that is used instead.
+"""
+import json, os, subprocess, sys
+
+src = sys.argv[1]
+out = os.path.splitext(src)[0] + '.words.json'
+words = []
+try:
+ import mlx_whisper
+ r = mlx_whisper.transcribe(src, path_or_hf_repo='mlx-community/whisper-large-v3-turbo', word_timestamps=True)
+ words = [{'w': w['word'].strip(), 's': round(w['start'], 2), 'e': round(w['end'], 2)} for seg in r['segments'] for w in seg.get('words', [])]
+except ImportError:
+ try:
+ from faster_whisper import WhisperModel
+ except ImportError:
+ print('Installing the transcriber (one time, about 1 minute)...', flush=True)
+ subprocess.run([sys.executable, '-m', 'pip', 'install', '-q', 'faster-whisper'], check=True)
+ from faster_whisper import WhisperModel
+ model = WhisperModel(os.environ.get('WHISPER_MODEL', 'base'), device='cpu', compute_type='int8')
+ segs, _ = model.transcribe(src, word_timestamps=True, vad_filter=True)
+ words = [{'w': w.word.strip(), 's': round(w.start, 2), 'e': round(w.end, 2)} for s in segs for w in (s.words or [])]
+
+json.dump(words, open(out, 'w'), indent=0)
+for w in words: print(f"{w['s']:7.2f} {w['w']}")
+print(f'\nSaved {len(words)} words to {out}')