Red5服务器搭建(实现在线直播,流媒体视频播放)

article/2025/10/30 11:59:52

 

引言

流媒体文件是目前非常流行的网络媒体格式之一,这种文件允许用户一边下载一边播放,从而大大减少了用户等待播放的时间。另外通过网络播放流媒体文件时,文件本身不会在本地磁盘中存储,这样就节省了大量的磁盘空间开销。正是这些优点,使得流媒体文件被广泛应用于网络播放。

流媒体服务器是通过建立发布点来发布流媒体内容和管理用户连接的。流媒体服务器能够发布从视频采集卡或摄像机等设备中传来的实况流,也可以发布事先存储的流媒体文件,并且发布实况流和流媒体文件的结合体。一个媒体流可以由一个媒体文件构成,也可以由多个媒体文件组合而成,还可以由一个媒体文件目录组成。

Flash Media Server,简称 FMS,是 Flash 大家庭里的一员,被称为是目前开发 Web 音视频应用程序(比如,视频聊天室、视频会议系统、播客系统、音视频留言等等)的最方便最快捷的解决方案。也在 web 应用程序开发上有着越来越广泛的应用。当然 FMS 这种优良功能并不是免费提供给广大用户的,几千美金每个点的价格让很多开发人员望而却步。于是,大家开始尝试寻找一种更合适的解决方案,开源的 Red5 便成为了人们的新宠。

Red5 是一个采用 Java 开发的开源的 Flash 流媒体服务器,功能上与 FMS 类似。它支持:把音频(MP3)和视频(FLV)转换成播放流;录制客户端播放流(只支持 FLV);共享对象;现场直播流发布;远程调用。Red5 使用 RSTP 作为流媒体传输协议,包括在线录制,Flash 流媒体播放,在线聊天,视频会议等一些基本功能。国内外基于 Red5 的流媒体应用产品也在不断推广,例如在线视频会议 Openmeeting,大型 Flash 网游功夫之王 2。

Red5 概述

Red5 是一个采用 Java 开发开源的 Flash 流媒体服务器。免费开源使软件更加容易扩展,下载后你可以对源代码进行修改;更加经济,比起 FMS 高昂的费用,Red5 能为一般的应用节约大笔费用;同时服务器端的 Java 面向对象语言比起 FMS 服务器端的 ActionScript2 语言更加成熟。鉴于 Red5 的种种优势,推出不久便被广大用户所接受。

Red 5 支持:

1. 把音频(MP3)和视频(FLV, F4V, MP4, 3GP)转换成播放流;

2. 录制客户端播放流, 把摄像头,麦克风等传入的音频视频录制保存到服务器;

3. 共享对象;

4. 现场直播流发布;

5. 远程调用;

6. 协议:RTMP, RTMPT, RTMPS, and RTMPE。

Red5 服务器搭建

JDK自行安装

下载Red5

https://github.com/Red5/red5-server/releases

解压到自己的一个能记住的文件夹中 eg:F:\Red5

配置Red5相关参数

修改red5.properties配置文件..\conf\red5.properties

