`
nanjingjiangbiao_T
  • 浏览: 2594507 次
  • 来自: 深圳
文章分类
社区版块
存档分类
最新评论

基于开源Flash Server:Red5构建RTMP流媒体播放平台

 
阅读更多

我们新建FLASH视频平台带宽消耗及增长比较厉害,看完下面这篇文章,感觉可以再次适当地优化这个流媒体播放平台,以减少对带宽的占用(文章中的建议也很好,10M以下使用HTTP协议,10M以上视频使用RTMP协议)。大家可以探讨一下在平台上同时支持使用HTTP协议与RTMP协议来进行流媒体播放是否可行性?
----------------
基于开源Flash Server:Red5构建RTMP流媒体播放平台
  [文章作者:张宴 本文版本:v1.0 最后修改:2009.04.13 原文链接:http://blog.s135.com/post/409/]
  上周五,我们基于开源Flash Server:Red5(http://osflash.org/red5)的Flash流媒体服务平台上线,内容涉及视频上传、视频分发、调用接口、Flash播放器等。
  一、Flash RTMP流媒体播放演示(播放时进度条可以自由拖动):
(略)
  二、安装步骤简要说明:
  ①、安装JDK
  打开http://java.sun.com/javase/downloads/,下载最新的Java SE Development Kit (JDK),安装在/usr/local/jdk/下。
chmod +x jdk-6u13-linux-i586.bin
./jdk-6u13-linux-i586.bin
  ②、安装Red5
  打开http://osflash.org/red5/070final,下载red5-0.7.0.tar.gz,解压缩后执行./red5.sh,然后访问http://yourdomain:5080/,有演示。
  三、服务器带宽消耗比较:
  ①、客户端 1.5M ADSL 环境,HTTP 方式播放单个视频,服务器所消耗的带宽:
[root@localhost ~]# ./net.sh eth0 1
IN: 3318 Byte/s OUT: 259984 Byte/s
IN: 3486 Byte/s OUT: 249470 Byte/s
IN: 3332 Byte/s OUT: 259984 Byte/s
IN: 3090 Byte/s OUT: 252528 Byte/s
IN: 3000 Byte/s OUT: 252474 Byte/s
IN: 3000 Byte/s OUT: 253976 Byte/s
IN: 2940 Byte/s OUT: 255478 Byte/s
IN: 3004 Byte/s OUT: 252474 Byte/s
IN: 3452 Byte/s OUT: 252528 Byte/s
IN: 3270 Byte/s OUT: 260038 Byte/s
IN: 3586 Byte/s OUT: 252474 Byte/s
  ②、客户端 1.5M ADSL 环境,RTMP 流媒体方式播放单个视频,服务器所消耗的带宽:
[root@localhost ~]# ./net.sh eth0 1
IN: 3900 Byte/s OUT: 27878 Byte/s
IN: 4200 Byte/s OUT: 30868 Byte/s
IN: 4380 Byte/s OUT: 27801 Byte/s
IN: 4080 Byte/s OUT: 29965 Byte/s
IN: 4080 Byte/s OUT: 26450 Byte/s
IN: 3960 Byte/s OUT: 27143 Byte/s
IN: 3000 Byte/s OUT: 10061 Byte/s
IN: 3960 Byte/s OUT: 16166 Byte/s
IN: 3660 Byte/s OUT: 26480 Byte/s
IN: 4020 Byte/s OUT: 23127 Byte/s
  HTTP 方式播放,如果服务器端不限速,客户端的带宽越大,服务器消耗的带宽也越大,但限速又会影响用户体验;
  RTMP 流媒体方式播放,只要客户端达到最低带宽要求,不管客户端的带宽如何,服务器消耗的带宽都一样。
  如果播放10M以内大小的视频,HTTP 能够在较短的时间内下载完视频,能够降低并发观看用户数;
  如果播放10M以上大小的视频,RTMP 要比 HTTP 方式节省不少带宽。
  RTMP 播放时进度条可以自由拖动,虽然Lighttpd和Nginx目前也可以使用somevideo.flv?start=xxx的方式从指定位置下载视频,但还是不如 RTMP 灵活。
  四、带宽测试Shell脚本(net.sh):
#!/bin/bash
# test network width
function usage
{
echo "Usage: $0 "
echo " e.g. $0 eth0 2"
exit 65
}
if [ $# -lt 2 ];then
usage
fi
typeset in in_old dif_in
typeset out out_old dif_out
typeset timer
typeset eth
eth=$1
timer=$2
in_old=$(cat /proc/net/dev | grep $eth | sed -e "s/\(.*\)\:\(.*\)/\2/g" | awk ' { print $1 }' )
out_old=$(cat /proc/net/dev | grep $eth | sed -e "s/\(.*\)\:\(.*\)/\2/g" | awk ' { print $9 }' )
while true
do
sleep ${timer}
in=$(cat /proc/net/dev | grep $eth | sed -e "s/\(.*\)\:\(.*\)/\2/g" | awk ' { print $1 }' )
out=$(cat /proc/net/dev | grep $eth | sed -e "s/\(.*\)\:\(.*\)/\2/g" | awk ' { print $9 }' )
dif_in=$(((in-in_old)/timer))
dif_out=$(((out-out_old)/timer))
echo "IN: ${dif_in} Byte/s OUT: ${dif_out} Byte/s"
in_old=${in}
out_old=${out}
done
exit 0

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics