av一区二区在线观看_亚洲男人的天堂网站_日韩亚洲视频_在线成人免费_欧美日韩精品免费观看视频_久草视

您的位置:首頁(yè)技術(shù)文章
文章詳情頁(yè)

Java Red5服務(wù)器實(shí)現(xiàn)流媒體視頻播放

瀏覽:3日期:2022-08-14 08:35:45
引言

流媒體文件是目前非常流行的網(wǎng)絡(luò)媒體格式之一,這種文件允許用戶一邊下載一邊播放,從而大大減少了用戶等待播放的時(shí)間。另外通過(guò)網(wǎng)絡(luò)播放流媒體文件時(shí),文件本身不會(huì)在本地磁盤(pán)中存儲(chǔ),這樣就節(jié)省了大量的磁盤(pán)空間開(kāi)銷(xiāo)。正是這些優(yōu)點(diǎn),使得流媒體文件被廣泛應(yīng)用于網(wǎng)絡(luò)播放。

流媒體服務(wù)器是通過(guò)建立發(fā)布點(diǎn)來(lái)發(fā)布流媒體內(nèi)容和管理用戶連接的。流媒體服務(wù)器能夠發(fā)布從視頻采集卡或攝像機(jī)等設(shè)備中傳來(lái)的實(shí)況流,也可以發(fā)布事先存儲(chǔ)的流媒體文件,并且發(fā)布實(shí)況流和流媒體文件的結(jié)合體。一個(gè)媒體流可以由一個(gè)媒體文件構(gòu)成,也可以由多個(gè)媒體文件組合而成,還可以由一個(gè)媒體文件目錄組成。

Flash Media Server,簡(jiǎn)稱 FMS,是 Flash 大家庭里的一員,被稱為是目前開(kāi)發(fā) Web 音視頻應(yīng)用程序(比如,視頻聊天室、視頻會(huì)議系統(tǒng)、播客系統(tǒng)、音視頻留言等等)的最方便最快捷的解決方案。也在 web 應(yīng)用程序開(kāi)發(fā)上有著越來(lái)越廣泛的應(yīng)用。當(dāng)然 FMS 這種優(yōu)良功能并不是免費(fèi)提供給廣大用戶的,幾千美金每個(gè)點(diǎn)的價(jià)格讓很多開(kāi)發(fā)人員望而卻步。于是,大家開(kāi)始嘗試尋找一種更合適的解決方案,開(kāi)源的 Red5 便成為了人們的新寵。

Red5 是一個(gè)采用 Java 開(kāi)發(fā)的開(kāi)源的 Flash 流媒體服務(wù)器,功能上與 FMS 類似。它支持:把音頻(MP3)和視頻(FLV)轉(zhuǎn)換成播放流;錄制客戶端播放流(只支持 FLV);共享對(duì)象;現(xiàn)場(chǎng)直播流發(fā)布;遠(yuǎn)程調(diào)用。Red5 使用 RSTP 作為流媒體傳輸協(xié)議,包括在線錄制,F(xiàn)lash 流媒體播放,在線聊天,視頻會(huì)議等一些基本功能。國(guó)內(nèi)外基于 Red5 的流媒體應(yīng)用產(chǎn)品也在不斷推廣,例如在線視頻會(huì)議 Openmeeting,大型 Flash 網(wǎng)游功夫之王 2。

Red5 概述

Red5 是一個(gè)采用 Java 開(kāi)發(fā)開(kāi)源的 Flash 流媒體服務(wù)器。免費(fèi)開(kāi)源使軟件更加容易擴(kuò)展,下載后你可以對(duì)源代碼進(jìn)行修改;更加經(jīng)濟(jì),比起 FMS 高昂的費(fèi)用,Red5 能為一般的應(yīng)用節(jié)約大筆費(fèi)用;同時(shí)服務(wù)器端的 Java 面向?qū)ο笳Z(yǔ)言比起 FMS 服務(wù)器端的 ActionScript2 語(yǔ)言更加成熟。鑒于 Red5 的種種優(yōu)勢(shì),推出不久便被廣大用戶所接受。

Red 5 支持:

把音頻(MP3)和視頻(FLV, F4V, MP4, 3GP)轉(zhuǎn)換成播放流; 錄制客戶端播放流, 把攝像頭,麥克風(fēng)等傳入的音頻視頻錄制保存到服務(wù)器; 共享對(duì)象; 現(xiàn)場(chǎng)直播流發(fā)布; 遠(yuǎn)程調(diào)用; 協(xié)議:RTMP, RTMPT, RTMPS, and RTMPE。Red5 服務(wù)器搭建

JDK自行安裝 下載Red5

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

解壓到自己的一個(gè)能記住的文件夾中 eg:F:Red5

配置Red5相關(guān)參數(shù)

修改red5.properties配置文件..confred5.properties

只需要配置HTTP 和RMTP節(jié)點(diǎn)的host和port即可 默認(rèn)也行host配置成0.0.0.0 輸入局域網(wǎng)IP或者127.0.0.1都可以正常訪問(wèn)

