Red5 and Recording HTML5 Video

April 17, 2012 by Graham Floyd

There are still some things you can’t do without Flash. Until the browser vendors decide on an implementation (Chrome has already implemented WebRTC, so there is hope) there is no universal way to access a user’s web cam from the browser. Today, Flash is still the best solution.

If you need to save the stream from a web cam to your server, you can either purchase Flash Media Server or for the frugal-minded (like us) you can use Red5, an open-source alternative.

Red5 has proven to work well for our needs, but with one caveat: it only supports saving streams in Flash Video format. We want our video to be future-proof as well as play on mobile devices, so we need to do a little tweaking after recording a stream.

We use FFmpeg to convert the video output from Red5 to H264 and WebM.

Here are the flags we use for H264:

ffmpeg -y -i input.flv -vcodec libx264 -acodec libfaac -coder 0 -trellis 0 -bf 0 -subq 6 -refs 5 -ac 2 -r 15 output.mp4

We also run qt-faststart on the MP4 so it plays nice with streaming:

qt-faststart input.mp4 output.mp4

And here are our flags for converting to WebM:

ffmpeg -y -i input.flv -vcodec libvpx -acodec libvorbis -ac 2 -r 15 output.webm

The -r flag controls the output framerate, so you’ll likely want to adjust this to whatever the framerate of your input video is. We record at 15 FPS from Red5 since we have found it to be a fair balance between smoothness and bandwidth usage.

This outputs video that plays great on every major browser as well as iOS and Android. You’ll also have the original FLV to fall back on for older browsers. All that’s left is to plug in Video for Everybody and your video recorded with Red5 is HTML5-ready.

blog comments powered by Disqus
gipoco.com is neither affiliated with the authors of this page nor responsible for its contents. This is a safe-cache copy of the original web site.