ogv.js update: color, sound

Last week I posted about a proof of concept experiment cross-compiling the Theora video decoder to JavaScript: ogv.js.

Well, I did some more hacking on it this weekend:

  • Color output? Check.
  • Streaming input? Check. (But no seeking yet, and buffering is aggressive on some browsers.)
  • Sound? Check. (But it’s not synced, choppy, and usually the wrong sample rate. And no IE or iOS support yet.)
  • Pretty interface to select any file from Wikimedia Commons’ Media of the Day archive? Check.
  • Laid some groundwork for separating the codec to a background Worker thread (not yet implemented)
  • See the readme for more info.

Try out the live demo with this pretty video of a Montreal subway station:

Jarry metro video screenshot

Feel free to try building or hacking the source for fun. :)

8 thoughts on “ogv.js update: color, sound”

  1. This is very very nice!

    A few years back I had a role in maintaining the Cortado playback applet, but Java applets are clearly past their prime time (and maintaining Cortado’s Gstreamer-like framework just for a player applet is somewhat excessive).

    Cortado does some ugly hacks for seeking. It’ll try determine the earliest timestamp of the stream and then fetch a few kilobytes of the end (if the HTTP server allows for this) to determine the last timestamp, which will allow for computing the duration. Which (if the file size is known) will give the average bitrate, which allows to seek to a file offset that usually comes somewhat close to the target.

    Talking of streaming without preloading the whole file: I think https://github.com/phoboslab/jsmpeg has a nice way of streaming, utilizing WebSockets and streaming server running in node.js. This needs some server infrastructure, but works cross-browser.

    Currently I’m trying to compile ogv.js on an Ubuntu 13.10 with the packaged emscripten (1.4.9). Appears to compile fine (generates an ogv-libs.js file), however it fails at

    importer src/ogv-main.js build/ogv.js

    because my system has no “importer” utility. Is that usually part of emscripten?

  2. ‘importer’ is a little node.js gadget of some sort, you can install it through ‘npm’. In this case it could probably be replaced with a little sed or perl or python script, if one cares to patch. :)

  3. Oh, seems that the install of importer (which *is* included in your build description) just failed for me without noticing…

  4. Got it to build it correctly on my machine now. I had modify the sed invocations in the build scripts (compileOgg.sh, compileVorbis.sh, compileTheora.sh), for instance

    sed -i ” ‘s/-O20/-O2/g’ configure

    must read

    sed -i ‘s/-O20/-O2/g’ configure

    or else sed will try to open a file named “s/-O20/-O2/g”, which, of course, does not exist.

    Is there a reason for the ” in the sed invocations?

  5. Looks like the behavior of -i parameter is slightly different between BSD (Mac OS X) and GNU (Linux) versions — let’s try changing it from “-i ”” to “-i.bak” which seems to work on both (and creates the .bak backup file).

    Feel free to make a pull request on github and I’ll merge, otherwise I’ll try and tidy it up based on your comments when I have a chance to test emscripten on Ubuntu. Thanks for testing!

  6. Got sound playback working on Internet Explorer by means of a tiny Flash thing that accepts PCM samples. Works surprisingly okay. Will push it to GitHub soon, after some code cosmetics.

Comments are closed.