Three things that broke when I moved video compression into the browser
I run a video compressor that works entirely in the browser . No upload, no server, nothing leaves the machine. Two of the three bugs below only showed up when I stopped reading code and started timing things, so I want to write them down while the numbers are still in front of me. The pipeline has three paths. If the file already meets the target, copy the encoded samples and encode nothing. If…
Three key issues emerged when moving video compression into the browser. First, timestamps were absent in AVI files, causing issues with copying the media. The fix involved adding the +genpts flag to ffmpeg, which generated presentation timestamps. Second, output sizes varied significantly between H.264 AVI and Xvid AVI files. The H.264 AVI compression with WebCodecs took just 7.5 seconds, resulting in a 12.3 MB file, while the Xvid AVI with ffmpeg.wasm took 53.4 seconds, yielding a 12.5 MB file.
Finally, the audio copy path was not always available due to encoder priming delay. This delay caused audio tracks to double in size compared to the source, rendering the passthrough path unusable. To address this, a floor was implemented to return the original source file if the copy would increase the file size.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.