只需要配置HTTP 和RMTP节点的host和port即可 默认也行host配置成0.0.0.0 输入局域网IP或者127.0.0.1都可以正常访问

 
  1. # Socket policy

  2. policy.host=0.0.0.0

  3. policy.port=843

  4.  
  5. # HTTP

  6. http.host=0.0.0.0

  7. http.port=8855

  8. https.port=5443

  9. http.URIEncoding=UTF-8

  10. http.max_keep_alive_requests=-1

  11. http.max_threads=20

  12. http.acceptor_thread_count=10

  13. http.processor_cache=20

  14.  
  15. # RTMP

  16. rtmp.host=0.0.0.0

  17. rtmp.port=1935

  18. rtmp.io_threads=16

  19. rtmp.send_buffer_size=65536

  20. rtmp.receive_buffer_size=65536

  21. rtmp.ping_interval=1000

  22. rtmp.max_inactivity=60000

  23. rtmp.max_handshake_time=5000

  24. rtmp.tcp_nodelay=true

  25. rtmp.tcp_keepalive=false

  26. rtmp.default_server_bandwidth=10000000

  27. rtmp.default_client_bandwidth=10000000

  28. rtmp.client_bandwidth_limit_type=2

  29. rtmp.bandwidth_detection=false

  30. rtmp.encoder_base_tolerance=5000

  31. rtmp.encoder_drop_live_future=false

  32. # traffic optimization hinting. to disable set traffic class set to -1

  33. # low delay + high throughput == 24 (0x18)

  34. rtmp.traffic_class=-1

  35. # requested maximum length of the queue of incoming connections

  36. rtmp.backlog=32

  37. # the interval (seconds) between each throughput calculation

  38. rtmp.thoughput_calc_interval=15

  39. # enable use of the default mina acceptor

  40. rtmp.default_acceptor=true

  41. # socket i/o pool sizes used when default acceptor is disabled

  42. rtmp.initial_pool_size=0

  43. rtmp.max_pool_size=2

  44. rtmp.max_processor_pool_size=16

  45. rtmp.executor_keepalive_time=60000

  46. mina.logfilter.enable=false

  47. # scheduler configs (per application)

  48. rtmp.scheduler.pool_size=16

  49. rtmp.deadlockguard.sheduler.pool_size=16

  50. # message executor configs (per application) - adjust these as needed if you get tasks rejected

  51. rtmp.executor.core_pool_size=4

  52. rtmp.executor.max_pool_size=32

  53. rtmp.executor.queue_capacity=64

  54. # drop audio packets when queue is almost full, to disable this, set to 0

  55. rtmp.executor.queue_size_to_drop_audio_packets=60

  56. # maximum amount of time allotted to process a single rtmp message / packet in milliseconds, set it as 0 to disable timeout

  57. rtmp.max_handling_time=2000

  58. # connection tweaks - dont modify unless you know what you're doing

  59. rtmp.channel.initial.capacity=3

  60. rtmp.channel.concurrency.level=1

  61. rtmp.stream.initial.capacity=1

  62. rtmp.stream.concurrency.level=1

  63. rtmp.pending.calls.initial.capacity=3

  64. rtmp.pending.calls.concurrency.level=1

  65. rtmp.reserved.streams.initial.capacity=1

  66. rtmp.reserved.streams.concurrency.level=1

  67.  
  68. # RTMPS

  69. rtmps.host=0.0.0.0

  70. rtmps.port=8443

  71. rtmps.ping_interval=5000

  72. rtmps.max_inactivity=60000

  73. rtmps.max_keep_alive_requests=-1

  74. rtmps.max_threads=20

  75. rtmps.acceptor_thread_count=2

  76. rtmps.processor_cache=20

  77. # RTMPS Key and Trust store parameters

  78. rtmps.keystorepass=password

  79. rtmps.keystorefile=conf/keystore.jks

  80. rtmps.truststorepass=password

  81. rtmps.truststorefile=conf/truststore.jks

  82.  
  83. # RTMPT

  84. rtmpt.host=0.0.0.0

  85. rtmpt.port=8088

  86. rtmpt.ping_interval=5000

  87. rtmpt.max_inactivity=60000

  88. rtmpt.max_handshake_time=5000

  89. rtmpt.max_keep_alive_requests=-1

  90. rtmpt.max_threads=20

  91. rtmpt.acceptor_thread_count=2

  92. rtmpt.processor_cache=20

  93. rtmpt.encoder_base_tolerance=5000

  94. rtmpt.encoder_drop_live_future=true

  95. # better setting for streaming media

  96. rtmpt.target_reponse_size=32768

  97. # best setting for small messages or shared objects

  98. #rtmpt.target_reponse_size=8192

  99. # max incoming messages to process at a time. the most that FP appears to send is 166

  100. rtmpt.max_in_msg_process=166

  101. # max time in millis that we will wait when offering data to the in or out queue

  102. rtmpt.max_queue_offer_time=125

  103. # max offer attempts

  104. rtmpt.max_queue_offer_attempts=4

  105.  
  106. # WebSocket

  107. ws.host=0.0.0.0

  108. ws.port=8081

  109.  
  110. # Debug proxy (needs to be activated in red5-core.xml)

  111. proxy.source_host=127.0.0.1

  112. proxy.source_port=1936

  113. proxy.destination_host=127.0.0.1

  114. proxy.destination_port=1935

  115.  
  116. # JMX

  117. jmx.rmi.host=localhost

  118. jmx.rmi.port=9999

  119. jmx.rmi.sport=9998

  120. jmx.rmi.port.remoteobjects=

  121. jmx.keystorepass=password

  122. jmx.mina.monitor.enable=false

  123. jmx.mina.poll.interval=1000

  124. # Whether to always create the registry in-process, not attempting to

  125. # locate an existing registry at the specified port. Set to "true" in order

  126. # to avoid the overhead of locating an existing registry when you always intend

  127. # to create a new registry in any case.

  128. jmx.registry.create=true

  129. # Whether or not the MBeanServerFactoryBean should attempt to locate a running

  130. # MBeanServer before creating one

  131. jmx.reuse.existing.server=true

  132. # Whether to register the MBeanServer with the MBeanServerFactory, making it

  133. # available through MBeanServerFactory.findMBeanServer()

  134. jmx.register.factory=true

  135. # Whether any threads started for the JMXConnectorServer should be started as daemon threads

  136. jmx.daemon=true

  137. # Whether the JMXConnectorServer should be started in a separate thread

  138. jmx.threaded=true

  139.  
  140. # Server properties

  141. # max events to send in a single update

  142. so.max.events.per.update=64

  143. so.scheduler.pool_size=4

  144. keyframe.cache.entry.max=500

  145. war.deploy.server.check.interval=600000

  146. fileconsumer.delayed.write=true

  147. fileconsumer.queue.size=120

  148. subscriberstream.buffer.check.interval=5000

  149. subscriberstream.underrun.trigger=100

  150. broadcaststream.auto.record=false

