| We are on the same wavelength chris_pie. ch_sm is correct, it is a performance issue. My first iteration of this was a chrome extension with ffmpeg.wasm, but there were multiple problems. 1. ffmpeg-wasm uses web-workers to attempt to parallelize the requests, but github has content security policies preventing the creation of web-workers from a chrome extension. 2. We can use the ffmpeg single core version, but the speed ends up being quite slow. I'm not 100% sure why but my best guess is because ffmpeg.wasm doesn't have access or take advantage of the computer's graphics card. The chrome extension background service worker is also only single threaded. 3. I did build a custom ffmpeg.wasm using Jerome Wu's blob as a guide to see if there was anyway to get the compression speed faster https://itnext.io/build-ffmpeg-webassembly-version-ffmpeg-js.... It worked, but was not faster. The speed difference can be significant. i.e. On my M2 macbook pro I was getting 14 fps compression speed, compared to a 260fps compression speed using native ffmpeg. This will vary, but I'd say around 5x to 15x improvement, similar to what ch_sm said. The ffmpeg configuration I use is:
ffmpeg -i inputPath -an -c:v libx264 -crf 28 -preset ultrafast output.mp4 Feel free to test it out. If you want to test ffmpeg.wasm on the browser with web-workers, I have a work in progress demo page. The site is not updated yet, but at the bottom on the site you can upload a video and test the FPS of the ffmpeg.wasm on your machine. You will notice small <30MB videos get higher FPS than larger videos. https://github-video-compressor.vercel.app/ The speed of the compression is important, because I wanted the whole compression + upload to be faster or take just as long as uploading the actual file. This does depend on the computer resources and internet speeds. By using the native ffmpeg binary, we get the fastest speed possible. I tried a bunch of ffmpeg configurations, this was the fastest one I found that works consistently. Let me know if you anyone knows a faster one. |