Red5服务器学习(1)流媒体服务搭建

red5是一个java开源流媒体服务器,总结一下初次使用red5的过程

1 下载安装

red5服务器http://osflash.org/red5 项目地址,下载地址http://code.google.com/p/red5/,下载zip格式,解压之后直接点击red5.bat运行,在浏览器输入http://localohost:5080就能看到demo页面

2 设置一个播放目录

在/red5目录/webapps目录下

建立myvod/WEB_INF目录,配置以下3个文件

*初次使用也不是很清楚这些配置那些是必须项,直接从demo配置里都复制过来了

 myvod/WEB_INF/web.xml

<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app
   xmlns="http://java.sun.com/xml/ns/j2ee"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
   version="2.4">

	<display-name>myvod</display-name>

	<context-param>
		<param-name>webAppRootKey</param-name>
		<param-value>/myvod</param-value>
	</context-param>

</web-app>

 myvod/WEB_INF/red5-web.xml

<?xml version="1.0" encoding="UTF-8" ?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:lang="http://www.springframework.org/schema/lang"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-3.0.xsd">

	<bean id="placeholderConfig" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
	    <property name="location" value="/WEB-INF/red5-web.properties" />
	</bean>

	<bean id="web.context" class="org.red5.server.Context"
		autowire="byType" />

	<bean id="web.scope" class="org.red5.server.WebScope"
		 init-method="register">
		<property name="server" ref="red5.server" />
		<property name="parent" ref="global.scope" />
		<property name="context" ref="web.context" />
		<property name="handler" ref="web.handler" />
		<property name="contextPath" value="${webapp.contextPath}" />
		<property name="virtualHosts" value="${webapp.virtualHosts}" />
	</bean>

	<bean id="web.handler" class="org.red5.server.adapter.ApplicationAdapter" />

</beans>

 

myvod/WEB_INF/red5-web.properties

webapp.contextPath=/myvod
webapp.virtualHosts=*, localhost, localhost:8088, 127.0.0.1:8088

创建一个myvod/streams目录,需要播放的flv文件可以放在里面,复制一个test.flv文件到streams目录,客户端的访问地址就是 rtmp://localhost/myvod/test.flv

*streams目录是red5默认的文件搜索目录,代码实现在DefaultStreamFilenameGenerator.java

3 客户端使用flex4

可以下载一个flash builder 4,可以试用60天

 创建一个simpleplayer项目

编辑simpleplayer.mxml内容如下

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
			   xmlns:s="library://ns.adobe.com/flex/spark" 
			   xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="320" minHeight="200"
			   applicationComplete="init()">
			   
	<fx:Script>
		<![CDATA[
			
			
			public function init() : void {
				myPlayer.source = "rtmp://localhost/myvod/test.flv";
			}
			
		]]>
	</fx:Script>
	
	
	<s:VideoPlayer id="myPlayer" x="0" y="0" width="400" height="330" autoPlay="true" scaleMode="zoom" loop="true"/>
</s:Application>

 

运行一下就能看到在线播放了

 

一个简单的流媒体服务器就可以使用了

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值