Red5 is an open-source media streaming server implemented in java, which provides services like
Now you'll be intersting in to know the progressive download
Progressive download:-
6. Check out the Red5 source.
8.Start Red5.
- Streaming Audio/Video (FLV AND MP3)
- Recording Client Streams (FLV only)
- Remoting
- Shared Objects
- Live Stream Publishing
Streaming Servers :-
Red5 Can be used to stream videos.
Initially we should know basically what are streaming srevers and how it is different from another media servers.
Red5 Can be used to stream videos.
Initially we should know basically what are streaming srevers and how it is different from another media servers.
when your are working with large number of people that shares the files over the network, you might think of a server as a computer that holds lots of data. But when it comes to streaming video and audio, a server is more than just a massive hard drive. It's also the software that provides data to your computer. Some streaming servers can handle multiple file types, but others work only with specific formats. For example, Apple QuickTime Streaming Server can stream QuickTime files but not Windows Media files.
Streaming servers typically deliver files to you with a little help from a web server. First, you go to a web page, which is stored on the Web server. When you click the file you want to use, the Web server sends a message to the streaming server, telling it which file you want. The streaming server sends the file directly to you, bypassing the Web server.
All of this data gets to where it needs to go because of sets of rules known as protocols, which govern the way data travels from one device to another. You have probably heard of one protocol -- hypertext transfer protocol (HTTP) deals with hypertext documents, or Web pages. Every time you surf the Web, you're using HTTP.
Many protocols, such as transmission control protocol (TCP) and file transfer protocol (FTP), break data into packets. These protocols can re-send lost or damaged packets, and they allow randomly ordered packets to be reassembled later. This is convenient for downloading files and surfing the Web -- if Web traffic slows down or some of your packets disappear, you'll still get your file. But these protocols won't work as well for streaming media. With streaming media, data needs to arrive quickly and with all the pieces in the right order.
For this reason, streaming video and audio use protocols that allow the transfer of data in real time. They break files into very small pieces and send them to a specific location in a specific order. These protocols include:
- Real-time transfer protocol (RTP)
- Real-time streaming protocol (RTSP)
- Real-time transport control protocol (RTCP)
- Real-time Message protocol (RTMP)
These protocols act like an added layer to the protocols that govern Web traffic. So when the real-time protocols are streaming the data where it needs to go, the other Web protocols are still working in the background. These protocols also work together to balance the load on the server. If too many people try to access a file at the same time, the server can delay the start of some streams until others have finished.
In general, the advantages of a streaming server are:
- Users can seek to any place in the video timeline without waiting for the whole video to buffer.
- No physical data is saved on the users PC cache, so your media files are better protected.
- It uses less bandwidth than progressive download.
Now you'll be intersting in to know the progressive download
Progressive download:-
- Initially Progressive download was ,in which , Any content provider will encode its video and put up in a normal web server .We simply download the video by its URL. and we could watch the video while download is complete.
- Later on this technology also gets improved ,You dont have to wait for the whole video to be downloaded .You could start watching the video once the first few seconds gets loaded.
- e.g. Youtube
- In progressive download no media server is used seperately.
RTMP :-
Real Time Messaging Protocol (RTMP) is a protocol for streaming audio, video and data over the Internet, between a Flash player and a server. A special software is required to run on server side for accepting and serving the rtmp connections from flash clients. We provide managed RTMP hosting based on RED5.
Red5 is shared on our shared hosting plans that means although you can use red5 to stream your videos you will not have access to the red5 folder. Most scripts based on red5 need to upload a folder inside red5/webapps.
This folder is important because it will be on the RTMP path, ex.
rtmp://your-server-ip/folder-name
Install Red5 server on centos 5.x version:-
1. Install Java using yum. :-
yum -y install java-1.6.0-openjdk java-1.6.0-openjdk-devel
2. Install the Apache ant binary.
wget http://archive.apache.org/dist/ant/binaries/apache-ant-1.8.1-bin.tar.bz2 tar jxvf apache-ant-1.8.1-bin.tar.bz2 mv apache-ant-1.8.1 /usr/local/ant3. Set important Java environment variables.export ANT_HOME=/usr/local/ant export JAVA_HOME=/usr/lib/jvm/java export PATH=$PATH:/usr/local/ant/bin export CLASSPATH=.:$JAVA_HOME/lib/classes.zip4. Also add them tobashrc
so they are available the next time you log in.echo 'export ANT_HOME=/usr/local/ant' >> /etc/bashrc echo 'export JAVA_HOME=/usr/lib/jvm/java' >> /etc/bashrc echo 'export PATH=$PATH:/usr/local/ant/bin' >> /etc/bashrc echo 'export CLASSPATH=.:$JAVA_HOME/lib/classes.zip' >> /etc/bashrc5. Install subversion with yum. If you did a base install of CentOS, subversion will not be preinstalled.
yum -y install subversion
6. Check out the Red5 source.
cd /usr/src
svn checkout http://red5.googlecode.com/svn/java/server/tags/0_9_1 red5
7. Build Red5 with ant.
mv red5 /usr/local/ cd /usr/local/red5 ant prepare ant dist
8.Start Red5.
cp -r dist/conf .
./red5.sh
9. Create a startup script (optional)
vi /etc/init.d/red5Then enter this text into the file.
# description: Red5 streaming server # processname: red5 . /etc/rc.d/init.d/functions [ -r /etc/sysconfig/red5 ] && . /etc/sysconfig/red5 RETVAL=0 case "$1" in start) echo -n "Starting red5: " cd /usr/local/red5 /usr/local/red5/red5.sh >/dev/null 2>/dev/null & RETVAL=$? if [ $RETVAL -eq 0 ]; then echo $! > /var/run/red5.pid touch /var/lock/subsys/red5 fi [ $RETVAL -eq 0 ] && success $"red5 startup" || failure $"red5 startup" echo ;; stop) echo -n $"Stopping down red5: " killproc -p /var/run/red5.pid RETVAL=$? echo [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/red5 ;; restart) $0 stop $0 start ;; status) status red5 -p /var/run/red5.pid RETVAL=$? ;; *) echo $"Usage: $0 {start|stop|restart|status}" RETVAL=1 esac exit $RETVAL
10. Set permissions on the script.
chmod a+x /etc/init.d/red5
chkconfig red5 on
11. Add necessary ports to the iptables file.
iptables -A INPUT -p tcp -d 0/0 -s 0/0 --dport 5080 -j ACCEPT
iptables -A INPUT -p tcp -d 0/0 -s 0/0 --dport 1935 -j ACCEPT
Then restart iptables :-
service iptables restart
You may want to restart the server, and the Red5 test page can be accessed at http://localhost(or servername):5080/
it'll look like this.
Streaming videos with Red5 Server :-
To upload videos to RED5 server we have to install OFLADEMO.
a.)OFLADEMO :-
To install oflaDemo
download http://red5.googlecode.com/svn-history/r3990/snapshots/oflaDemo-r3989-java6.war
in /red5/webapps (as described above we dont have direct access to RED5,any folder can be upload to webapps folder )and in ssh do jar +x ./oflaDemo-r3989-java6.war
i.e.
i. [root@ip /]cd /usr/local/red5/webapps
ii. [root@ ip webapps] wget http://red5.googlecode.com/svn-history/r3990/snapshots/oflaDemo-r3989-java6.war
iii. unzip the above folder
iv .[root@ip /]chmod 777 /usr/local/red5/webapps/oflaDemo/streams/
b.) Upload Videos to RED5 server using PHP :-
To uplaod files to RED5 server simply we have to give the path to the streams locates in oflademo.
As shown below :-
$red5videopath='/usr/local/red5/webapps/oflademo/streams/';
c.) Streaming Videos with RED5 and oflademo :-
i. ) Go to http://localhost(or servername):5080/
ii.) Click on Launch a demo , Screen will be showing like this :-
iii.) Click on view demo in oflademo and a screen will be showing like this :-
Pass path to oflademo as shown in black dark circle (rtmp://your-server-ip/folder-name)and click on connect :-
After click on connect video will be playing :-
Enjoy media streaming with RED5 server. :-)