Red5服务器搭建,流媒体rtmp推流实现H5在线直播以及遇到的坑

1.先安装JDK,red5运行需要运行在java环境里,(java环境配置自行百度)

2.1下载red5链接,选择适合的版本

https://github.com/Red5/red5-server/releasesRed5服务器搭建,流媒体rtmp推流实现H5在线直播以及遇到的坑_第1张图片

我(第一次下载的是1.2.3最新版本的)第二次下载的是上图的版本,建议用一个比较稳定的版本,解压到你找的到文件夹里,然后修改Red5相关参数

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

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

# Socket policy
policy.host=0.0.0.0
policy.port=843

# HTTP
http.host=192.168.xxx.xxx
http.port=5080
https.port=5443
http.URIEncoding=UTF-8
http.max_headers_size=8192
http.max_keep_alive_requests=-1
http.max_threads=20
http.acceptor_thread_count=10
http.processor_cache=20

# RTMP
rtmp.host=192.168.xxx.xxx
rtmp.port=1935
rtmp.io_threads=8
rtmp.send_buffer_size=65536
rtmp.receive_buffer_size=65536
rtmp.ping_interval=1000
rtmp.max_inactivity=60000
rtmp.max_handshake_time=5000
rtmp.tcp_nodelay=true
rtmp.tcp_keepalive=false
rtmp.default_server_bandwidth=10000000
rtmp.default_client_bandwidth=10000000
rtmp.client_bandwidth_limit_type=2
rtmp.bandwidth_detection=false
rtmp.encoder_base_tolerance=5000
rtmp.encoder_drop_live_future=false
# traffic optimization hinting. to disable set traffic class set to -1
# low delay + high throughput == 24 (0x18)
rtmp.traffic_class=-1
# requested maximum length of the queue of incoming connections
rtmp.backlog=32
# the interval (seconds) between each throughput calculation
rtmp.thoughput_calc_interval=15
# enable use of the default mina acceptor
rtmp.default_acceptor=true
# socket i/o pool sizes used when default acceptor is disabled
rtmp.initial_pool_size=0
rtmp.max_pool_size=2
rtmp.max_processor_pool_size=8
rtmp.executor_keepalive_time=60000
mina.logfilter.enable=false
# scheduler configs (per application)
rtmp.scheduler.pool_size=8
rtmp.deadlockguard.sheduler.pool_size=8
# message executor configs (per application) - adjust these as needed if you get tasks rejected
rtmp.executor.core_pool_size=4
rtmp.executor.max_pool_size=32
rtmp.executor.queue_capacity=64
# drop audio packets when queue is almost full, to disable this, set to 0
rtmp.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 timeout
rtmp.max_handling_time=2000
# connection tweaks - dont modify unless you know what you're doing
rtmp.channel.initial.capacity=3
rtmp.channel.concurrency.level=1
rtmp.stream.initial.capacity=1
rtmp.stream.concurrency.level=1
rtmp.pending.calls.initial.capacity=3
rtmp.pending.calls.concurrency.level=1
rtmp.reserved.streams.initial.capacity=1
rtmp.reserved.streams.concurrency.level=1
# maximum packet size allowed in bytes
rtmp.max_packet_size=3145728

2.3启动Red5

双击red.bat即可启动Red5服务器(遇到的坑,就是双击red.bat时候会出现闪退情况,建议在在widons的dos窗口下启动red5.bat试试,cmd的命令行可以查到报错内容)我的情况如下错误

Error: JNI error occurred, please check the installation and try again

Exception in thread "main" java.lang.unsupportiedclassversionerror: org / red5 / server / bootstrap has been compiled by a newer version of Java runtime (class file version 55.0), which only recognizes class file versions up to 52.0

//下面是翻译

错误:发生JNI错误,请检查安装并重试

线程“main”java.lang.UnsupportedClassVersionError中的异常:org/red5/server/Bootstrap已由较新版本的java运行时(类文件版本55.0)编译,此版本的java运行时仅识别高达52.0的类文件版本

最新版本的red5,用的Java版本比我之前安装的版本高,所以我会运行失败。我重新选择了合适的1.0.1版本red5进行了安装,可以运行起来了。

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

http://localhost:port(localhost、port为配置文件..\conf\red5.properties中设置的,参考2.2的图) ,如下图就说明启动成功了。

Red5服务器搭建,流媒体rtmp推流实现H5在线直播以及遇到的坑_第2张图片

2.5设置信息发布直播

进入发布设置界面:http://localhost:port/demos/publisher.html(localhost:port替换成自己的ip和端口)

Red5服务器搭建,流媒体rtmp推流实现H5在线直播以及遇到的坑_第3张图片

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

Red5服务器搭建,流媒体rtmp推流实现H5在线直播以及遇到的坑_第4张图片

我用chrome浏览器访问会存在的问题,video 选择时候会出现下图情况No video

Red5服务器搭建,流媒体rtmp推流实现H5在线直播以及遇到的坑_第5张图片

我换成IE浏览器访问就可以从video里找到可选择的播放设备。按照下面的步骤可以进行推流。

Red5服务器搭建,流媒体rtmp推流实现H5在线直播以及遇到的坑_第6张图片

Red5服务器搭建,流媒体rtmp推流实现H5在线直播以及遇到的坑_第7张图片

修改一下red5-server/webapps/oflaDemo/index.html的配置

  jwplayer('mediaspace').setup({
        'flashplayer': 'player.swf',
        'file': '你的streamid', //你的streamid 很重要哦
        'streamer': 'rtmp://你的ip/oflaDemo',
        'controlbar': 'bottom',
        'width': '720',
        'height': '480'
    });

测试可以访问http://localhost:port/oflaDemo/index.html(localhost:port替换成自己的ip和端口)

Red5服务器搭建,流媒体rtmp推流实现H5在线直播以及遇到的坑_第8张图片

也可以下载VCL播放器播放 rtmp://你的ip/oflaDemo/你的streamid

以上内容我补充了我遇到的问题,参考链接https://blog.csdn.net/u010651369/article/details/80886676

 

你可能感兴趣的:(Red5服务器搭建,流媒体rtmp推流实现H5在线直播以及遇到的坑)