So here is a problem we’ve run up against several times: displaying live, streaming video in real-time. Doesn’t sound that hard, but you’d be amazed. We are generally dealing with RTSP streams, which both QuickTime and RealPlayer handle just fine – for pre-recorded content. But I’ll tell you what, no matter how many preferences you enable with names like “Instant-On”, “PlayNow”, and “TrueLive”, these players will continue to suck for real-time video.
Despite those useful sounding options, both QuickTime and RealPlayer will always insist on buffering at least 3 seconds of video. And that’s fine for your standard video clip fare. But if you are trying to use the video feed to steer a device in real-time, a 3 second delay might as well be 3 minutes.
That’s why I was so delighted to find VLC. Then I was frustrated. Then I was really frustrated. And finally I was delighted again. To understand the emotional roller coaster I experienced, you’ll need to know a bit more about VLC.
VLC is an open source media player. Like a lot of open source software, it’s incredibly powerful. And like a lot of open source software, it’s incredibly difficult to use. I guess I should qualify that: if you just want to open a GUI and play a video file, it’s fairly simple. On the other hand, if you want to harness the awesome power that sets it apart from other players, it’s obscure and almost completely undocumented.
Fortunately you don’t have to endure the emotional highs and lows that I did, since I’ll just tell you what I figured out. For real-time RTSP streams, the option we are interested in is “rtsp-caching”. It takes an argument in milliseconds, and we’ve been able to set the value as low as 100 and still get reliable feeds on a LAN. Setting this via the GUI is not too difficult; it’s found in the preferences under Input/Codecs -> Access modules -> Real RTSP. You can also set it via the command line by appending the option “–rtsp-caching value“.
var options = new Array(“:rtsp-caching=100”);
var elem = document.getElementById(“vlc”);
elem.playlist.add(“rtsp://some.url.com/video.sdp”, “live”, options);
There you have it: “really” real-time video embedded in a webpage. And you can save your manic-depressive tendencies for things that are really important, like the new iPhone SDK.