[red5]开源red5流媒体环境修改视频存放目录的代码
[red5]开源red5流媒体环境修改视频存放目录的代码
安装好red5后先访问http:\\localhost:5080主页,然后安装名为oflaDemo的demo,到webapps里找到该项目后增加一个class文件,java代码如下:
- package org.red5.demos.oflaDemo;
- import org.red5.server.api.scope.IScope;
- import org.red5.server.api.stream.IStreamFilenameGenerator;
- import org.red5.server.api.stream.IStreamFilenameGenerator.GenerationType;
- public class CustomFilenameGenerator
- implements IStreamFilenameGenerator
- {
- public String recordPath;
- public String playbackPath;
- public String generateFilename(IScope scope, String name, IStreamFilenameGenerator.GenerationType type)
- {
- return generateFilename(scope, name, null, type);
- }
- public String generateFilename(IScope scope, String name, String extension, IStreamFilenameGenerator.GenerationType type)
- {
- String filename;
- String filename;
- if (type == IStreamFilenameGenerator.GenerationType.RECORD)
- filename = this.recordPath + name;
- else {
- filename = this.playbackPath + name;
- }
- if (extension != null)
- {
- filename = filename + extension;
- }
- return filename;
- }
- public void setRecordPath(String path) {
- this.recordPath = path;
- }
- public void setPlaybackPath(String path) {
- this.playbackPath = path;
- }
- public boolean resolvesToAbsolutePath() {
- return true;
- }
- }
然后修改配置文件red5—web.xml增加如下内容(我把默认播放目录改为e盘)
- <bean id="streamFilenameGenerator"
- class="org.red5.demos.oflaDemo.CustomFilenameGenerator">
- <property name="recordPath" value="E:\\" />
- <property name="playbackPath" value="E:\\" />
- </bean>
完成,就可以用酷播免费播放器(这是一款免费且支持rtmp流的网页播放器,官方下载 http://www.cuplayer.com/cuplayer/download.html ,下载基础应用的范例就可以了),代码参考:
- <script type="text/javascript" src="/player/images/swfobject.js"></script>
- <div class="video" id="CuPlayer"> <b> <img src="/player/images/loading.gif" />
- 网页视频播放器加载中,请稍后...</b> </div>
- <script type="text/javascript">
- var so = new SWFObject("/Player/player.swf","ply","980","460","9","#000000");
- so.addParam("allowfullscreen","true");
- so.addParam("allowscriptaccess","always");
- so.addParam("wmode","opaque");
- so.addParam("quality","high");
- so.addParam("salign","lt");
- so.addVariable("JcScpServer","rtmp://127.0.0.1/SOSample"); //服务器地址
- so.addVariable("JcScpVideoPath","mp4:test.mp4"); //发布点名称
- so.addVariable("JcScpImg","/player/Images/start.jpg");
- so.addVariable("JcScpFile","/player/CuSunV4Set.xml");
- so.write("CuPlayer");
- </script>
热门文章推荐
- [Red5]Red5之Flash流媒体服务器的安装与使用教程完整版(组图)
- [RED5]搭建RED5直播用流媒体服务(搭直播环境)
- [RED5]Red5的直播与点播的压力测试(并发数的测试)
- [RED5]red5流媒体服务器(开源免费)的安装方法
- [RED5]用red5做视频直播(red5流媒体直播)
- [RED5]Red5在线录制音视频源代码示例
- [RED5]Red5 Client 连接 Red5Server java代码
- [RED5]red5流媒体播放平台搭建环境方法
请稍候...