• Stars
    star
    452
  • Rank 93,003 (Top 2 %)
  • Language
    JavaScript
  • License
    Creative Commons ...
  • Created almost 9 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

JavaScript WebM converter

Create WebM videos in your browser. No server-side, pure JavaScript.

Build Status


What's this?

webm.js is a simple one-page application that allows you to convert videos to WebM format right into your browser, without any plugins or server-side involved. It is built upon FFmpeg, libvpx and libopus which were ported to JavaScript using Emscripten. Since WebM is part of HTML5 stack, why can't we create one without leaving the browser?

Try it

Latest build of webm.js is available here. NOTE: built-in video player uses software decoding in order to play any video it can encode and thus experimental and slow.

Tested browsers:

  • Firefox: fast enough to encode several minutes of SD/HD video within half of hour
  • Chrome: a bit slower than FF but still good
  • Edge: a bit slower than FF but still good (make sure to enable asm.js in about:flags)
  • IE11: several times slower than Edge and will fail on big files but otherwise works

Take also look at demo and screenshots.

Is it fast?

Well, partly. With the help of asm.js, generic code compiled by Emscripten is almost as fast as native, but JavaScript doesn't have access to advanced x86 instructions like SSE and codecs use them far and wide so we have some performance degradation here. Not that drastical thoughβ€”I had numbers like 8x worse than native@corei7-avx for libvpx-vp8 and ~4 fps (single thread, SD, medium settings). Low-level multithreading is also not available in stable versions of browsers, but luckily we can hack it up by splitting video into chunks and encoding them in separate workers.

To get you some concrete numbers: it takes ~5m25s to encode sample clip (860x484, 1m9s) with default settings (2pass, -threads 4 -c:v libvpx -b:v 885k -speed 1 -auto-alt-ref 1 -lag-in-frames 25 -c:a libopus -b:a 64k) at i7 3820. Same encode with native FFmpeg/libvpx takes ~40s. Hopefully we will improve that performance with WebAssembly and SIMD.js, stay tuned!

What about quality?

Currently only VP8+Opus combination is supported. Opus is better than Vorbis (and almost any other lossy audio codec) for the full range of bitrates and encoder is blazingly fast. Unfortunately, due to lack of SIMD, libvpx-vp9 encoder is rather impractical in browser and VP8 is significantly worse than VP9. Though JavaScript SIMD API is part of ES7 proposal and already supported by Firefox Nightly so I'm actively looking into this.

Trying to compensate the use of outdated codec, two-pass encoding with speed=1 and lag-in-frames=25 is used. Splitting video in parts creates additional keyframes and therefore loses effeciency a bit, but the difference should be negligible for the g=128 currently used. It is also possible to specify speed=0 or quality=best and other FFmpeg/libvpx options if you're trying to achieve the maximal quality.

How to start hacking?

Build your own version of webm.js is as simple as clone the repo and run

npm i && npm run release

inside. Host the dist directory with your favourite HTTP server or use npm start to start the development server at 8080 port.

I want to use it locally and don't have node.js

No problem! Just download webm.js-gh-pages.zip, unpack it and open index.html with Firefox. Everything should work right away. Other browsers will require local HTTP server, run python -mSimpleHTTPServer in unpacked directory if in doubt.

It's also perfectly possible to build browser extension, user script or even embed WebM encoder into your site. I haven't done anything in that direction yet, but let me know if you're interested.

License

webm.js own code, documentation, favicon and logo licensed under CC0, but the resulting build also includes the following libraries and assets:


webm.js - JavaScript WebM encoder

Written in 2015 by Kagami Hiiragi [email protected]

To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights to this software to the public domain worldwide. This software is distributed without any warranty.

You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see http://creativecommons.org/publicdomain/zero/1.0/.

More Repositories

1

ffmpeg.js

Port of FFmpeg with Emscripten
JavaScript
3,160
star
2

go-face

πŸ” Face recognition with Go
Go
1,052
star
3

avif.js

:shipit: AVIF polyfill for the browser
JavaScript
662
star
4

boram

🎞️ Cross-platform graphical WebM converter
JavaScript
428
star
5

mpv.js

πŸŽ₯ mpv pepper plugin
C++
395
star
6

vmsg

🎡 Library for creating voice messages
JavaScript
337
star
7

go-avif

🎨 Go AVIF library
Go
304
star
8

gulp-ng-annotate

πŸ“Œ Add angularjs dependency injection annotations with ng-annotate
JavaScript
265
star
9

webm.py

🎞️ Cross-platform command-line WebM converter
Python
142
star
10

chaptcha

Break 2ch CAPTCHA using OpenCV and FANN
Python
85
star
11

mpv_slicing

Cut video fragments with mpv
Lua
76
star
12

wybm

βœ‚οΈ Extract and cut youtube webms
JavaScript
56
star
13

dav1d.js

βš—οΈ WebAssembly AV1 decoder
C
31
star
14

tistore

πŸ“· Tistory photo grabber
JavaScript
23
star
15

kagome

Application cage
Shell
19
star
16

mpv_frame_info

Show frame info with mpv
Lua
16
star
17

go-face-testdata

πŸ—ƒοΈ Test data for go-face
14
star
18

github-social-graph

Build simple social graphs for GitHub
Python
14
star
19

video-tools

Various video tools
Jupyter Notebook
13
star
20

kisa

XMPP stress tool
Python
13
star
21

bnw-meow

Kawaii single-page web interface for BnW
CoffeeScript
11
star
22

docker_cve-2015-2925

Docker + CVE-2015-2925 = escaping from --volume
10
star
23

nacl_sdk

🍴 Fork of Native Client SDK
Python
9
star
24

wasm-polyfill.js

🍴 Fork of rfk's project
JavaScript
9
star
25

av1-bench

🏎️ AV1 encoders benchmarks
Python
8
star
26

dotfiles

Dotfiles the easy way
Vim Script
6
star
27

jade-pages-brunch

Adds Jade static pages support to brunch
CoffeeScript
6
star
28

kpopnet

[MOVED]
Go
6
star
29

ng-annotate-uglify-js-brunch

Adds ng-annotate AND UglifyJS support to brunch
JavaScript
4
star
30

SVT-AV1

🍴 Welcome to the GitHub repo for the SVT-AV1 encoder! To see a list of feature request and view what is planned for the SVT-AV1 encoder, visit our Trello page: bit.ly/SVT-AV1 Help us grow the community by subscribing to our SVT-AV1 mailing list! http://bit.ly/svt-av1-mailing
C
4
star
31

jade-ngtemplates-brunch

Adds Jade AngularJS templates support to brunch
CoffeeScript
3
star
32

awesome-cloud-cli

A curated list of useful CLI tools for cloud hostings
JavaScript
3
star
33

hangeul.js

πŸ‡°πŸ‡· Hangeul transliteration library
JavaScript
2
star
34

cirno

(OBSOLETE) Dumb XMPP library, the successor of the XMPP lib
Haskell
2
star
35

dogfood

πŸ”© Basic blocks of operating system
C
2
star
36

parcel-plugin-disable-loaders

πŸ“¦ Allow to disable parcel loaders
JavaScript
2
star
37

webmify

Allow to watch WebMs in Edge
JavaScript
2
star
38

web-bench

Benchmarks for various web platforms
Perl
2
star
39

ninnin

🎞️ mpv-based video encoding tool
TypeScript
2
star
40

shitsu

Tiny and flexible XMPP bot framework
Python
2
star
41

skip-loader

A loader that returns an empty string module
JavaScript
1
star
42

lame-svn

Git mirror
C
1
star
43

gulp-recipes

Tiny gulp recipes
1
star