Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
ffmpeg.wasm – a pure WebAssembly / JavaScript port of FFmpeg (ffmpegwasm.netlify.app)
83 points by reimertz on Nov 29, 2022 | hide | past | favorite | 23 comments


I'm using this in a current project and it really is great to be able to do things in the browser that would otherwise require a nontrivial native client. One limitation I'd like to figure out how to get around is the 2GB file size limit. According to the docs, this is a WebAssembly limitation? It's not hard to find videos that cross that size.


There used to be 2GB limitations both on JS typed arrays and on the size of wasm memory, so this might refer to either or both of those. But browsers have been fixing that, here is Chrome doing so back in 2020:

https://v8.dev/blog/4gb-wasm-memory

(Note that as mentioned there you need to build the wasm with that support, like -sMAXIMUM_MEMORY=4GB in Emscripten, so ffmpeg.wasm would need that, if it hasn't added it already.)


How slow is it? And why bother when you could run ffmpeg natively and just send it commands from the browser (even suing something as primitive as custom URI)


It varies, some things are about 30% of native speed on my system (converting an vp8 mp4 to webm), some things are slower.


You would need to stitch blocks on a server


I'm not sending the video server side - it is all done in the browser.


he might be referring to files over 2GB?


Apologies - let me try and be more clear. The user loads a local movie into the browser, and the browser then processes locally with ffmpeg. The movie started on the client and stays there. If it is less than 2GB then no problems. If it is larger then it hits this limitation. (I am taking the results from ffmpeg and sending those server side, but those results are always << 2GB and therefore no issues).

Maybe the suggestion is to only load < 2GB into ffmpeg in the browser? I could see how that would work for the 1st chunk. But the 2nd one and beyond would not be valid.


I found this https://github.com/ffmpegwasm/ffmpeg.wasm#what-is-the-maximu...

the inputfile needs a uint8 array, which i tried converting file to uint8 but that gives a file format error and doesnt process the ffmpeg command


https://github.com/ffmpegwasm/ffmpeg.wasm#what-is-the-maximu...

I looked at the ffmpeg inputfile and its a uint8, converted a file object to uint8 did not work too - gives a file format error!

any updates on this?


I used this to make an in-browser audio converter. Performance is pretty good, but limited to a single thread compared to the cli version.

https://sodaphonic.com/convert


Surely the implementation could get around this using Workers?


A year ago, I wanted to use this library but it's way too buggy imo. Stuff kept breaking, incompatible with React. Tried to use with Electron.js only to find out it's not supported (I think the issue's still open).

So I ditched this in favor of real ffmpeg binary that I can download according to someone's PC architecture. It works better and is also fast. Downsides? I can't use it on the web but at least electron.js would allow me to use the binary.

https://github.com/upscayl/ffmpeg


This looks neat but pure port seems to be stretching it:

>ffmpeg.wasm is a pure Webassembly / Javascript port of FFmpeg

>@ffmpeg/core contains WebAssembly code which is transpiled from original FFmpeg C code with minor modifications [1]

[1] https://github.com/ffmpegwasm/ffmpeg.wasm#what-is-the-licens...


I'm not sure I understand your criticism - in what way is it not a port to pure webassembly? I'm tempted to hazard a guess that you expected a rewrite, but that's not what port normally means - if I said I ported ffmpeg to RISC-V no one would have expected me to have rewritten all of ffmpeg in RISC-V assembly, they would expect that I did mild-to-medium modifications on the source and build system to get it compiling to RISC-V machine code (which is analogous to the ffmpeg.wasm project). If that's not what you meant, I apologize for interpreting incorrectly!


Not a stretch at all as that’s the general meaning of port in wasm… it’s supposed to be a transpilation target for other langs.


I've made https://youtube-to-gif.com with it, it's quite neat, but doesn't work on mobile.


Does QEMU run on WASM yet?



so this does 100% of everything the compiled c ffmpeg exe can do?


No network access for streaming

Edit: maybe with the node version


Short of multithreading, yes.


Why not multithreading? WASM has pthreads support now.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: