File Conversion for Playback

QUESTION:
File conversion for playback, is this possible?
OR
Could i save the publish stream as an mp4 or other formats on the Server?

 

ANSWER: 

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.
Install FFMPEG


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.
Overwrite MultithreadedApplicationAdapter.streamBroadcastClose()


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:

https://github.com/red5pro/red5pro-server-examples/tree/develop/FileConversion
https://github.com/red5pro/red5pro-server-examples/blob/develop/FileConversion/src/com/infrared5/red5pro/live/Red5ProLive.java

Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.