<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: meme</title>
    <description>The latest articles on DEV Community by meme (@meme_9f3abc29eb312e14a70f).</description>
    <link>https://dev.to/meme_9f3abc29eb312e14a70f</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4279525%2F706f9da0-27ae-4827-93f4-72f5b7d00c9b.png</url>
      <title>DEV Community: meme</title>
      <link>https://dev.to/meme_9f3abc29eb312e14a70f</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/meme_9f3abc29eb312e14a70f"/>
    <language>en</language>
    <item>
      <title>How I built a browser-only MP4 and GIF meme studio on Cloudflare Workers, Canvas, and Web Audio</title>
      <dc:creator>meme</dc:creator>
      <pubDate>Thu, 03 Dec 2026 02:58:46 +0000</pubDate>
      <link>https://dev.to/meme_9f3abc29eb312e14a70f/how-i-built-a-browser-only-mp4-and-gif-meme-studio-on-cloudflare-workers-canvas-and-web-audio-3chn</link>
      <guid>https://dev.to/meme_9f3abc29eb312e14a70f/how-i-built-a-browser-only-mp4-and-gif-meme-studio-on-cloudflare-workers-canvas-and-web-audio-3chn</guid>
      <description>&lt;p&gt;Most short-form meme editors either require a heavy mobile app like Alight Motion or upload your photos to a remote server and stamp a watermark on the export. I wanted a tool that builds beat-synced tweenslop videos and looping GIFs locally in the browser, with no account and no server rendering bill.&lt;/p&gt;

&lt;p&gt;That project became &lt;a href="https://tweenslopmaker.com/" rel="noopener noreferrer"&gt;Tweenslop Maker&lt;/a&gt;. It runs on Cloudflare Workers for server-rendered HTML and does all image processing, 2D animation, audio synthesis, and MP4/GIF encoding on the user's device.&lt;/p&gt;

&lt;p&gt;Here are the five engineering problems I ran into while shipping it and how I fixed them.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Avoiding bad cutouts on real photos
&lt;/h2&gt;

&lt;p&gt;Users upload clean PNG stickers, Roblox avatars, and messy bedroom photos of their cats. Running an aggressive automatic background removal pass on a cluttered pet photo produces jagged blobs.&lt;/p&gt;

&lt;p&gt;Instead of forcing one cutout mode on every upload, the editor checks background uniformity when an image loads. Clean backgrounds go straight to automatic cutout. Busy real-life photos default to a 512px rounded white-border sticker card. Users can switch between Rounded, Circle, and Auto Cutout in one click without re-uploading.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Speeding up client-side GIF encoding by 35.6x
&lt;/h2&gt;

&lt;p&gt;Discord and meme creators want looping GIFs in addition to MP4 clips, so I built a dedicated &lt;a href="https://tweenslopmaker.com/gif" rel="noopener noreferrer"&gt;GIF maker route&lt;/a&gt;. Early tests on mobile phones were painfully slow because nearest-color palette matching scanned the color table for every pixel on every frame.&lt;/p&gt;

&lt;p&gt;Precomputing a color lookup table (LUT) replaced the inner loop with an array index read. That single change made client-side GIF encoding 35.6x faster and made 360x640 multi-second loops practical on mid-range phones.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Keeping Web Audio and Canvas in sync on iOS Safari
&lt;/h2&gt;

&lt;p&gt;The &lt;a href="https://tweenslopmaker.com/studio" rel="noopener noreferrer"&gt;full studio&lt;/a&gt; combines 16 preset animation templates, pixel rainbow trails, a 4-character Squad Mode, and a 16-step beat machine for Brazilian Funk and Dark Phonk loops.&lt;/p&gt;

&lt;p&gt;iOS Safari is strict about two things:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;code&gt;AudioContext&lt;/code&gt; stays suspended until a direct user tap resumes it.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;MediaRecorder&lt;/code&gt; codec support differs from desktop Chrome.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I moved &lt;code&gt;AudioContext&lt;/code&gt; creation and &lt;code&gt;resume()&lt;/code&gt; directly inside tap handlers, bound the animation clock to the audio timeline instead of raw &lt;code&gt;setInterval&lt;/code&gt; ticks, and targeted 5 Mbps H.264 output where supported with automatic WebM fallback. I also capped default squash-and-stretch scaling at 1.85:1 at 100% Chaos so fast beat drops stay funny without turning the photo into an unreadable smear.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Bundling 8 royalty-free beats without bloating page load
&lt;/h2&gt;

&lt;p&gt;Audio tools often suffer from huge initial payloads. The beat library lives on a dedicated &lt;a href="https://tweenslopmaker.com/songs" rel="noopener noreferrer"&gt;songs page&lt;/a&gt; with 8 royalty-free tracks (including 138 BPM and 142 BPM Brazilian Funk loops) that users can preview, download as WAV, or send straight into the sequencer.&lt;/p&gt;

&lt;p&gt;Audio buffers load on demand rather than on initial page render. Non-editor routes ship stripped-down JavaScript bundles between 3.45 kB and 19.0 kB.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Fixing Core Web Vitals on Cloudflare Workers
&lt;/h2&gt;

&lt;p&gt;Cloudflare Workers renders all 36 pages from TypeScript templates with static assets served under &lt;code&gt;public, max-age=31536000, immutable&lt;/code&gt; headers. During real-device testing, two layout shifts showed up: preview cards resized after images decoded, and web fonts reflowed headings.&lt;/p&gt;

&lt;p&gt;Reserving explicit aspect ratios across breakpoints cut desktop CLS on &lt;code&gt;/songs&lt;/code&gt; from 0.4006 to 0.0044. Switching template previews to 640x360 WebP assets (12 KB to 25 KB each) with &lt;code&gt;fetchpriority="high"&lt;/code&gt; brought template gallery LCP down to 1,500 ms and kept mobile INP between 16 ms and 120 ms.&lt;/p&gt;

&lt;h2&gt;
  
  
  Try it and poke holes in it
&lt;/h2&gt;

&lt;p&gt;Everything runs locally in your browser with no login and no watermark:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Main editor: &lt;a href="https://tweenslopmaker.com/" rel="noopener noreferrer"&gt;Tweenslop Maker&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;4-tab editor and 16-step beat machine: &lt;a href="https://tweenslopmaker.com/studio" rel="noopener noreferrer"&gt;Tweenslop Studio&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Looping GIF exporter: &lt;a href="https://tweenslopmaker.com/gif" rel="noopener noreferrer"&gt;Tweenslop GIF Maker&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Free WAV beat library: &lt;a href="https://tweenslopmaker.com/songs" rel="noopener noreferrer"&gt;Tweenslop Songs&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you have hit strange &lt;code&gt;MediaRecorder&lt;/code&gt; quirks on mobile Safari or have ideas for faster client-side MP4 muxing, I would love to hear how you solved them in the comments.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>cloudflare</category>
      <category>webaudio</category>
    </item>
  </channel>
</rss>
