首页 > 编程知识 正文

如何搭建流媒体服务(视频服务器搭建流媒体)

时间:2023-05-05 11:26:48 阅读:73836 作者:3485

快速构建简单的流媒体服务概述系统配置RTMP协议概述Red5概述Red5服务构建

前言

最近自己在研究流媒体播放的相关技术,但是网上的资料很少。 在查阅开源精神和资料的各位的帮助下,把自己的心得记录下来,便于共享和今后的维护。

在此强烈感谢并推荐雷神(懦弱的气氛)

个人博客: https://blog.csdn.net/lei Xiaohua 1020

系统要构成完整的流媒体系统,需要三个部分:编码器、流媒体服务器和播放器。

编码器对MP3文件和麦克风输入等内容源进行编码,并将编码的内容发送到流式服务器。流式服务器向互联网公开,客户端播放器连接到流式服务器即可

这次构建过程是基于RTMP协议进行的。

RTMP协议概述

播放RTMP协议的流媒体需要经过握手、建立连接、建立流和播放几个步骤。

rmp连接从握手开始。

1 )连接建立阶段用于在客户端和服务器之间建立“网络连接”;2 )流建立阶段用于在客户端和服务器之间建立“网络流”;3 )播放阶段是视频数据Red5概述Red5是一台使用Java开发开源的Flash流媒体服务器。 开源使软件更容易扩展,下载后可以修改源代码更经济,与FMS的昂贵费用相比,Red5可以为常见的APP应用程序节省大量费用,同时服务器端面向Java对象的语言为fmms 考虑到Red5的各种好处,它在推出后不久就被很多用户接受了。

Red 5支持:

将音频(MP3 )和视频(FLV、F4V、MP4、3gp )转换为播放流

录制客户端的播放流,将摄像机、麦克风等发送的音视频录制保存到服务器中

共享对象;

现场流分发

远程呼叫;

协议:RTMP、RTMPT、RTMPS和and RTMPE。

Red5服务器构建并自行安装JDK本文不进行演示

参考: https://jingyan.Baidu.com/article/6 dad 5075 D1 DC 40 a123 e 36 ea3. html

下载Red5:(本人使用版本:1.0.10 )。

官网: http://red5.org/

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

下载并解压缩到自己的固定文件夹中。 图:

或者,可以在conf/red5.properties文件下更改IP和端口号

# socket policy.host=0.0.0.0 policy.port=843 # http http.host=192.168.1.115/其中HTTP IP地址http.port=5080 https.port=5443 http.uri encoding=utf-8 http.max _ headers _ size=8192 http.max e=20 # rtmp rtmp.host=192.168.1.115/其中IP地址rtmp.port=1935 rtmp.io _ threads=8rtmp.send _ buffer _ size=65536 rtmp.receive _ buffer _ size=655555306; MP.TCP _ keepalive=false rtmp.default _ server _ bandwidth ent _ bandwidth _ limit _ type=2rt MP.bandwidth _ detth r trafficoptimizationhinting.todisablesettrafficclasssetto-1 # lowdelayhighthroughput==24 (0x 18 ) rtmp.traffic _ class requestedmaximumlengthofthequeueofinconnectionsrtmp.backkic

na acceptorrtmp.default_acceptor=true# socket i/o pool sizes used when default acceptor is disabledrtmp.initial_pool_size=0rtmp.max_pool_size=2rtmp.max_processor_pool_size=8rtmp.executor_keepalive_time=60000mina.logfilter.enable=false# scheduler configs (per application)rtmp.scheduler.pool_size=8rtmp.deadlockguard.sheduler.pool_size=8# message executor configs (per application) - adjust these as needed if you get tasks rejectedrtmp.executor.core_pool_size=4rtmp.executor.max_pool_size=32rtmp.executor.queue_capacity=64# drop audio packets when queue is almost full, to disable this, set to 0rtmp.executor.queue_size_to_drop_audio_packets=60# maximum amount of time allotted to process a single rtmp message / packet in milliseconds, set it as 0 to disable timeoutrtmp.max_handling_time=2000# connection tweaks - dont modify unless you know what you're doingrtmp.channel.initial.capacity=3rtmp.channel.concurrency.level=1rtmp.stream.initial.capacity=1rtmp.stream.concurrency.level=1rtmp.pending.calls.initial.capacity=3rtmp.pending.calls.concurrency.level=1rtmp.reserved.streams.initial.capacity=1rtmp.reserved.streams.concurrency.level=1# maximum packet size allowed in bytesrtmp.max_packet_size=3145728# RTMPSrtmps.host=0.0.0.0rtmps.port=8443rtmps.ping_interval=5000rtmps.max_inactivity=60000rtmps.max_keep_alive_requests=-1rtmps.max_threads=8rtmps.acceptor_thread_count=2rtmps.processor_cache=20# RTMPS Key and Trust store parametersrtmps.keystorepass=passwordrtmps.keystorefile=conf/keystore.jksrtmps.truststorepass=passwordrtmps.truststorefile=conf/truststore.jks# RTMPTrtmpt.host=0.0.0.0rtmpt.port=8088rtmpt.ping_interval=5000rtmpt.max_inactivity=60000rtmpt.max_handshake_time=5000rtmpt.max_keep_alive_requests=-1rtmpt.max_threads=8rtmpt.acceptor_thread_count=2rtmpt.processor_cache=20rtmpt.encoder_base_tolerance=5000rtmpt.encoder_drop_live_future=true# better setting for streaming mediartmpt.target_reponse_size=32768# best setting for small messages or shared objects#rtmpt.target_reponse_size=8192# max incoming messages to process at a time. the most that FP appears to send is 166rtmpt.max_in_msg_process=166# max time in millis that we will wait when offering data to the in or out queuertmpt.max_queue_offer_time=125# max offer attemptsrtmpt.max_queue_offer_attempts=4# Debug proxy (needs to be activated in red5-core.xml)proxy.source_host=127.0.0.1proxy.source_port=1936proxy.destination_host=127.0.0.1proxy.destination_port=1935# JMXjmx.rmi.host=localhostjmx.rmi.port=9999jmx.rmi.sport=9998jmx.rmi.port.remoteobjects=jmx.keystorepass=passwordjmx.mina.monitor.enable=falsejmx.mina.poll.interval=1000# Whether to always create the registry in-process, not attempting to # locate an existing registry at the specified port. Set to "true" in order# to avoid the overhead of locating an existing registry when you always intend# to create a new registry in any case.jmx.registry.create=true# Whether or not the MBeanServerFactoryBean should attempt to locate a running # MBeanServer before creating onejmx.reuse.existing.server=true# Whether to register the MBeanServer with the MBeanServerFactory, making it # available through MBeanServerFactory.findMBeanServer()jmx.register.factory=true# Whether any threads started for the JMXConnectorServer should be started as daemon threadsjmx.daemon=true# Whether the JMXConnectorServer should be started in a separate threadjmx.threaded=true# Server properties# max events to send in a single updateso.max.events.per.update=64so.scheduler.pool_size=4keyframe.cache.entry.max=500war.deploy.server.check.interval=600000fileconsumer.delayed.write=truefileconsumer.queue.size=120fileconsumer.wait.for.keyframe=truesubscriberstream.buffer.check.interval=5000subscriberstream.underrun.trigger=100subscriberstream.max.pending.frames=10subscriberstream.max.sequential.frames=10broadcaststream.auto.record=false

启动red5.bat

出现上图后在浏览器输入:http://IP:port/
如:http://192.168.1.115:5080/

即代表启动成功!

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。