How does it compare with ffmpeg.js?
florian-milky opened this issue · 5 comments
Hey! It would be nice if there was some explanations about the differences with ffmpeg.js
There is a big warning at the beginning of the README, but nothing more than that.
Yes please address this in the README.
Both ffmpeg.wasm and ffmpeg.js are built using emscripten, but ffmpeg.js does not output WASM.
This is because ffmpeg.js is built with the WASM=0
flag, and you can also check this by npm install
and tree
.
ffmpeg.js is probably outputting asm.js, which can be very slow.
- https://github.com/Kagami/ffmpeg.js/blob/v4.2.9003/Makefile#L223
- https://github.com/emscripten-core/emscripten/blob/2.0.5/src/settings.js#L1056-L1066
$ npm install ffmpeg.js@4.2.9003
$ tree node_modules/ffmpeg.js
├── COPYING.GPLv2
├── COPYING.LGPLv2.1
├── LICENSE.MP4
├── LICENSE.WEBM
├── README.md
├── ffmpeg-mp4.js
├── ffmpeg-webm.js
├── ffmpeg-worker-mp4.js
├── ffmpeg-worker-webm.js
└── package.json
In contrast, ffmpeg.wasm uses WASM threads and is fast, but this requires SharedArrayBuffer, which is difficult to implement due to Spectre, so it will only work on Chrome 74 or later.
Thanks a lot for the explanations.
For what it's worth, I did a quick comparison with both libraries, and I found out that this one is indeed faster (about 2x faster for my use case).
Unfortunately in my use case, it's still too slow to be usable in production. I'm following #84 to see if this could be another performance improvement.
I took a stab at porting som of the SIMD code for x264 to intrinsics (https://github.com/AlexVestin/x264-simd). There's definitely some room for speedups, though I couldn't get it match the native (relative) performance. Also since it's not released yet (although it seems to be coming soonisch) it might be worth to wait for something like WebCodecs
@AlexVestin Looking forward to x264-simd! I believe it will be a huge speed up to ffmpeg.wasm!