启动Red5

双击red.bat即可启动Red5服务器

浏览器访问查看是否搭建成功

http://localhost:port(localhost、port为配置文件中设置) 正确如下图所示

视频直播开始准备

下载demo

上图可以看到install红色的那行字。点击进去。选择OLFA 安装

如果下载不成功请看这里

确定webapps下面没有oflaDemo文件夹。下载小帅丶准备好的压缩包解压放进去即可

下载地址链接: https://pan.baidu.com/s/1Qd0UggtEhBv5nbVxQGPSzQ 密码: 4xqf

设置信息发布直播

进入发布设置界面:http://localhost:port/demos/publisher.html

查看Settings区域。选择Video后在Device中选择摄像头,并点击Start,出现视频画面(有可能会提示是否允许。选择允许即可)

Server设置

回到Server画面,在Location中输入rtmp://localhost:1935/oflaDemo,地址与red5.properties中的rtmp协议的设置必须相同。
点击Connect

右侧出现NetConnection.Connect.Success ,说明连接服务器成功。

推送视频流

切换到Video点击Publish页面中的Publish按钮即可对外发布直播

查看视频流

切换到Server点击play即可看推送的视频流

用自己的页面观看直播

需要jwplayer。为了方便大家已经放在oflaDemo里面。在上面的百度云链接下载即可。

修改相关内容 file的值是直播页面的Name的值。streamer则为Location里面的URL

 
  1. <html>

  2. <head>

  3. <title>Red5 - OFLADemo</title>

  4. <script type='text/javascript' src='jwplayer.js'></script>

  5. </head>

  6. <body>

  7. <div id="player">

  8. <script type='text/javascript'>

  9. jwplayer('player').setup({

  10. 'flashplayer': 'player.swf',

  11. 'file': '直播页面的Name',

  12. 'streamer': 'rtmp://自己服务的IP:1935/oflaDemo',

  13. 'controlbar': 'bottom',

  14. 'width': '848',

  15. 'height': '360'

  16. });

  17. </script>

  18. </div>

  19. </body>

  20. </html>

使用浏览器观看

输入地址 http://localhost:port/oflaDemo/jwPalyer.html 即可查看

以上就是Red5的服务器搭建步骤


http://chatgpt.dhexx.cn/article/H29p8xZ3.shtml

相关文章

Red5 流媒体服务器 的使用(开发)

