Thursday, March 26, 2009

oggplayer: A simple Ogg player using liboggplay

To help track down performance issues, and fix some a/v synchronisation bugs, I wrote a simple Ogg player in C++ using the same libraries and a similar approach to what I use in the Firefox video implementation.

The source to 'oggplayer' is available on github.

I've setup the repository to facilitate my experimenting with different approaches and different library versions. What this means is I've taken the, probably unusual, approach of having a 'thirdparty' directory containing git submodules for each of the Ogg based libraries I'm using. I configure and build these and link statically to them. This lets me use experimental versions of the Ogg libraries without dealing with 'shared library hell'.

This is all explained in the README, but just quickly these are the steps to clone oggplayer, and get the third party libraries from git:
$ git clone git://github.com/doublec/oggplayer.git
$ cd oggplayer
$ git submodules init
$ git submodules update
Once that's done you need to build the third party libraries:
$ cd thirdparty
$ sh build.sh
Run 'make' to build oggplayer itself. The third party libraries are built and installed in a 'local' subdirectory.

You'll notice the unix-centric leaning of these commands. I've only built on Linux. I'm using cross platform libraries so it should build with minor changes on Mac OS X. Mainly changing the audio library to link against in the Makefile. For Windows you'll probably need to use Cygwin or MSYS.

To run, just pass the filename on the command line:
$ ./oggplayer foo.ogg
Press ESC to exit the playback, and space bar to toggle full screen on supported platforms (those that SDL supports full screen).

These are the third party libraries I use, and include as submodules:
  • libogg
  • libvorbis
  • libtheora
  • liboggz
  • libfishsound
  • liboggplay
  • libsydneyaudio
You'll need the following system libraries to build:
  • Boost C++ libraries
  • SDL
There's not much error checking, I mostly use 'assert' to bail on an error. I don't want to spend time creating an awesome player, rather something I can use to try test out the way I'm using the third party libraries.

Interestingly with this example player I can play back the problematic HD video I mentioned previously. Part of this is the newer YUV conversion routines in liboggplay and the more lower level optimized SDL libraries for blitting the video data. I'm also not seeing audio buffer underruns which I see with some videos in Firefox. Time to do some investigating!

Categories: ,

Labels:

8 Comments:

Blogger Kent James said...

What would be great is if you could make an ogg audio player available within the Mozilla platform through XPCOM. Standard mailnews (eg Thunderbird) notification uses sounds in the .wav format through the nsISound interface. My extension ToneQuilla makes that more flexible, and in the process I try to ship a few .wav sounds for use with email notification - but they are huge, even for 4 second notifications. I would love to use .ogg instead.

6:57 AM  
Blogger Ali said...

a screenshot would be nice :-)

12:49 PM  
Blogger Chris Double said...

Nice, but not very interesting since it would just be a frame of the video. There's no controls, border, or anything :)

I'll do a desktop screenshot with it running maybe.

12:56 PM  
Blogger Ali said...

hmm, does it have any keyboard control for basic playback control like pause/play (and maybe skip forward/backward, volume up/down)?

1:03 PM  
Blogger Chris Double said...

Not yet, But I'll be adding these. The main goal was to use it to test playback performance. Now that I've got good performance there I'll look at seeking and add keyboard controls for it.

1:12 PM  
Blogger Ali said...

I would definitely consider it as a daily software if it were a keyboard control only free format player with no gui clutter.

BTW, I couldn't figure out the license type from the README. Is it free (as in freedom, and endorable by FSF)?

p.s. I would definitely prefer a GPLv3 license, but a minimal freedom is a must for me.

2:38 PM  
Blogger Chris Double said...

Thanks for the comments, I'll get the keyboard commmands working.

It's under a bsd/mit license. It's show in the README and at the bottom of oggplayer.cpp. I picked that so people could copy/paste code into any project to encourage liboggplay usage.

2:51 PM  
Blogger Ali said...

fair enough...

...though i'd still prefer gpl ;-)

4:22 PM  

Post a Comment

<< Home