# Socket policypolicy.host=0.0.0.0policy.port=843 # HTTPhttp.host=0.0.0.0http.port=8855https.port=5443http.URIEncoding=UTF-8http.max_keep_alive_requests=-1http.max_threads=20http.acceptor_thread_count=10http.processor_cache=20 # RTMPrtmp.host=0.0.0.0rtmp.port=1935rtmp.io_threads=16rtmp.send_buffer_size=65536rtmp.receive_buffer_size=65536rtmp.ping_interval=1000rtmp.max_inactivity=60000rtmp.max_handshake_time=5000rtmp.tcp_nodelay=truertmp.tcp_keepalive=falsertmp.default_server_bandwidth=10000000rtmp.default_client_bandwidth=10000000rtmp.client_bandwidth_limit_type=2rtmp.bandwidth_detection=falsertmp.encoder_base_tolerance=5000rtmp.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 connectionsrtmp.backlog=32# the interval (seconds) between each throughput calculationrtmp.thoughput_calc_interval=15# enable use of the default mina 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=16rtmp.executor_keepalive_time=60000mina.logfilter.enable=false# scheduler configs (per application)rtmp.scheduler.pool_size=16rtmp.deadlockguard.sheduler.pool_size=16# 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 # RTMPSrtmps.host=0.0.0.0rtmps.port=8443rtmps.ping_interval=5000rtmps.max_inactivity=60000rtmps.max_keep_alive_requests=-1rtmps.max_threads=20rtmps.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=20rtmpt.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 # WebSocketws.host=0.0.0.0ws.port=8081 # 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=120subscriberstream.buffer.check.interval=5000subscriberstream.underrun.trigger=100broadcaststream.auto.record=false啟動(dòng)Red5

雙擊red.bat即可啟動(dòng)Red5服務(wù)器 瀏覽器訪問(wèn)查看是否搭建成功 http://localhost:port(localhost、port為配置文件中設(shè)置) 正確如下圖所示

Java Red5服務(wù)器實(shí)現(xiàn)流媒體視頻播放

視頻直播開(kāi)始準(zhǔn)備

下載demo

上圖可以看到install紅色的那行字。點(diǎn)擊進(jìn)去。選擇OLFA 安裝

Java Red5服務(wù)器實(shí)現(xiàn)流媒體視頻播放

如果下載不成功請(qǐng)看這里

確定webapps下面沒(méi)有oflaDemo文件夾。下載壓縮包解壓放進(jìn)去即可

下載地址鏈接: https://pan.baidu.com/s/1Qd0UggtEhBv5nbVxQGPSzQ 密碼: 4xqf

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

進(jìn)入發(fā)布設(shè)置界面:http://localhost:port/demos/publisher.html

Java Red5服務(wù)器實(shí)現(xiàn)流媒體視頻播放

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

Java Red5服務(wù)器實(shí)現(xiàn)流媒體視頻播放

Server設(shè)置

回到Server畫(huà)面,在Location中輸入rtmp://localhost:1935/oflaDemo,地址與red5.properties中的rtmp協(xié)議的設(shè)置必須相同。點(diǎn)擊Connect

Java Red5服務(wù)器實(shí)現(xiàn)流媒體視頻播放

右側(cè)出現(xiàn)NetConnection.Connect.Success ,說(shuō)明連接服務(wù)器成功。

Java Red5服務(wù)器實(shí)現(xiàn)流媒體視頻播放

推送視頻流

切換到Video點(diǎn)擊Publish頁(yè)面中的Publish按鈕即可對(duì)外發(fā)布直播

查看視頻流

切換到Server點(diǎn)擊play即可看推送的視頻流

Java Red5服務(wù)器實(shí)現(xiàn)流媒體視頻播放

用自己的頁(yè)面觀看直播

需要jwplayer。為了方便大家已經(jīng)放在oflaDemo里面。在上面的百度云鏈接下載即可。

修改相關(guān)內(nèi)容 file的值是直播頁(yè)面的Name的值。streamer則為L(zhǎng)ocation里面的URL

<html><head><title>Red5 - OFLADemo</title><script type=’text/javascript’ src=’jwplayer.js’></script></head><body><div id='player'><script type=’text/javascript’> jwplayer(’player’).setup({ ’flashplayer’: ’player.swf’, ’file’: ’直播頁(yè)面的Name’, ’streamer’: ’rtmp://自己服務(wù)的IP:1935/oflaDemo’, ’controlbar’: ’bottom’, ’width’: ’848’, ’height’: ’360’ });</script></div></body></html>使用瀏覽器觀看

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

Java Red5服務(wù)器實(shí)現(xiàn)流媒體視頻播放

以上就是Java Red5服務(wù)器實(shí)現(xiàn)流媒體視頻播放的詳細(xì)內(nèi)容,更多關(guān)于Java Red5流媒體視頻播放的資料請(qǐng)關(guān)注好吧啦網(wǎng)其它相關(guān)文章!

標(biāo)簽: Java
相關(guān)文章:
主站蜘蛛池模板: 亚洲一区二区在线播放 | 黄色一级视频网站 | 国产日韩久久 | 久青草影院 | 51成人做爰www免费看网站 | 一级黄色大片 | 亚洲www啪成人一区二区麻豆 | 免费av在线 | 欧美久久久久久久久久 | 国产伦精品一区二区三区免费 | 国产视频一区二区在线观看 | 中文字幕综合网 | 色婷婷中文字幕 | av在线资源网 | 日本高清中文字幕 | 亚洲激情在线视频 | av免费观看在线 | 亚洲国产成人在线 | 国产精品手机在线 | 一级黄色片免费 | 成人一级毛片 | 黄色天堂| 亚洲综合免费 | 国产精品成人免费精品自在线观看 | 欧美在线视频一区二区 | 亚洲激情网 | 久久艹国产 | 麻豆视频国产 | 日韩三级久久 | 97在线观看视频 | 人人干人人艹 | 中文字幕超清在线观看 | 国产一区二区三区精品视频 | 久草视频在线播放 | 国产精品国产三级国产 | 国产精品久久久一区二区三区 | 中文字幕超清在线观看 | 亚洲免费在线观看 | av片在线观看| 成人婷婷 | 国产精品自拍第一页 |