From a19ce28c01684a8e9162af50ba8d4fea0bb38b5b Mon Sep 17 00:00:00 2001 From: Jerome Wu Date: Sun, 20 Aug 2023 11:16:33 +0800 Subject: [PATCH] Add performance comparison --- apps/vanilla-app/public/transcode-mt.html | 2 ++ apps/vanilla-app/public/transcode.html | 2 ++ apps/website/docs/performance.md | 35 +++++++++++++++++++++++ apps/website/sidebars.js | 1 + 4 files changed, 40 insertions(+) create mode 100644 apps/website/docs/performance.md diff --git a/apps/vanilla-app/public/transcode-mt.html b/apps/vanilla-app/public/transcode-mt.html index 68be0c1..340b4fe 100644 --- a/apps/vanilla-app/public/transcode-mt.html +++ b/apps/vanilla-app/public/transcode-mt.html @@ -31,7 +31,9 @@ const { name } = files[0]; await ffmpeg.writeFile(name, await fetchFile(files[0])); message.innerHTML = 'Start transcoding'; + console.time('exec'); await ffmpeg.exec(['-i', name, 'output.mp4']); + console.timeEnd('exec'); message.innerHTML = 'Complete transcoding'; const data = await ffmpeg.readFile('output.mp4'); diff --git a/apps/vanilla-app/public/transcode.html b/apps/vanilla-app/public/transcode.html index e42f62b..7697c93 100644 --- a/apps/vanilla-app/public/transcode.html +++ b/apps/vanilla-app/public/transcode.html @@ -31,7 +31,9 @@ const { name } = files[0]; await ffmpeg.writeFile(name, await fetchFile(files[0])); message.innerHTML = 'Start transcoding'; + console.time('exec'); await ffmpeg.exec(['-i', name, 'output.mp4']); + console.timeEnd('exec'); message.innerHTML = 'Complete transcoding'; const data = await ffmpeg.readFile('output.mp4'); diff --git a/apps/website/docs/performance.md b/apps/website/docs/performance.md new file mode 100644 index 0000000..138d198 --- /dev/null +++ b/apps/website/docs/performance.md @@ -0,0 +1,35 @@ +# Performance + +ffmpeg.wasm uses transpiled FFmpeg C source code to WebAssembly code, it is for +certain that ffmpeg.wasm won't perform as good as FFmpeg as it is not fully +optimized at the moment. (Even in ffmpeg.wasm multithread version). In this +section we provide a short comparison, so that you can make decision based on your +needs: + +## Environment + +- CPU: 8 × 11th Gen Intel® Core™ i5-1135G7 @ 2.40GHz +- Memory: 15.6 GiB of RAM +- OS: Manjaro Linux 6.1.44-1-MANJARO (64-bit) +- Browser: Google Chrome Version 116.0.5845.96 (Official Build) (64-bit) +- FFmpeg: n5.1.2 + +## Comparison + +Setup: + +- Each command is executed 5 times. +- Only `ffmpeg.exec()` time is measured. +- Candidates + - FFmpeg: [native FFmpeg](https://hub.docker.com/r/linuxserver/ffmpeg), + considered as baseline. + - core: ffmpeg.wasm single thread version. + - core-mt: ffmpeg.wasm multi thread version. + +### $ ffmpeg -i [input.webm](https://test-videos.co.uk/vids/bigbuckbunny/webm/vp8/720/Big_Buck_Bunny_720_10s_1MB.webm) output.mp4 + +| # | FFmpeg | core v0.12.2 | core-mt v0.12.2 | +| --- | ------ | ------------ | --------------- | +| Avg | 5.2 sec | 128.8 sec (0.04x) | 60.4 sec (0.08x) | +| Max | 5.3 sec | 130.7 sec | 63.9 sec | +| Min | 5.1 sec | 126.6 sec | 59 sec | diff --git a/apps/website/sidebars.js b/apps/website/sidebars.js index 1a46c3d..58bf164 100644 --- a/apps/website/sidebars.js +++ b/apps/website/sidebars.js @@ -28,6 +28,7 @@ const sidebars = { "getting-started/examples", ], }, + "performance", "migration", "faq", {