CHAT: find a stream's best moments from chat spikes and cut them into vertical clips
When something big happens on stream, chat explodes. This one-file script finds those spikes and turns each one into a vertical 9:16 clip that starts 20 seconds early, so you catch the build-up.
Affiliate disclosure: this page contains affiliate links. If you sign up for a paid plan through them, we earn a commission.
Only clip streamers who allow it. Ask first, or check the streamer's rules on clips and reuploads.
On your phone? This runs on a computer. Open this page on your laptop or desktop.
What it does
- Counts chat messages in every 10-second window of a Twitch stream.
- Finds the top 5 spikes (you can pick how many), skipping any that overlap.
- Cuts a vertical 9:16 clip for each spike, starting 20 seconds before it, 45 seconds long. The center of the video is cropped to fill the frame.
- Saves the clips in one folder, named by rank and time, plus
spikes.txt: the time, the message count and the top words in chat for each spike.
Option A: download the script
One Python file, 11 KB. It uses only Python's standard library plus ffmpeg, so there's nothing else to install. It reads your two files and writes clips to a folder. It doesn't go online.
Option B: have Claude build it
This is the exact prompt we gave Claude. Fable 5.2 wrote the script above in about 3 minutes, and we didn't change anything.
Build me a one-command tool that finds the best clips in a Twitch stream by looking at chat.
Input: the chat file (JSON) I download with TwitchDownloader, and the stream video file.
1. Count chat messages in every 10-second window.
2. Find the top N spikes (default 5) — the moments chat explodes. Don't pick spikes that overlap each other.
3. For each spike, cut a vertical 9:16 clip that starts 20 seconds before the spike (default length 45 seconds) with ffmpeg. Crop the center of the video to fill the vertical frame.
4. Save all clips in one folder, named by rank and timestamp, plus a small text file listing each spike (time, message count, top words in chat).
Make it a single Python file I can run with one command, like:
python chat_clips.py chat.json stream.mp4
Only use Python's standard library + ffmpeg (no extra installs). Print a short summary at the end.Claude may write a slightly different script each time. The steps below are for our file.
How to run it, step by step
Everything below is free and works on Windows or Mac. You only do steps 1 to 3 once. Never used a terminal? It's a window where you paste a command and press Enter. Every grey box below has a Copy button.
1. Install Python
- Go to python.org/downloads and download the installer for your computer.
- Windows: on the first installer screen, tick "Add python.exe to PATH" before you click Install. If you skip this box, the commands below won't work.
- Mac: open the downloaded file and click through the installer.
To check it worked, open a new terminal (Windows: Start menu, type PowerShell. Mac: press Cmd + Space, type Terminal) and paste:
python --versionpython3 --versionYou should see a version number like Python 3.x.x. On a Mac, always type python3 where this guide says python.
2. Install ffmpeg
ffmpeg is the free video tool that cuts the clips. Paste one line into the terminal:
winget install Gyan.FFmpegbrew install ffmpegWindows: if it asks you to agree to the source terms, type Y and press Enter. Mac: if brew isn't found, install Homebrew first from brew.sh. Then close the terminal, open a new one and check with ffmpeg -version.
3. Make a folder with two files
- Make a new folder on your Desktop, for example
chatclips. - Put
chat_clips.pyin it (the download button above). - Get TwitchDownloaderCLI: open the TwitchDownloader releases page (free, open source), find the newest release and download the CLI zip for your computer: Windows, or macOS (Arm64 for M1 to M4 Macs, x64 for Intel Macs). Unzip it and move
TwitchDownloaderCLIinto the same folder.
4. Open the terminal inside that folder
- Windows: open the folder, right-click an empty spot and choose Open in Terminal.
- Mac: open Terminal, type
cdand a space, drag the folder into the window, then press Enter. The first time, also run the line below so your Mac lets the downloader start. If macOS still blocks it, go to System Settings → Privacy & Security and click Open Anyway.
chmod +x TwitchDownloaderCLIType dir (Windows) or ls (Mac) and press Enter. You should see both files.
5. Download the stream's chat and video
On Twitch, open the streamer's Videos page, pick a past broadcast and copy its link. In the commands below, replace https://twitch.tv/videos/1234567890 with your link.
.\TwitchDownloaderCLI.exe chatdownload --id https://twitch.tv/videos/1234567890 -o chat.json
.\TwitchDownloaderCLI.exe videodownload --id https://twitch.tv/videos/1234567890 -o stream.mp4./TwitchDownloaderCLI chatdownload --id https://twitch.tv/videos/1234567890 -o chat.json
./TwitchDownloaderCLI videodownload --id https://twitch.tv/videos/1234567890 -o stream.mp4The chat takes a minute or two. The video is the whole broadcast, so a long stream can be several GB and take a while. For your first try, pick a shorter one. Subscriber-only or expired videos can't be downloaded.
6. Run the clip finder
python chat_clips.py chat.json stream.mp4You get a folder named stream_clips with the vertical clips and spikes.txt. (Mac: python3 instead of python.)
Want more clips, longer clips or a different folder? Add options:
python chat_clips.py chat.json stream.mp4 -n 8 --length 60 -o my_clips-n = number of clips, --length = seconds per clip, -o = output folder. Add --dry-run to see the spikes without cutting anything. If you trimmed the start of the video, use --chat-offset (for example -600 for 10 minutes) so the chat times line up.
If something goes wrong
- "python is not recognized", or the Microsoft Store opens: Python isn't on PATH. Run the installer again, tick "Add python.exe to PATH", then open a new terminal.
- "ffmpeg not found on PATH": close the terminal and open a new one. Still there? Repeat step 2.
- "chat file not found" or "video file not found": the terminal isn't in your folder, or the file names are different. Redo step 4 and check the names with
dirorls. - "chat file has no 'comments' list": the chat was saved in another format. Download it again with
-o chat.json. - "no chat spikes fall inside the video": the video and chat don't match. Download both from the same link, or see
--chat-offsetabove. - Anything else: paste the exact error and the command you ran into Claude. It can usually tell you what to fix.
How we tested it
- We ran it once on our own 10-minute sample: a test video with a big clock on screen and 996 made-up chat messages in TwitchDownloader's JSON format.
- It cut 5 vertical clips (1080 × 1920, 45 seconds each) in 47 seconds.
- The 3 chat explosions we planted came out as #1 to #3, in the right order. Each clip started exactly 20 seconds before its spike: the 5:40 spike's clip opens at 5:20 on the clock.
- We haven't tested it on a real Twitch stream yet, so on a real stream the results may differ. If your stream has fewer than 5 big spikes, the last clips may just be ordinary moments.
Next step: captions, or no code at all (OpusClip)
- After the script: the clips come out with no captions. Add them in any editor, or try OpenShorts, the one in the Reel (open source, free if you run it yourself). OpusClip is another option: it adds captions and reframes clips for vertical video.
- If you'd rather not run code: OpusClip clips long videos in your browser, with no code.
- What it costs (official pricing page, checked Nov 2026): the Free plan gives 60 minutes of video a month, with a watermark, and clips expire after 3 days. Starter is $15 a month for 150 minutes; Pro is $29 a month for 300 minutes. Twitch links work on Pro only; on Free, upload the video file instead.
- Same rule here: only clip streamers who allow it.
No coding? Paste a past stream's link into OpusClip (or upload the video file on the Free plan), and it cuts vertical clips with captions for you.
Try OpusClip free → Affiliate link
Full breakdown of plans and credits: OpusClip free plan limits and pricing.
More GTA 6: clip GTA 6 streams with Claude Code (free clipper + GTA plugin).
Made for our Instagram Reel. More Claude experiments every week: @theoautomates