前言
什么是Red5
Red5的主要功能和Macromedia公司的FMS类似,提供基于Flash的流媒体服务的一款基于Java的开源流媒体服务器。它由Java语言编写,使用RTMP作为流媒体传输协议,这与FMS完全兼容。它具有流化FLV、MP3文件,实时录制客户端流为FLV文件,共享对象,实时视频播放、Remoting等功能。用Red5替换FMS后,客户端不用更改可正常运行。
搭建思路
搭建准备
1.JDK环境
搭建
1.搭建Red5服务器
https://github.com/Red5/red5-server/releases
解压并启动
将下载的服务器解压到指定目录,但是目录不可有中文或空格。然后点击red5.bat启动即可
2.使用obs-studio推送视频流
https://obsproject.com
注:
localhost为本地服务器地址,如果远程推送可以写IP或域名
串流密钥稍候拉流时使用
开始推流
3.Html拉流
注:
jwplayer.js和player.swf可从red5-server\webapps\oflaDemo文件夹中获取
red.html中代码
<!DOCTYPE html>
<html lang="zh-cn" >
<head >
<meta charset="utf-8" >
<meta http-equiv="X-UA-Compatible" content="IE=edge" >
<meta name="viewport" content="width=device-width, initial-scale=1" >
<title>Hello Red5</title>
<style type ="text/css" >
.player {
height: 480px;
width: 720px;
margin: 20px auto;
}
</style>
</head>
<body>
<div class='player' >
<div id ='player' ></div>
</div>
<script type ='text/javascript' src='jwplayer.js' ></script>
<script type ='text/javascript' >
jwplayer('player' ).setup({
'flashplayer' : 'player.swf' ,
'file' : 'xujun' ,
'streamer' : 'rtmp://localhost/oflaDemo' ,
'controlbar' : 'bottom' ,
'width' : '720' ,
'height' : '480' ,
'buffer' : '0'
});
</script>
</body>
</html>
其中localhost为拉流服务器地址,file为obs设置的串流密钥
打开red.html开始拉流
注:该播放器为flash播放器,因此浏览器必须开启对flash的支持