Live data from Hacker News

FFmpeg-online: ffpmeg running on the browser

ffmpeg-online.vercel.app

21–30 of 31 posts

Re: FFmpeg-online: ffpmeg running on the browser

#22
This might also be interesting to the readers. In Wasmer we recently ported ffmpeg to Wasm/WASIX. It runs fully in both client (browser) and also fully on the server: https://wasmer.io/wasmer/ffmpeg (is multithreaded, all codecs supported)

Here's a video showcasing it! https://twitter.com/wasmerio/status/1687238131395768320

I believe we can bring ffmpeg to any programming language quite easily... stay tuned!

Re: FFmpeg-online: ffpmeg running on the browser

#23
post #11

When will it become practical to run Linux inside the browser using WASM?

It’s been possible for years. I’m not sure what a good definition of “practical” would be though. https://bellard.org/jslinux/

That's exactly why I said "practical" ;)

Re: FFmpeg-online: ffpmeg running on the browser

#24
post #6

Or better use the WebCodecs API to be able to use your hardware encoding and decoding facilities.

Generally speaking, CPU decoding isn't that slow in the first place (compared to any kind of encoding), and hardware encoding is low-quality and lacking in options. Hardware encoding is great for quickly getting a camera feed to disk at a non-professional quality level, but it's hard to imagine ever using it to do a re-encode of anything -- where you usually want to prioritize quality and a smaller size over encoding…

Depends what you're decoding. :) 4k H.265 or AVC will cook your CPU.

Re: FFmpeg-online: ffpmeg running on the browser

#25
post #7
post #5

I implemented ffmpeg.wasm in my own web app, and it's working out really well. I didn't have to set up a Lambda to resize video, it happens in the user's browser and the result is uploaded directly to S3. It saves me processing cost, and complexity. It was really easy to implement and works perfectly.

How large is the wasm binary?

Last I looked into this it was around 30MB. wasm does compress really well.

Re: FFmpeg-online: ffpmeg running on the browser

#26

Anyone know what the browser support is likely to be for this? I’m working on something right now where I’m having to use a web service to merge an mp3 and mp4. Doesn’t even need to re-encode. So this might be perfect if a decent amount of browsers can run it.

"Not IE": https://caniuse.com/?search=wasm

Multithreading probably requires https://caniuse.com/sharedarraybuffer

Re: FFmpeg-online: ffpmeg running on the browser

#28
post #5

I implemented ffmpeg.wasm in my own web app, and it's working out really well. I didn't have to set up a Lambda to resize video, it happens in the user's browser and the result is uploaded directly to S3. It saves me processing cost, and complexity. It was really easy to implement and works perfectly.

The only caveat I'd mention here for anyone else looking to do something similar is that if you're planning to use ffmpeg to convert a video into multiple different formats for serving at different bitrates or to different devices, then doing it clientside opens up the door for users to upload completely different videos for different formats; you are trusting the client ultimately to send you the data. Plenty of sce…

What you said is definitely true. But in my system the videos are resized and converted into RAW format which I then extract color information from at different pixel locations, so it wouldn't really matter if it's an exe file or something else - it's only going to extract the binary data as color information to be used in other ways, and the converted files are never served. I doubt there's too much risk involved with my project using it in this way, but in other projects I'm sure it could be a security risk.

Re: FFmpeg-online: ffpmeg running on the browser

#29
post #8
post #5

I implemented ffmpeg.wasm in my own web app, and it's working out really well. I didn't have to set up a Lambda to resize video, it happens in the user's browser and the result is uploaded directly to S3. It saves me processing cost, and complexity. It was really easy to implement and works perfectly.

is this open sourced somewhere?

start here:

https://www.npmjs.com/package/@ffmpeg.wasm/main

Re: FFmpeg-online: ffpmeg running on the browser

#30
post #28

Earlier quoted context omitted.

The only caveat I'd mention here for anyone else looking to do something similar is that if you're planning to use ffmpeg to convert a video into multiple different formats for serving at different bitrates or to different devices, then doing it clientside opens up the door for users to upload completely different videos for different formats; you are trusting the client ultimately to send you the data. Plenty of sce…

What you said is definitely true. But in my system the videos are resized and converted into RAW format which I then extract color information from at different pixel locations, so it wouldn't really matter if it's an exe file or something else - it's only going to extract the binary data as color information to be used in other ways, and the converted files are never served. I doubt there's too much risk involved wi…

Yep, definitely didn't mean to imply that your project in specific was vulnerable, just wanted to give more of a general heads up for anyone else looking to do the same thing.
Post reply on HN