日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

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

發(fā)布時(shí)間:2023/12/20 编程问答 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Red5服务器搭建,流媒体rtmp推流实现H5在线直播以及遇到的坑 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

1.先安裝JDK,red5運(yùn)行需要運(yùn)行在java環(huán)境里,(java環(huán)境配置自行百度)

2.1下載red5鏈接,選擇適合的版本

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

我(第一次下載的是1.2.3最新版本的)第二次下載的是上圖的版本,建議用一個(gè)比較穩(wěn)定的版本,解壓到你找的到文件夾里,然后修改Red5相關(guān)參數(shù)

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

只需要配置HTTP 和RMTP節(jié)點(diǎn)的host和port即可 默認(rèn)也行host配置成0.0.0.0 輸入局域網(wǎng)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啟動(dòng)Red5

雙擊red.bat即可啟動(dòng)Red5服務(wù)器(遇到的坑,就是雙擊red.bat時(shí)候會(huì)出現(xiàn)閃退情況,建議在windows的dos窗口下啟動(dòng)red5.bat試試,cmd的命令行可以查到報(bào)錯(cuò)內(nèi)容)我的情況如下錯(cuò)誤

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

//下面是翻譯

錯(cuò)誤:發(fā)生JNI錯(cuò)誤,請檢查安裝并重試

線程“main”java.lang.UnsupportedClassVersionError中的異常:org/red5/server/Bootstrap已由較新版本的java運(yùn)行時(shí)(類文件版本55.0)編譯,此版本的java運(yùn)行時(shí)僅識(shí)別高達(dá)52.0的類文件版本

最新版本的red5,用的Java版本比我之前安裝的版本高,所以我會(huì)運(yùn)行失敗。我重新選擇了合適的1.0.1版本red5進(jìn)行了安裝,可以運(yùn)行起來了。

2.4瀏覽器訪問查看是否搭建成功

http://localhost:port(localhost、port為配置文件..\conf\red5.properties中設(shè)置的,參考2.2的圖) ,如下圖就說明啟動(dòng)成功了。

2.5設(shè)置信息發(fā)布直播

進(jìn)入發(fā)布設(shè)置界面:http://localhost:port/demos/publisher.html(localhost:port替換成自己的ip和端口)

查看Settings區(qū)域。選擇Video后在Device中選擇攝像頭,并點(diǎn)擊Start,出現(xiàn)視頻畫面(有可能會(huì)提示是否允許。選擇允許即可)

我用chrome瀏覽器訪問會(huì)存在的問題,video 選擇時(shí)候會(huì)出現(xiàn)下圖情況No video

我換成IE瀏覽器訪問就可以從video里找到可選擇的播放設(shè)備。按照下面的步驟可以進(jìn)行推流。

修改一下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和端口)

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

以上內(nèi)容我補(bǔ)充了我遇到的問題,參考鏈接https://blog.csdn.net/u010651369/article/details/80886676

?

總結(jié)

以上是生活随笔為你收集整理的Red5服务器搭建,流媒体rtmp推流实现H5在线直播以及遇到的坑的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。