1. 什么是Red5. Red5是一个开源项目&#xff0c;用于实现flash与服务器端之间通过rtmp(real time messaging protocal)协议通信&#xff0c;可以实现视频、音频的传输&#xff0c;remote shared object等等。相对于FMS, Red5是免费、开源的。 2. 环境搭建(用Tomcat好了). 首先下…

CentOS 7下Red5流媒体服务器的搭建与测试

Red5流媒体服务器的搭建 一、Red5流媒体简介二、搭建流程1、下载Red52、修改Red5相关配置3、启动Red5服务器4、问题解决问题1&#xff1a;问题2&#xff1a; 5、测试环节6、结语 一、Red5流媒体简介 Red5流媒体服务器是一个采用Java开发的开源免费的Flash流媒体服务器。并且相…

常用流媒体服务器

1、Mediasoup mediasoup是相对比较新的一个WebRTC服务器端的开源项目。它更多是通过集成包方式和其他应用服务器来集成。它支持SFU模式&#xff0c;主要支持视频聊天&#xff0c;媒体流广播等。 其特点是&#xff1a; 通过底层API实现和第三方集成&#xff0c;安装简单&#…

开源流媒体服务器Red5实施案列分析

Red5是一个采用Java开发开源的Flash流媒体服务器。它支持&#xff1a;把音频 &#xff08;MP3&#xff09;和视频&#xff08;FLV&#xff09;转换成播放流&#xff1b; 录制客户端播放流&#xff08;只支持FLV&#xff09;&#xff1b;共享对象&#xff1b;现场直播流发布&…

Red5流媒体服务器的搭建与使用

什么是流媒体服务器 流媒体指以流形式在网络中传送音频、视频和多媒体文件的媒体形式。相对于下载后观看的网络播放形式而言&#xff0c;流媒体的典型特征是把连续的音频和视频信息压缩后放到网络服务器上&#xff0c;用户边下载边观看&#xff0c;而不必等待整个文件下载完毕…

Red5流媒体服务器初探——Red5服务器的搭建

由于个人的兴趣爱好&#xff0c;想利用手中的树莓派搭建一个环境监控系统。由于需要一个流媒体服务器用于多媒体数据的接收与推送&#xff0c;所以最近稍微了解了下Red5 Media Server方面的东西。 搭建Red5服务器 首先在百度中搜索“Red5”关键字可以获得以下链接&#xff1a;…

Red5流服务器搭建(实现在线直播,流媒体视频播放和在线视频会议)

最近研究了一下流媒体技术&#xff0c;也试着用免费开源的Red5搭建了流服务器&#xff0c;实现了直播&#xff0c;视频播放&#xff0c;远程视频会议等功能&#xff0c;下面是近期实践的总结&#xff0c; 一. 先介绍一下流媒体技术&#xff1a; 所谓流媒体技术&#xff0c;是…

搭建Windows Red5流媒体服务器详解

搭建Windows Red5流媒体服务器详解 环境 win7 64 位 一、下载程序 setup-Red5-1.0.0-java6.exe 或者 setup-Red5-1.0.1-java6.exe 推荐 下载1.0.1 版本 &#xff0c; 后面rtmp 播放使用的是1.0.1 版本的red5 red51.0.0 下载地址 http://download.csdn.net/detail/keepin…

Red5流媒体服务器的搭建

Red5搭建耗了我很多时间&#xff0c;尝试了Red5的N多个版本&#xff0c;从0.9.0~1.0.5都试过了。 还有JDK的版本&#xff0c;也尝试了很多从jdk6u43到jdk7u79都试过了。 我主要的一个问题就是&#xff0c;在Red5的安装页面看不到安装的AppName&#xff0c;因此我试了很多都不…

(一)使用RED5搭建流媒体服务器

——–本次是在windows中搭建成功&#xff0c;并且成功演示demo 1.安装好jdk red5-server-1.05 以下需要JDK-1.7 red5-server-1.06 以上需要JDK-1.8 2.到官方下载red5-server-1.04 压缩文件 https://github.com/Red5/red5-server/releases 安装步骤&#xff1a; 1&#…

nginx+red5流媒体服务器搭建

