red5介绍
Red5是一个采用Java开发开源的Flash流媒体服务器。它支持:把音频(MP3)和视频(FLV)转换成播放流; 录制客户端播放流(只支持FLV);共享对象;现场直播流发布;远程调用。Red5使用RSTP作为流媒体传输协议,在其自带的一些示例中演示了在线录制,flash流媒体播放,在线聊天,视频会议等一些基本功能。
red5安装
1.jdk安装
安装时把以前的java的rpm删除
1)给jdk-6u20-linux-i586.bin 加上可执行权限
2)./jdk-6u20-linux-i586.bin
运行之后会在当前目录下生成jdk1.6.0_20把这目录拷贝至/usr/local下
2.apache-ant
下载apache-ant-1.8.1-bin.tar.gz 包bin的不用编译解压后直接使用
mv apache-ant-1.8.1 /usr/local/ant
在/etc/profile加入
export ANT_HOME=/usr/local/ant
export JAVA_HOME=/usr/local/jdk1.6.0_20/
export CLASSPATH=.:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar
export PATH=$PATH:$ANT_HOME/bin:$JAVA_HOME/bin
source /etc/profile使配置生效
3.red5
这里使用的red5版本是red5-0.9.1.zip
mkdir /usr/local/red5
cp red5-0.9.1.zip /usr/local/red5
unzip red5-0.9.1.zip
vi /usr/local/red5/conf/red5.properties
下面的IP为本机IP,端口不能冲突
rtmp.host_port = 0.0.0.0:1935
debug_proxy.host_port = 0.0.0.0:1936
proxy_forward.host_port = 127.0.0.1:1935
rtmps.host_port = 127.0.0.1:1945
http.host=192.168.6.112
http.port=5080
rtmpt.host=192.168.6.112
rtmpt.port=8888
demos放置的目录为
/usr/local/red5/webapps/root/demos/SimpleChat.swf
开启服务、开放5080端口、浏览器访问测试
cd /usr/local/red5/
./red5.sh&
http://192.168.6.112:5080/demos/BallControl.swf
把red5作为一个redhat系列系统服务使用
拷贝一份red5.sh为/etc/init.d/red5
chmod 755 /etc/init.d/red5
red5内容为下
#!/bin/bash
#
# Startup script for Red5 flash streaming server
#
# chkconfig: 345 81 81
# description: RED5 by java
#
# processname: java (unfortunately)
# pidfile: /var/run/red5.pid
# config: /etc/red5.conf
# Source function library.
. /etc/rc.d/init.d/functions
PID_FILE=/var/run/red5.pid
PID=`ps ax |grep java|grep red5|awk '{print $1;}'`
RETVAL=0
start() {
echo -n $"Starting $DESCR: "
export ANT_HOME=/usr/local/ant
export JAVA_HOME=/usr/local/jdk1.5.0_22/
export CLASSPATH=.:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar
export PATH=$PATH:$ANT_HOME/bin:$JAVA_HOME/bin
#red5所在目录
cd /usr/local/red5
#red5的red5.sh文件内容
if [ -z "$RED5_HOME" ]; then
export RED5_HOME=`pwd`;
fi
P=":" # The default classpath separator
OS=`uname`
case "$OS" in
CYGWIN*|MINGW*) # Windows Cygwin or Windows MinGW
P=";" # Since these are actually Windows, let Java know
;;
Darwin*)
;;
*)
# Do nothing
;;
esac
echo "Running on " $OS
export ANT_HOME=/usr/local/ant
export JAVA_HOME=/usr/local/jdk1.6.0_20/
export CLASSPATH=.:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar
export PATH=$PATH:$ANT_HOME/bin:$JAVA_HOME/bin
# JAVA options
# You can set JAVA_OPTS to add additional options if you want
# Set up logging options
LOGGING_OPTS="-Dlogback.ContextSelector=org.red5.logging.LoggingContextSelector -Dcatalina.useNaming=true"
# Set up security options
SECURITY_OPTS="-Djava.security.debug=failure"
export JAVA_OPTS="$LOGGING_OPTS $SECURITY_OPTS $JAVA_OPTS"
if [ -z "$RED5_MAINCLASS" ]; then
export RED5_MAINCLASS=org.red5.server.Bootstrap
fi
# Jython options
JYTHON="-Dpython.home=lib"
for JAVA in "${JAVA_HOME}/bin/java" "${JAVA_HOME}/Home/bin/java" "/usr/bin/java" "/usr/local/bin/java"
do
if [ -x "$JAVA" ]
then
break
fi
done
if [ ! -x "$JAVA" ]
then
echo "Unable to locate Java. Please set JAVA_HOME environment variable."
exit
fi
export RED5_CLASSPATH="${RED5_HOME}/boot.jar${P}${RED5_HOME}/conf${P}${CLASSPATH}"
# start Red5
echo "Starting Red5"
exec "$JAVA" "$JYTHON" -Dred5.root="${RED5_HOME}" $JAVA_OPTS -cp "${RED5_CLASSPATH}" "$RED5_MAINCLASS" $RED5_OPTS > /dev/null 2>&1 & RETVAL=$?
#red5.sh内容完毕
[ $RETVAL = 0 ] && touch /var/lock/subsys/red5 && echo $! >$PID_FILE && echo_success
echo
return $RETVAL
}
stop(){
echo -n $"Stopping $DESCR: "
#killproc $PID_FILE
[[ $PID != "" ]] && success && kill $PID || failure
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -rf /var/lock/subsys/red5 $PID_FILE
}
#See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
sleep 3
start
;;
*)
echo $"Usage: $DESCR{start|stop|restart}"
exit 1
esac
exit $RETVAL
参考资料
http://www.linuxidc.com/Linux/2010-03/25162.htm
http://hi.baidu.com/weiqi228/blog/item/911508f501986827bc3109c2.html
https://www.tusurfer.com/tus/user_guide.do#1.Download client|outline
http://ant.apache.org/
本文转自 qwjhq 51CTO博客,原文链接:http://blog.51cto.com/bingdian/321968