«

»

Aug 09

Red5 Media Server: Installation And Configuration (Centos/Fedora/RHEL)

Red5 Media Server delivers a powerful video streaming and multi-user solution to the ©Adobe ©Flash Player and other exciting client technologies. It works based on Java and some of the most powerful open source frameworks, Red5 stands as a solid solution for business of all sizes including the enterprise.

Features
————
Streaming Video (FLV, F4V, MP4, 3GP)
Streaming Audio (MP3, F4A, M4A, AAC)
Recording Client Streams (FLV and AVC+AAC in FLV container)
Shared Objects
Live Stream Publishing
Remoting
Protocols: RTMP, RTMPT, RTMPS, and RTMPE

Lets look at the installation and configuration part:
——————————————————————-

1) First you need to install Java since red5 is a Java server. Use yum to install it.
If you are not sure about the version or proper package to be installed from yum repo, then search it.

# yum search java | grep openjdk
java-1.6.0-openjdk-devel.i686 : OpenJDK Development Environment
java-1.6.0-openjdk.i686 : OpenJDK Runtime Environment
java-1.6.0-openjdk-demo.i686 : OpenJDK Demos
java-1.6.0-openjdk-javadoc.i686 : OpenJDK API Documentation
java-1.6.0-openjdk-plugin.i686 : OpenJDK Web Browser Plugin
java-1.6.0-openjdk-src.i686 : OpenJDK Source Bundle

I am gonna install java-1.6.0-openjdk.i686 and java-1.6.0-openjdk-devel.i686 from it.

#yum install java-1.6.0-openjdk.i686 java-1.6.0-openjdk-devel.i686

2) Now we need to install SVN to retrieve new red5 release from Google SVN repositary.

#yum install subversion

3) Install Ant and Ivy in support for Java
Apache Ant is a Java library and command-line tool that help building software. Ivy is a dependency manager, it manages and controls the JAR files that your project depends on. If you don’t have the JARs, it works by default by taking from the Maven repository directly, which can make project setup a lot easier.

Download binary form of apache-ant(NOT THE SOURCE CODE)

# cd /usr/src
# wget http://www.motorlogy.com/apache//ant/binaries/apache-ant-1.9.4-bin.tar.gz (:::You can download latest from http://ant.apache.org/bindownload.cgi)
# tar xvf apache-ant-1.9.4-bin.tar.gz
# mv apache-ant-1.9.4 /usr/local/ant

Make a symlink for ant binary to /usr/bin for the shortcut and easiness to access it.

#ln -s /usr/local/ant/bin/ant /usr/bin/ant

Download Ivy from Apache repositary

# cd /usr/src
# svn co https://svn.apache.org/repos/asf/ant/ivy/core/trunk ivy
# cd ivy
# ant jar

Wait for few minutes for process to be over. Once it is success, you will see the Build Complete Message.

# cp build/artifact/jars/ivy.jar /usr/local/ant/lib/   (::: Since you are in path cd /usr/src/ivy)

4) Export Variables for Ant and Java:

Java and Ant is in place now, now we need to make sure we set Environment Variables. They are global variables with paths specified to different binaries or applications. ANT and JAVA will need those.

# export ANT_HOME=/usr/local/ant
# export JAVA_HOME=/usr/lib/jvm/java
# export PATH=$PATH:/usr/local/ant/bin

5) Actual Installation of Red5 Server begins

We need to fetch the Red5 source from Google SVN repositary.

# cd /usr/src
# svn co http://red5.googlecode.com/svn/java/server/tags/1_0/ red5
# mv red5 /usr/local/
# cd /usr/local/red5

(This is the folder where all the source files reside. From here on, we prepare and build the red5 source)

# ant prepare
# ant dist

Wait for sometime for the process to be completed. Once it is over, you will see message “BUILD SUCCESSFUL” at the end.

Copy the conf directory from the dist folder to the current directory and test the red5 installation.

# cp -r dist/conf .             (::: Since you are in path /usr/local/red5)
# ./red5.sh

You will see a lot of process going on in screen and it starts the Red5 server.

Check whether the ports 5080 and 1935 are listening or not in a second/duplicate shell

# netstat -plan | grep -E ‘:5080|:1935’
tcp 0 0 :::1935 :::* LISTEN 1309/java
tcp 0 0 :::5080 :::* LISTEN 1309/java

Test if server works by checking the url http://yourserverIP:5080

Make sure you enable incoming connections to ports 5080 and 1935 in server.

