Inspiration
Twitch streamers generate hours of high-energy live content every day, yet discoverability happens on vertical short-form platforms (TikTok, YouTube Shorts, Instagram Reels).
Currently, turning a hype live Twitch moment into a vertical 9:16 Short requires downloading massive VODs, importing them into heavy desktop video editors, manually cropping 16:9 gameplay + facecam, adding streamer/clipper attribution watermarks, and brainstorming viral titles—or paying steep monthly subscription fees for cloud GPU clipping services.
We asked: What if a live Twitch viewer typing !clip in chat—or a sudden surge of POG / LUL chat hype—could instantly slice the last 30 seconds of a stream directly in the browser, auto-crop it to 9:16 vertical format with facecam + gameplay, stamp the viewer's handle on screen, and generate a viral hook using OpenAI Codex—with \$0 server bandwidth fees?
What it does
StreamClip AI is a 100% client-side, zero-server-cost live clipping and 9:16 vertical production engine built for Twitch streamers and their communities:
- Dual Staggered 30s Rolling Browser Buffer: Continuously captures the rendered
720x1280(9:16) vertical canvas stream and audio tracks in memory using dual staggeredMediaRecorderslots (2.5 MbpsVP8)—using zero disk space until a clip is triggered and exporting ready-to-play.webmfiles in under0.3s. - Zero-OAuth Live Twitch Chat Trigger (
!clip): Connects directly to any live Twitch channel via Twitch's anonymous IRC WebSocket (wss://irc-ws.chat.twitch.tv:443). When any viewer types!clipin live chat, StreamClip AI automatically captures the last 30 seconds and credits the viewer on-screen (⚡ Clipped by @username). - 🔥 Automatic Chat Hype-Spike Detector: Tracks a 7-second sliding window of live Twitch chat velocity and hype emotes (
POG,LUL,KEKW,OMG,CLUTCH,CLIP,🔥). When chat velocity hits 100%, StreamClip AI automatically triggers a 30-second vertical clip (🔥 Clipped by @ChatHypeSpike) even if nobody typed!clip. - 4 Real-Time 9:16 Smart Crop Layouts + Interactive Framing:
- Center Crop (Crosshair / Action): Crops 16:9 gameplay to vertical 9:16 focused on the action zone.
- Split: Top-Right Facecam + Gameplay: Stacks the streamer's top-right webcam in the top 34% and center gameplay in the bottom 66% with a neon Twitch divider.
- Split: Top-Left Facecam + Gameplay: Dedicated split layout for streamers with top-left webcams.
- Pillarbox Blur Background: Centers the full 16:9 frame over a dynamically blurred vertical backdrop.
- Smart Video Framing (
Pan X / Pan Y / Zoom+📺 Fit YouTube / Twitch TabPreset): Allows instant 1-click framing to crop out white webpage sidebars when capturing non-fullscreen browser tabs.
- OpenAI Codex Viral Hook Banner & Caption Engine: Renders an editable TikTok/Shorts hook banner directly onto the 9:16 video canvas and generates 3 copy-ready viral titles and hashtag packs tailored to the streamer and clipper.
- Multi-Clip Session Vault & Cover Extractor: Stores every captured clip during a stream session with instant in-browser playback, 1-click
.webmvideo download, and an automatically extracted720x1280.jpgcover thumbnail.
How we built it
We used OpenAI Codex as our core engineering co-pilot to architect, debug, and optimize the real-time media and networking pipelines in our repository (GitHub Repository):
- Real-Time 9:16 Canvas Compositor (
CanvasPipeline): Used Codex to design the720x1280vertical compositor that transforms any1280x720(16:9) screen/tab capture or synthetic stream into 4 switchable vertical layouts with glassmorphic streamer badges, viewer attribution pills, and lower-third viral hook banners. - Dual Staggered Rolling Recorders (
RollingClipBuffer): StandardMediaRecorderchunk-shifting corrupts.webmfiles because the EBML initialization header only lives inchunk[0]. With OpenAI Codex, we engineered a Dual Staggered Recorder architecture (Slot Astarting at0sandSlot Boffset at15s, rotating every32s) so every sliced clip retains a valid initialization header and exports instantaneously without waiting on single-threaded WASM re-encoding. - Native Twitch IRCv3 WebSocket Parser & Hype Engine (
TwitchIRC): Used Codex to write a zero-dependency WebSocket client that performs the anonymousjustinfanhandshake overwss://irc-ws.chat.twitch.tv:443, responds toPING/PONGheartbeats, parses IRCv3 messages in real time, and calculates rolling chat hype velocity.
Challenges we ran into
- WebM Header Corruption in Rolling Buffers: Simply calling
recordedChunks.shift()after 30 seconds strips the WebM EBML header fromchunk[0], producing unplayable video downloads. Solving this with dual staggeredMediaRecorderinstances ensured every 15–30s window starts with a clean keyframe and initialization segment and exports in< 0.3s. - Background-Tab
requestAnimationFrameThrottling: When capturing another browser tab viagetDisplayMedia, Chrome focuses the captured tab and throttlesrequestAnimationFrame()in the backgroundStreamClip AItab to0 FPS, causing frozen video exports. We solved this by pairingrequestAnimationFramewith a33ms(30 FPS) background timer driver and asynchronouscanvas.toBlob()thumbnail extraction so recording stays butter-smooth at 30 FPS even whenStreamClip AIis in an unfocused tab. - Cropping Out Browser UI on Non-Fullscreen Streams: Capturing a standard YouTube or Twitch tab often includes webpage margins or sidebars. We built real-time
Pan X,Pan Y, andCrop Zoomsliders plus a 1-click📺 Fit YouTube / Twitch Tabpreset (panX: 28%,panY: 34%,zoom: 1.5x) to lock straight onto the video player.
Accomplishments that we're proud of
- \$0 Cloud GPU Costs & Instant
< 0.3sExports: Everything runs natively in the browser at 30 FPS using HTML5 Canvas andMediaRecorderwithout server uploads or slow transcoding queues. - Dual Community Triggers (
!clip+ Automatic Chat Hype-Spike): Combines intentional viewer clipping (!clip) with automatic emote-velocity detection (POG/LULwaves) so streamers never miss a clutch moment while focused on gameplay. - Built-In Community Attribution: Viewers love seeing their handle (
⚡ Clipped by @Viewer) permanently baked into a streamer's official TikTok or YouTube Short, turning passive viewers into active clip hunters. - Zero-Friction Live Testing: Works out of the box with live screen/tab capture (
getDisplayMedia), real Twitch chat channels, and a built-in 60 FPS synthetic gameplay + chat hype simulator for instant browser testing.
What we learned
- How to synchronize HTML5
<video>,<canvas>compositing, background-tab timer drivers, andMediaRecorderbitrates (2.5 MbpsVP8) for smooth, zero-freeze vertical video output. - How effectively OpenAI Codex can diagnose and solve subtle browser media pitfalls—including WebM EBML header preservation, background-tab frame throttling, and real-time IRCv3 WebSocket stream parsing.
What's next for StreamClip AI
- OBS Studio Custom Dock & Browser Source: Embed StreamClip AI directly inside OBS Studio so streamers can run it without an extra browser window.
- Microphone Audio-Peak Auto-Trigger: Combine our Twitch Chat Hype-Spike Detector with Web Audio API decibel spike detection (streamer reactions/laughter) for multimodal auto-clipping.
- Direct TikTok & YouTube Shorts OAuth Publishing: One-click upload directly from the StreamClip AI Session Vault to YouTube Shorts and TikTok drafts.
Built With
- css3
- html5
- javascript
- mediarecorder
- openai-codex
- twitch
- webrtc
- websockets
Log in or sign up for Devpost to join the conversation.