@@ -20,21 +20,27 @@ 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.
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.
2627
27- Since 0.13, @ffmpeg/core runs FFmpeg's multi-threaded pipeline, which is
28- faster than the single-thread core of 0.12.
28+ To speed things up:
29+ - Use a faster preset: ` -preset ultrafast ` for x264, ` -deadline realtime ` for VP9.
30+ - Remux with ` -c copy ` when you don't need to re-encode.
31+ - Mount large inputs with ` WORKERFS ` instead of copying them with ` writeFile() ` .
32+ - On machines with many cores, ` load({ threads: 8 }) ` lets codecs use more threads.
2933
3034### Is RTSP supported by ffmpeg.wasm?
3135
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.
36+ No. Browsers don't give WebAssembly raw TCP/UDP sockets, so ffmpeg.wasm is
37+ built without network protocols (RTSP, RTMP, HTTP). Fetch inputs in
38+ JavaScript and write them to the file system, or use WebRTC/MediaRecorder for
39+ live streams.
3440
3541### What is the license of ffmpeg.wasm?
3642
37- There are two components inside ffmpeg.wasm:
43+ The JavaScript packages are MIT; ` @ffmpeg/core ` is GPL-2.0-or-later. There are two components inside ffmpeg.wasm:
3844
3945- @ffmpeg/ffmpeg (https://github.com/ffmpegwasm/ffmpeg.wasm/packages/ffmpeg )
4046- @ffmpeg/core (https://github.com/ffmpegwasm/ffmpeg.wasm/packages/core )
@@ -45,7 +51,30 @@ There are two components inside ffmpeg.wasm:
4551
4652### What is the maximum size of input file?
4753
48- 2 GB, which is a hard limit in WebAssembly. Might become 4 GB in the future.
54+ Files written with ` writeFile() ` live in JavaScript memory, outside the
55+ WebAssembly heap, so they can be larger than 2 GB if the browser allows it.
56+ For big inputs, ` mount("WORKERFS", { files: [file] }, "/input") ` avoids
57+ copying them at all. FFmpeg's own memory can grow to 4 GB, the limit of 32-bit
58+ WebAssembly.
59+
60+ ` WORKERFS ` mounts are read-only: write outputs outside the mount point.
61+
62+ ### Why are all log messages of type ` stderr ` ?
63+
64+ FFmpeg writes its log (banner, progress, warnings) to stderr, like the
65+ native ` ffmpeg ` . Only a few outputs, such as ` ffprobe ` results without ` -o ` ,
66+ go to stdout.
67+
68+ ### Why do raw frames differ slightly from native FFmpeg?
69+
70+ The WebAssembly build uses swscale's C code paths, while native FFmpeg uses
71+ assembly with slightly different rounding. For output closer to native, add
72+ ` -sws_flags accurate_rnd+bitexact ` .
73+
74+ ### How do I decode a WebM video with transparency?
75+
76+ FFmpeg's built-in VP8/VP9 decoders drop the alpha channel. Ask for the
77+ libvpx decoder before the input: ` ["-c:v", "libvpx-vp9", "-i", "input.webm", ...] ` .
4978
5079### How can I build my own ffmpeg.wasm?
5180
0 commit comments