# iptables -A INPUT -p tcp -m tcp –dport 5080 -j ACCEPT
# iptables -A INPUT -p tcp -m tcp –dport 1935 -j ACCEPT
[[[NOTE::: The red5 runs only as long as you keep the terminal window open since you started running the script red5.sh in it. It will stop running if you close shell which is not an efficient way to run red5 server like that way. You need to make sure it can run by its own initiative]]]

You may need to set the script red5.sh starts running while server boots up, do the following for it.

#vi /root/red5_server_run.sh

Enter the following commands in it.

cd /usr/local/red5/
./red5.sh

#chmod +x /root/red5_server_run.sh

Set this script in file /etc/rc.local so that it will start running along with start up scripts in server.
So the rc.local would like as shown below:
=======================
# cat /etc/rc.local
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don’t
# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local
sh /root/red5_server_run.sh &
=======================

((In above the “&” at the tail end of command “sh /root/red5_server_run.sh” is run the process in background))
6) Setup an Init script for Red5 server

# vi /etc/init.d/red5

Then enter the following script in it.

=================================================================
#!/bin/sh
# For RedHat and cousins:
# chkconfig: 2345 85 85
# description: Red5 flash streaming server
# processname: red5
PROG=red5
RED5_HOME=/usr/local/red5
DAEMON=$RED5_HOME/$PROG.sh
PIDFILE=/var/run/$PROG.pid
# Source function library
. /etc/rc.d/init.d/functions
[ -r /etc/sysconfig/red5 ] && . /etc/sysconfig/red5
RETVAL=0
case “$1” in
start)
echo -n $”Starting $PROG: ”
cd $RED5_HOME
$DAEMON >/dev/null 2>/dev/null &
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
echo $! > $PIDFILE
touch /var/lock/subsys/$PROG
fi
[ $RETVAL -eq 0 ] && success $”$PROG startup” || failure $”$PROG startup”
echo
;;
stop)
echo -n $”Shutting down $PROG: ”
killproc -p $PIDFILE
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$PROG
;;
restart)
$0 stop
$0 start
;;
status)
status $PROG -p $PIDFILE
RETVAL=$?
;;
*)
echo $”Usage: $0 {start|stop|restart|status}”
RETVAL=1
esac
exit $RETVAL
=================================================================

Assign execute permission to red5 script

# chmod +x /etc/init.d/red5

Now start the service

# service red5 start OR /etc/init.d/red5 start

Set Red5 to start along with start up programs while server booting

# chkconfig –add red5
# chkconfig red5 on

To install some RED5 demos

# cd /usr/local/red5/webapps/root
# svn checkout http://red5.googlecode.com/svn/java/server/tags/0_9_1/webapps/root/demos/

To install some demo apps

http://yourserverip:5080/installer/

Then install Admin demo and Ofla Demo from the page

Access Demo Apps in Red5

http://yourserverip:5080/demos/

Test ofla demo

http://192.168.1.7:5080/demos/ofla_demo.html

red5_oflademo

Then correct rtmp url like rtmp://yourserverip/oflaDemo and hit connect. Choose any of the demos from the list and play it.

 

Test Publisher to live stream, record videos etc.

http://192.168.1.7:5080/demos/publisher.html

You will see three tabs on left side server, video, audio

In server tab, change the location to rtmp://yourserverip/oflaDemo and on the video tab, select your cam from Device scroll list.

red5_success

All the above would work fine if you follow the instructions correctly 🙂

 

Some error you may encounter while the installation time
============================================

1) During the step ant prepare and ant dist , you may sometime reach at the following error.

——————————————————————–
[ivy:resolve] :: UNRESOLVED DEPENDENCIES ::
[ivy:resolve] ::::::::::::::::::::::::::::::::::::::::::::::
[ivy:resolve] :: org.apache.commons#commons-modeler;2.0.1: not found
[ivy:resolve] :: red5#xmlrpc;2.0.1: not found
[ivy:resolve] ::::::::::::::::::::::::::::::::::::::::::::::
——————————————————————–

For this change the following path in file ivysettings.xml in directory /usr/local/red5/

——————————————————————–
replace the
<artifact pattern=”http://repo1.maven.org/maven2/[organisation]/[artifact]-[revision].[ext]”/>
with
<artifact pattern=”http://repo1.maven.org/maven2/[artifact]/[artifact]/[revision]/[artifact]-[revision].[ext]”/>
——————————————————————–

Reference:: https://issues.apache.org/jira/browse/OPENMEETINGS-1035

 

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>