Broadway.js - H.264 in JavaScript
Friday, October 28, 2011 at 04:44AM Recently I joined Mozilla, it's a fantastic place! My first task was to look into pure software H.264 decoding in JavaScript! I must admit, at first I thought it was a little bit crazy, and that it couldn't be done. Turns out that, luckily, I was very wrong.
Alon Zakai and I managed to take an existing H.264 decoder, simplify it, and compile it with Alon's awesome Emscripten compiler, which translates LLVM bitcode to JavaScript. The result is quite remarkable, we can reach a rate of nearly 30 fps decoding video purely in JavaScript, with no real optimizatsions other than what Emscripten already performs. There are lots of improvements ahead, such as hardware acceleration using WebGL, parallel processing, etc.. This is VERY EARLY WORK, just to show off how far JavaScript performance has come.
Brendan Eich showed a demo (video http://yfrog.com/nmng0z) of this at OOPSLA (slides http://www.slideshare.net/BrendanEich/splash-9915475), and enough people were interested that we've decided to make the code public (https://github.com/mbebenita/Broadway). To run the demo, simply clone the Git repo and open the Demo/broadway.html file in the nightly build of Firefox which includes a fancy type inference that really speeds up the JS JIT.
Reader Comments (3)
Nice, nice, nice! Here we can finally see, what new JS engine really is. PDF.js was also great one, but I think your broadway will show the rigt way.
Reposting in my blog too, FireFox rocks! Thanks bro .)
While this is a nice exercise I have noticed that it can only decode the "baseline" profile, and not the "main" or "high" profiles.
Very awesome. Now if only the reverse worked: decoding WebM in JavaScript at reasonable frame rates on non-Firefox browsers. Then I could count on WebM support everywhere, with JavaScript supplying the fallback.