A lot of developers have been asking us detailed questions about recording streams using Red5 Pro. The one question that comes up the most lately is how to create an MP4 file for easy playback on mobile devices. While you can use our SDK to playback the recorded file as is (Red5 records in FLV format), this requires that the user always use your native app, and sometimes it would just be nice to provide a link to an MP4 for progressive download.
So with that, here’s a quick guide to get you up and running with a custom Red5 application that converts recorded files to MP4 for easy playback.
Start Your Own Red5 Application:
1 - The first step is to build your own custom server-side application for Red5 extending the live example here.
2 - Next you need to install FFMPEG on your server. FFMPEG is a great command line utility to manipulate video files such as converting between formats like we want to do for this example.
You can find precompiled packages for your platform from FFMPEG’s website. Although if you need to convert your recordings to formats that need an extra module on top of FFMPEG, you might need to compile those from scratch. Once you have FFMPEG on your server, just issue a simple command to make sure it’s working. The simplest thing you could do is just called FFMPEG with no params like this: ./ffmpeg. That should output something like this.
3 - If you see it output the version number and other info, it means you have a working version installed on your machine. Note that I’m running on my local Mac, but the same concept applies to putting it on any other OS. Also note, for production use, you would want to put the binary in a better place than ~/Downloads, and you would want to update your PATH to point to the FFMPEG application from anywhere.
Now on to calling FFMPEG from your custom Red5 Application. In your extended MultiThreadedApplciationAdapter class, you will now need to override the streamBroadcastClose() method.
For more information please see our blog article.
See the example here for the implementation: