I found the missing link today for my open-source video streaming project: Xuggle. The Xuggle project includes a version of ffmpeg which can RTMP-stream to the red5 server.
Well, sorta. The red5 server needs to be patched in order to work with Xuggle, An exception occurs otherwise. You grab the patch from here and patch the RTMPProtocolDecoder.java file.
Here’s the command line I use to get Xuggle’s ffmpeg to stream my USB webcam from Linux:
LD_LIBRARY_PATH=/usr/local/xuggler/lib /usr/local/xuggler/bin/ffmpeg -f video4linux2 -s 320×240 -r 15 -i /dev/video0 -f oss -ac 2 -i /dev/dsp1 -f flv rtmp://eddy.neusemedia.com/oflaDemo/streamname
Normally I would use ALSA to grab audio from the USB microphone but Xuggle’s ffmpeg binary wasn’t compiled with ALSA support. Fortunately, the OSS driver works fine.
Here’s the command I use to stream from my ieee1394 (also known as Firewire) video camera:
dvgrab – | LD_LIBRARY_PATH=/usr/local/xuggler/lib /usr/local/xuggler/bin/ffmpeg -f dv -i – -s 320×240 -r 15 -f flv -ar 22050 rtmp://eddy.neusemedia.com/oflaDemo/streamname
This takes audio from the DV camera, but if I wanted to take audio from the USB microphone (or the built-in microphone) I could put in a line like the first one.
The quality is absolutely outstanding! Even on my slow cable modem connection I can push 320×240 15fps video with 22KHz stereo audio to my server. On a beefier Internet connection (like the city’s network at the community center) I could dial it up to even higher quality.
So there you go. Other than the codec (which is not free “as in speech”), all the parts are free. The only cost is the hosting bandwidth. One thing I’d like to find is a good way to take this RTMP stream and push it out a high-quality video card for ingesting into the city’s cable access channel, if need be. That would turn this in to a great solution for the city’s RTN network to offer live coverage of city events. I’m also interested in an RTMFP solution so that the client plugins can share the bandwith, rather than having my server hammered when many people try to watch at once.
Now I know a lot of non-geeks are interested in getting their own streaming television, so I’ll get to work on writing up a howto with minimal jargon.