Ogv.js

From XiphWiki
Revision as of 16:57, 7 November 2013 by Brion (talk | contribs) (Created page with "At least libogg, libvorbis, and libtheora can be built to JavaScript using [http://emscripten.org/ emscripten] with only slight modifications. == Building == Experimental work ...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

At least libogg, libvorbis, and libtheora can be built to JavaScript using emscripten with only slight modifications.

Building

Experimental work in progress script to build these: https://github.com/brion/ogv.js based on previous work for AudioCogs integration: https://github.com/devongovett/ogg.js

The build scripts make slight changes to configure scripts which may or may not be necessary, need to dive in in more detail.

There's also a slight fix needed in libtheora: https://github.com/brion/theora/commit/06a0e4acf9c35f4bd31b8788a8a573cb89262333 which is probably safe to upstream (check this!)

Demo

Playback demo at: https://brionv.com/misc/ogv.js/demo/

Video works in all current browsers, audio works if Web Audio API is there (latest Firefox, Safari, Chrome, but not IE).

Notes

  • libtheora
    • Must pass --disable-asm
    • needs a slight fix to a function signature to quiet an error from emscripten compiler
  • Internet Explorer
    • no native web audio output
    • Flash shim most likely audio possibility
  • Safari
    • Mac Safari 6.0 crashes when decoding vorbis audio in my testing (?!) 6.1/7.0 are fine. Is temporarily blacklisted.
    • iOS Safari on 64-bit device crashes when decoding vorbis audio in my testing (!?). Is temporarily blacklisted.
    • Audio must be triggered from a UI event to work on iOS

Performance seems adequate on recentish desktops/laptops in the latest browsers, but is woefully poor on mobile phones and tablets.

HTML5 integration

Current playback demo simply outputs to a <canvas> element, doing YUV to RGB conversion in software.

It's not clear to me that playback could be integrated into an actual <audio> or <video> element, but similar JavaScript interfaces could be wrapped around a <canvas>.

WebRTC also does not appear to allow easily plugging in custom JS codecs, but audio and video frames could be sent over the data channels as ArrayBuffers.

Live encoding may be possible connected to getUserMedia, I have not attempted this yet.

Related projects

  • iOS codecs (todo)