If you have ever compressed a screen recording to "20 MB" in a browser tool only for Discord or GitHub to reject the upload with a file-size error, you ran into a classic systems mismatch. Naive web compressors compute a target video bitrate using targetBytes * 8 / durationSeconds - audioBitrate, run a single-pass libx264 encode, and hand back whatever file drops out of the muxer.
In practice, that formula overshoots strict platform upload gates routinely. While building a zero-upload FFmpeg WebAssembly pipeline—whose MIT-licensed preset builders and verifier live in savebylink-media-tools—we hit three distinct failure modes: binary-versus-decimal byte math, encoder/decoder compatibility traps on mobile captures, and browser linear-memory ceilings.
Before diving into the encoder pipeline, here is what strict upload gates actually enforce as of late 2026:
| Platform / Context | Advertised Cap | Strict Decimal Limit | Binary Equivalent | Safe 0.88x MiB Target | Operational Notes |
|---|---|---|---|---|---|
| Discord (Free) | 20 MB | 20,000,000 B (19.07 MiB) | 20,971,520 B (20 MiB) | 17.60 MiB (~18.45M B) | Raised from 10 MB in Aug 2026; Nitro Basic is 50 MB, Nitro is 1 GB |
| GitHub Issues (Free) | 10 MB | 10,000,000 B (9.54 MiB) | 10,485,760 B (10 MiB) | 8.80 MiB (~9.23M B) | Hard rejection on PR/issue drag-and-drop |
| Legacy Bots & Forums | 8 MB | 8,000,000 B (7.63 MiB) | 8,388,608 B (8 MiB) | 7.04 MiB (~7.38M B) | Common webhook and phpBB/Discourse defaults |
| Outlook.com / iCloud Mail | 20 MB | 20,000,000 B (19.07 MiB) | 20,971,520 B (20 MiB) | 17.60 MiB (~18.45M B) | Per-message attachment ceiling |
| Gmail | 25 MB | 25,000,000 B (23.84 MiB) | 26,214,400 B (25 MiB) | 22.00 MiB (~23.07M B) | Total message cap; corporate SMTP relays add ~33% Base64 MIME overhead |
Notice that last note on email: even if Gmail's web composer accepts a 24 MB binary attachment, forwarding that message through a strict corporate SMTP relay expands the payload by roughly 33% due to Base64 MIME encoding, pushing a 20 MB raw file past a 25 MB gateway limit.
Trap #1: Decimal MB vs. Binary MiB (and Single-Pass ABR Drift)
The fastest way to overshoot an upload gate is conflating SI decimal megabytes (10^6 bytes) with IEC binary mebibytes (2^20 bytes). Strict web upload validators commonly check file.size <= 20_000_000 (19.07 MiB) for a 20 MB cap or file.size <= 10_000_000 (9.54 MiB) for a 10 MB cap. If your compressor calculates bitrate against 20 MiB (20,971,520 bytes) or 10 MiB (10,485,760 bytes), you start out 4.86% over budget before a single frame is encoded.
On top of the unit mismatch, two codec realities eat into your byte budget:
- Container overhead: MP4 muxing adds
moovatom headers, sample tables (stts,stsz,stco), and interleaved chunk padding—typically 1% to 2.5% depending on clip length and framerate. - Single-pass ABR overshoot: In a browser where two-pass encoding doubles wall-clock time, single-pass average bitrate (
-b:v) withlibx264relies on a finite VBV lookahead window. High-entropy clips (confetti, foliage, rapid FPS camera pans) regularly finish 3% to 8% above the requested bitrate.
To absorb both the decimal/binary gap and single-pass variance, our preset builders target 0.88x binary MiB:
- 20 MB preset (live Discord 20 MB pipeline):
17.60 MiB(~18.45M bytes) - 10 MB preset (live GitHub 10 MB pipeline):
8.80 MiB(~9.23M bytes) - 25 MB preset (live Gmail 25 MB pipeline):
22.00 MiB(~23.07M bytes)
That gives -12% headroom against binary MiB and roughly 7.7% headroom against strict decimal MB. Even then, chaotic footage can occasionally spike past the ceiling. Rather than blindly handing back a 20.3 MB file, the pipeline runs an exact post-encode Uint8Array.byteLength check against the strict decimal limit and triggers a single proportional retry pass if it overshoots:
const DECIMAL_MB = 1_000_000; const BINARY_MIB = 1_048_576; interface EncodeBudget { hardLimitBytes: number; targetBytes: number; videoKbps: number; audioKbps: number; } function buildBudget(limitMb: number, durationSec: number): EncodeBudget { const hardLimitBytes = limitMb * DECIMAL_MB; const targetBytes = Math.floor(limitMb * BINARY_MIB * 0.88); const audioKbps = durationSec > 180 ? 64 : 96; const totalKbps = Math.floor((targetBytes * 8) / (durationSec * 1000)); const videoKbps = Math.max(150, totalKbps - audioKbps); return { hardLimitBytes, targetBytes, videoKbps, audioKbps }; } async function encodeWithRetry( runFfmpeg: (vKbps: number, aKbps: number) => Promise<Uint8Array>, budget: EncodeBudget ): Promise<Uint8Array> { let output = await runFfmpeg(budget.videoKbps, budget.audioKbps); if (output.byteLength > budget.hardLimitBytes) { // Scale proportionally to the actual overshoot, plus a 5% damping margin const ratio = (budget.targetBytes / output.byteLength) * 0.95; const retryVideoKbps = Math.max(120, Math.floor(budget.videoKbps * ratio)); const retryAudioKbps = retryVideoKbps < 300 ? 64 : budget.audioKbps; output = await runFfmpeg(retryVideoKbps, retryAudioKbps); } return output; } In practice, the initial 0.88x budget passes on the first try for the vast majority of clips, while the proportional retry catches outlier footage without forcing every user to sit through two-pass encodes.
Trap #2: Odd-Dimension libx264 Crashes & iPhone 10-Bit HEVC Playback Failures
Getting the file under 20,000,000 bytes is useless if the encoder crashes mid-run or if Discord renders the resulting .mp4 as a grey download box.
Two real-world input quirks cause most silent failures:
- Odd pixel dimensions: Cropped desktop screen recordings and modern smartphone aspect ratios frequently produce odd widths or heights (for example,
1179x2556or arbitrary region captures). Standard H.264 4:2:0 chroma subsampling (yuv420p) requires both width and height to be divisible by 2. Passing an odd dimension straight tolibx264throwswidth/height not divisible by 2and aborts immediately. - iPhone 10-bit HEVC (
.mov) streams: Modern iPhones record 10-bit HDR HEVC (yuv420p10le,hvc1) by default. If you copy streams or preserve the source pixel format when transcoding, Discord's Electron wrapper and Chromium on Windows machines without hardware HEVC extensions fail to decode the video track inline, falling back to a generic downloadable file attachment.
We solve both problems and enable instant progressive playback with three explicit FFmpeg flags:
ffmpeg -i input.mov \ -vf "scale=-2:'trunc(min(1080,ih)/2)*2'" \ -c:v libx264 -preset ultrafast \ -pix_fmt yuv420p \ -b:v 1450k -maxrate 1668k -bufsize 2900k \ -c:a aac -b:a 96k -ac 2 \ -movflags +faststart \ output.mp4 Why each piece matters:
-
scale=-2:'trunc(min(1080,ih)/2)*2': Caps vertical resolution at 1080p without upscaling smaller clips (min(1080,ih)), truncates the height to an even integer (trunc(.../2)*2), and uses-2to compute the aspect-ratio-locked width rounded to the nearest even number. It handles landscape recordings, vertical phone clips, and odd-pixel desktop snips uniformly. -
-pix_fmt yuv420p: Downconverts 10-bit HEVC (yuv420p10le) and screen-capture RGB (yuv444p) to 8-bit 4:2:0, guaranteeing inline playback across Discord, GitHub, Safari, Firefox, and Windows Chromium. -
-movflags +faststart: Relocates the MP4moovmetadata atom from the end of the file to the beginning so browsers can parse duration and start decoding frames before downloading the entire payload.
Trap #3: Why We Enforce a 100 MB Client-Side RAM Ceiling
Running FFmpeg inside WebAssembly eliminates server upload queues and privacy exposure, but pretending the browser is a native workstation leads to OOM tab crashes.
In our general browser video compressor, we deliberately enforce a hard 100 MB input file ceiling on the single-threaded WASM core. Here is the engineering reasoning behind that boundary:
- MEMFS amplification: WebAssembly's Emscripten virtual filesystem stores the input file in JS/WASM heap memory as a
Uint8Array. During transcoding, browser RAM simultaneously holds the source file buffer, decoded uncompressed YUV frames,libx264lookahead buffers, and the growing output.mp4buffer. A 100 MB compressed H.264/HEVC input routinely drives peak tab memory several times higher. - 32-bit WASM linear memory & mobile Safari: Standard
wasm32address space and aggressive mobile browser memory watchdogs kill tabs silently once allocations spike toward ~1–2 GB. Capping inputs at 100 MB keeps single-threaded transcoding predictable across laptops and phones without requiringSharedArrayBuffer(which forces restrictive COOP/COEP headers that break third-party embeds). - Offline-ready footprint: The single-threaded FFmpeg WASM core weighs roughly 31 MB and caches cleanly in the browser. Once loaded, compression runs with zero network traffic.
We are candid about the trade-off: if you are compressing >100 MB 4K camera footage, or doing explicit two-pass 60→30 FPS gaming captures where you want hardware NVENC/VideoToolbox acceleration, do not use a browser compressor. Native desktop tools like HandBrake or Shutter Encoder will encode 5x to 10x faster with lower thermal load and unconstrained memory. A WASM pipeline shines specifically for sub-100 MB daily workflow clips—bug repros for GitHub Issues, quick iPhone clips for Discord, or email attachments—where uploading raw video to a third-party server is slower and riskier than transcoding locally.
How to Verify 0 Uploads Yourself in DevTools
Never take a "client-side only" claim on faith. You can audit the zero-upload behavior of our live tool—or any browser-based media processor—in under a minute:
- Open the video compressor in Chrome or Firefox and open DevTools → Network.
- Wait for the page to finish loading and confirm the ~31 MB FFmpeg WASM core is fetched and cached.
- Click Clear (
Ctrl+L) in the Network tab, then switch the network throttling dropdown from No throttling to Offline. - Drop a local
.mp4or.movclip (under 100 MB) into the page, select a target cap (such as 10 MB or 20 MB), and run compression. - Inspect the Network log: you should see 0 outbound POST/PUT requests and 0 bytes transferred, followed by a locally generated
.mp4Blob download that passes strict decimal byte checks.
All preset calculations, byte-budget helpers, and verification scripts discussed here are open-source under the MIT license in WaterJason/savebylink-media-tools if you want to inspect the exact math or drop the preset logic into your own FFmpeg wrapper.