<?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: MyClipDownloader</title>
    <description>The latest articles on DEV Community by MyClipDownloader (myclipdownloader).</description>
    <link>https://dev.to/myclipdownloader</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%2Forganization%2Fprofile_image%2F16563%2Fd0fb2205-3d07-4f21-a250-5ef605a7fedf.jpg</url>
      <title>DEV Community: MyClipDownloader</title>
      <link>https://dev.to/myclipdownloader</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/myclipdownloader"/>
    <language>en</language>
    <item>
      <title>How I built a video compressor that runs entirely in the browser (ffmpeg.wasm)</title>
      <dc:creator>Suudipta Mukherjjee</dc:creator>
      <pubDate>Sun, 29 Nov 2026 01:24:00 +0000</pubDate>
      <link>https://dev.to/myclipdownloader/how-i-built-a-video-compressor-that-runs-entirely-in-the-browser-ffmpegwasm-3lc9</link>
      <guid>https://dev.to/myclipdownloader/how-i-built-a-video-compressor-that-runs-entirely-in-the-browser-ffmpegwasm-3lc9</guid>
      <description>&lt;p&gt;Most "online video compressors" work the same way: you upload your file to someone's server, wait, and download the result. That's slow for big files and a privacy problem for personal ones.&lt;/p&gt;

&lt;p&gt;For &lt;a href="https://myclipdownloader.com/video-compressor/" rel="noopener noreferrer"&gt;MyClipDownloader&lt;/a&gt; I wanted the opposite: &lt;strong&gt;the file never leaves your device.&lt;/strong&gt; All the work happens in the browser tab using &lt;a href="https://github.com/ffmpegwasm/ffmpeg.wasm" rel="noopener noreferrer"&gt;ffmpeg.wasm&lt;/a&gt;. Here's what I learned building it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why ffmpeg.wasm
&lt;/h2&gt;

&lt;p&gt;FFmpeg compiled to WebAssembly gives you the real thing in a browser: the same codecs and filters, and the same command-line arguments. It's slower than native FFmpeg, but for clips of a few minutes it's perfectly usable, and you get:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;No upload time&lt;/strong&gt;: processing starts instantly, even on a slow connection&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No server costs&lt;/strong&gt; for heavy video encoding&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Privacy by design&lt;/strong&gt;: there's nothing to store, leak or delete&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The hard part: hitting an exact file size
&lt;/h2&gt;

&lt;p&gt;People don't think in bitrates. They think "Discord's limit is 10 MB" or "this email attachment must be under 25 MB". So the compressor offers &lt;strong&gt;size targets of 8, 10, 25 and 50 MB&lt;/strong&gt; instead of quality sliders.&lt;/p&gt;

&lt;p&gt;To hit a target you work backwards from the size:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;total bits available  = target size × 8
reserve a safety margin (I hold back ~8%) for container overhead
audio gets a fixed share (~12% of the budget)
video bitrate         = remaining bits ÷ duration in seconds
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then comes the step most people skip: &lt;strong&gt;choosing the resolution from the bitrate.&lt;/strong&gt; If you squeeze a 1080p video into 300 kbps, you get a blocky mess. A smaller frame at the same bitrate looks much better. So the encoder picks the output width from the bitrate it ended up with: a high bitrate keeps the full resolution, and as it drops the frame shrinks step by step.&lt;/p&gt;

&lt;p&gt;Two edge cases became their own clear messages instead of silent failures:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Already fits&lt;/strong&gt;: if the file is already under the target, re-encoding would only make it worse, so the tool says so.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Target too small&lt;/strong&gt;: if a 20-minute video is asked to fit in 8 MB, the bitrate would be unwatchable. Better to tell the user than to produce garbage.&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;The size-target logic is open source (MIT): &lt;a href="https://github.com/myclipdownloader/ffmpeg-wasm-target-size" rel="noopener noreferrer"&gt;ffmpeg-wasm-target-size on GitHub&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Videos that don't know how long they are
&lt;/h2&gt;

&lt;p&gt;Size targeting depends on knowing the duration. Some files, especially WebM recordings from browsers and screen recorders, &lt;strong&gt;don't store a duration at all.&lt;/strong&gt; Without it, the bitrate math divides by nothing.&lt;/p&gt;

&lt;p&gt;The fix: when the container has no duration, read the actual packet timestamps from the stream and measure the duration from those. It's a little slower, but it means those recordings compress correctly instead of failing.&lt;/p&gt;

&lt;h2&gt;
  
  
  Memory is the real limit
&lt;/h2&gt;

&lt;p&gt;WebAssembly runs inside the browser's memory limits, and video is big. Things that helped:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Clean up the virtual file system between jobs (delete inputs and outputs once they're done)&lt;/li&gt;
&lt;li&gt;Fail early with a clear message instead of letting the tab crash&lt;/li&gt;
&lt;li&gt;Keep the default output as plain H.264 MP4, which plays everywhere and encodes predictably&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What else runs on the same engine
&lt;/h2&gt;

&lt;p&gt;Once the engine existed, the other tools were mostly different FFmpeg arguments:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Trimmer&lt;/strong&gt;: cut a clip without uploading it&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Video → GIF&lt;/strong&gt;: palette generation for clean, small GIFs&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;GIF → video&lt;/strong&gt;, &lt;strong&gt;video → MP3&lt;/strong&gt;, &lt;strong&gt;video → MP4&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Try it
&lt;/h2&gt;

&lt;p&gt;The compressor is free, needs no account, and works in English, Español, Português, Français, 日本語 and ไทย:&lt;br&gt;
👉 &lt;strong&gt;&lt;a href="https://myclipdownloader.com/video-compressor/" rel="noopener noreferrer"&gt;https://myclipdownloader.com/video-compressor/&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you've built anything with ffmpeg.wasm, I'd love to hear what you ran into, especially around memory limits and mobile browsers.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>showdev</category>
      <category>webassembly</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