公司 近期要开展演练投票&#xff0c;需要对演练视频进行观看&#xff0c;由于服务器资源有限&#xff0c;所以决定将视频部署到多个流媒体上&#xff0c;并且通过nginx进行负载调节&#xff1b; 一、red5流媒体搭建 Red5 是一个采用 Java 开发开源的 Flash 流媒体服务器。 下…

【Java】Red5服务器搭建(实现在线直播,流媒体视频播放)

为什么80%的码农都做不了架构师&#xff1f;>>> 引言 流媒体文件是目前非常流行的网络媒体格式之一&#xff0c;这种文件允许用户一边下载一边播放&#xff0c;从而大大减少了用户等待播放的时间。另外通过网络播放流媒体文件时&#xff0c;文件本身不会在本地磁盘中…

Red5流媒体服务器的完整尝试

1、下载Red5以及Java环境 所需要的文件如下&#xff1a;JDK可利用华为镜像快速下载 然后解压JDK与red5,配置JDK环境变量JAVA_HOMEE:\Program Files\Java\jdk1.8.0_20 配置好运行环境后&#xff0c;点击red5.bat即可启动&#xff0c;在浏览器地址栏输入http://localhost:5080/出…

流媒体服务器之Red5环境搭建

首先先介绍一下RED5&#xff0c;Red5的主要功能和Macromedia公司的FMS类似&#xff0c;提供基于Flash的流媒体服务的一款基于Java的开源流媒体服务器。它由Java语言编写&#xff0c;使用RTMP作为流媒体传输协议&#xff0c;这与FMS完全兼容。它具有流化FLV、MP3文件&#xff0c…

java语言【#106. 求绝对值】(已通过)

题目描述 ​ 在数学中&#xff0c;对于小于 0 的实数 n 来说&#xff0c;它的绝对值等于 −n&#xff0c;而对于大于等于 0 的实数来说&#xff0c;它的绝对值等于自身。 ​ 输入一个实数&#xff0c;输出它的绝对值。 输入 ​ 输入一个实数 n &#xff08;−100.0≤n≤100.0…

java求数字的绝对值

1.代码如下&#xff1a; package com.aaa;import java.util.Scanner;public class Shuzi {public static void main(String[] args) { // 求数字的绝对值Scanner scnew Scanner(System.in);while (true) {System.out.println("请输入你要判断的数字");double…

java中负数取绝对值,面试篇

前言: 这篇文章主要介绍了26道Spring经典面试题总结(附带答案)的相关资料,小编在网上看到的觉得挺不错的,现在分享给大家,希望对你们有所帮助。 另外本人整理收藏了多家公司面试知识点整理 ,以及各种Java核心知识点免费分享给大家,下方只是部分截图 想要资料的话也可以在…

CentOS7.4配置OpenLDAP Client集成AD服务及SSSD服务与SSH服务

一、前置准备 1、基础环境说明 客户端操作系统&#xff1a;CentOS 7.4 core AD服务器&#xff1a;WinServer 2012 R2 2、AD证书导出 1).服务器管理 服务器管理→AD CS→证书颁发机构→所有任务→备份CA 2).证书备份(导出) 备份项目→设置密码(默认为空)→完成 二、OpenL…

通过AD域验证登录Linux系统(Linux安装sssd加入Windows AD域)

背景 有一台Centos 7 的Linux服务器&#xff0c;需要每个IT管理员都可以登录并进行维护&#xff0c;为了方便账户管理&#xff0c;统一认证&#xff0c;要求Linux服务器登录实现Windows AD域验证。 环境说明 AD域&#xff1a;Windows server 2019 AD域主机IP : 192.168.100.…

使用AFS, Active Directory和SSSD搭建用于集成电路设计的分布式存储系统 【十七】部署 AFS 客户端 2 统一身份登录

使用AFS, Active Directory和SSSD搭建用于集成电路设计的分布式存储系统 【十七】部署 AFS 客户端 2 统一身份登录 Linux 统一身份登录和查询POSIX 属性 (POSIX Attributes)安装组件程序加入 AD 域测试 LDAP 查询配置 NSS 和 PAM配置 SSSD验证 SSSD 配置针对 AFS 进一步配置 PA…