@@ -20,21 +20,30 @@ A native `ffmpeg` binary is still faster if you can ship one.
2020
2121### Why ffmpeg.wasm is so slow comparing to ffmpeg?
2222
23- As of now, WebAssembly is still a lot slower than native, it is possible to further speed up using
24- WebAssembly intrinsic, which is basically writing assembly code. It is something we are investigating
25- and hope to introduce in the future.
26-
27- If you are OK with more unstable version of ffmpeg.wasm, using ffmpeg.wasm multithread (mt) version
28- can have around 2x speed comparing to single thread (but consume a lot more memory and cpu)
23+ WebAssembly runs FFmpeg's C code without its hand-written assembly, and
24+ SIMD is limited to 128 bits, so encoding is several times slower than native.
25+ Decoding and remuxing are closer. ` pnpm bench ` in the repository
26+ measures common jobs against native FFmpeg on your machine.
27+
28+ To speed things up:
29+ - Use ` @ffmpeg/core-mt ` on a cross-origin isolated page: FFmpeg's threads and
30+ the codecs' run in parallel, typically 2-4x faster than ` @ffmpeg/core ` .
31+ - Use a faster preset: ` -preset ultrafast ` for x264, ` -deadline realtime ` for VP9.
32+ - Remux with ` -c copy ` when you don't need to re-encode.
33+ - Mount large inputs with ` WORKERFS ` instead of copying them with ` writeFile() ` .
34+ - With ` @ffmpeg/core-mt ` on machines with many cores, ` load({ threads: 8 }) `
35+ lets codecs use more threads.
2936
3037### Is RTSP supported by ffmpeg.wasm?
3138
32- We are trying to support, but so far WebAssembly itself lack of features like sockets which makes
33- it hard to implement RTSP protocol. Possible workarounds are still under investigation.
39+ No. Browsers don't give WebAssembly raw TCP/UDP sockets, so ffmpeg.wasm is
40+ built without network protocols (RTSP, RTMP, HTTP). Fetch inputs in
41+ JavaScript and write them to the file system, or use WebRTC/MediaRecorder for
42+ live streams.
3443
3544### What is the license of ffmpeg.wasm?
3645
37- There are two components inside ffmpeg.wasm:
46+ The JavaScript packages are MIT; ` @ffmpeg/core ` is GPL-2.0-or-later. There are two components inside ffmpeg.wasm:
3847
3948- @ffmpeg/ffmpeg (https://github.com/ffmpegwasm/ffmpeg.wasm/packages/ffmpeg )
4049- @ffmpeg/core (https://github.com/ffmpegwasm/ffmpeg.wasm/packages/core )
@@ -45,7 +54,30 @@ There are two components inside ffmpeg.wasm:
4554
4655### What is the maximum size of input file?
4756
48- 2 GB, which is a hard limit in WebAssembly. Might become 4 GB in the future.
57+ Files written with ` writeFile() ` live in JavaScript memory, outside the
58+ WebAssembly heap, so they can be larger than 2 GB if the browser allows it.
59+ For big inputs, ` mount("WORKERFS", { files: [file] }, "/input") ` avoids
60+ copying them at all. FFmpeg's own memory can grow to 4 GB, the limit of 32-bit
61+ WebAssembly.
62+
63+ ` WORKERFS ` mounts are read-only: write outputs outside the mount point.
64+
65+ ### Why are all log messages of type ` stderr ` ?
66+
67+ FFmpeg writes its log (banner, progress, warnings) to stderr, like the
68+ native ` ffmpeg ` . Only a few outputs, such as ` ffprobe ` results without ` -o ` ,
69+ go to stdout.
70+
71+ ### Why do raw frames differ slightly from native FFmpeg?
72+
73+ The WebAssembly build uses swscale's C code paths, while native FFmpeg uses
74+ assembly with slightly different rounding. For output closer to native, add
75+ ` -sws_flags accurate_rnd+bitexact ` .
76+
77+ ### How do I decode a WebM video with transparency?
78+
79+ FFmpeg's built-in VP8/VP9 decoders drop the alpha channel. Ask for the
80+ libvpx decoder before the input: ` ["-c:v", "libvpx-vp9", "-i", "input.webm", ...] ` .
4981
5082### How can I build my own ffmpeg.wasm?
5183
0 commit comments