最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

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

 更新時間:2021年04月22日 11:00:55   作者:小帥丶  
這篇文章主要介紹了Java Red5服務(wù)器實現(xiàn)流媒體視頻播放,對視頻播放感興趣的同學(xué),可以參考下

引言

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

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

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

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

Red5 概述

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

Red 5 支持:

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

Red5 服務(wù)器搭建

JDK自行安裝 下載Red5

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

解壓到自己的一個能記住的文件夾中 eg:F:\Red5

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

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

只需要配置HTTP 和RMTP節(jié)點的host和port即可 默認也行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=0.0.0.0
http.port=8855
https.port=5443
http.URIEncoding=UTF-8
http.max_keep_alive_requests=-1
http.max_threads=20
http.acceptor_thread_count=10
http.processor_cache=20
 
# RTMP
rtmp.host=0.0.0.0
rtmp.port=1935
rtmp.io_threads=16
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=16
rtmp.executor_keepalive_time=60000
mina.logfilter.enable=false
# scheduler configs (per application)
rtmp.scheduler.pool_size=16
rtmp.deadlockguard.sheduler.pool_size=16
# 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
 
# RTMPS
rtmps.host=0.0.0.0
rtmps.port=8443
rtmps.ping_interval=5000
rtmps.max_inactivity=60000
rtmps.max_keep_alive_requests=-1
rtmps.max_threads=20
rtmps.acceptor_thread_count=2
rtmps.processor_cache=20
# RTMPS Key and Trust store parameters
rtmps.keystorepass=password
rtmps.keystorefile=conf/keystore.jks
rtmps.truststorepass=password
rtmps.truststorefile=conf/truststore.jks
 
# RTMPT
rtmpt.host=0.0.0.0
rtmpt.port=8088
rtmpt.ping_interval=5000
rtmpt.max_inactivity=60000
rtmpt.max_handshake_time=5000
rtmpt.max_keep_alive_requests=-1
rtmpt.max_threads=20
rtmpt.acceptor_thread_count=2
rtmpt.processor_cache=20
rtmpt.encoder_base_tolerance=5000
rtmpt.encoder_drop_live_future=true
# better setting for streaming media
rtmpt.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 166
rtmpt.max_in_msg_process=166
# max time in millis that we will wait when offering data to the in or out queue
rtmpt.max_queue_offer_time=125
# max offer attempts
rtmpt.max_queue_offer_attempts=4
 
# WebSocket
ws.host=0.0.0.0
ws.port=8081
 
# Debug proxy (needs to be activated in red5-core.xml)
proxy.source_host=127.0.0.1
proxy.source_port=1936
proxy.destination_host=127.0.0.1
proxy.destination_port=1935
 
# JMX
jmx.rmi.host=localhost
jmx.rmi.port=9999
jmx.rmi.sport=9998
jmx.rmi.port.remoteobjects=
jmx.keystorepass=password
jmx.mina.monitor.enable=false
jmx.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 one
jmx.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 threads
jmx.daemon=true
# Whether the JMXConnectorServer should be started in a separate thread
jmx.threaded=true
 
# Server properties
# max events to send in a single update
so.max.events.per.update=64
so.scheduler.pool_size=4
keyframe.cache.entry.max=500
war.deploy.server.check.interval=600000
fileconsumer.delayed.write=true
fileconsumer.queue.size=120
subscriberstream.buffer.check.interval=5000
subscriberstream.underrun.trigger=100
broadcaststream.auto.record=false

啟動Red5

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

視頻直播開始準備

下載demo

上圖可以看到install紅色的那行字。點擊進去。選擇OLFA 安裝

如果下載不成功請看這里

確定webapps下面沒有oflaDemo文件夾。下載壓縮包解壓放進去即可

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

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

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

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

Server設(shè)置

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

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

推送視頻流

切換到Video點擊Publish頁面中的Publish按鈕即可對外發(fā)布直播

查看視頻流

切換到Server點擊play即可看推送的視頻流

用自己的頁面觀看直播

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

修改相關(guān)內(nèi)容 file的值是直播頁面的Name的值。streamer則為Location里面的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': '直播頁面的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ù)器實現(xiàn)流媒體視頻播放的詳細內(nèi)容,更多關(guān)于Java Red5流媒體視頻播放的資料請關(guān)注腳本之家其它相關(guān)文章!

相關(guān)文章

  • SpringBoot如何使用@Aspect注解實現(xiàn)AOP

    SpringBoot如何使用@Aspect注解實現(xiàn)AOP

    這篇文章主要介紹了SpringBoot如何使用@Aspect注解實現(xiàn)AOP問題,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2023-07-07
  • Jsoup獲取全國地區(qū)數(shù)據(jù)屬性值(省市縣鎮(zhèn)村)

    Jsoup獲取全國地區(qū)數(shù)據(jù)屬性值(省市縣鎮(zhèn)村)

    這篇文章主要介紹了Jsoup獲取全國地區(qū)數(shù)據(jù)屬性值(省市縣鎮(zhèn)村)的相關(guān)資料,需要的朋友可以參考下
    2015-10-10
  • java隨機字符串生成示例

    java隨機字符串生成示例

    這篇文章主要介紹了java隨機字符串生成示例,這個字符隨機生成類可以生成多種組合的字符串,比如大+小字符+數(shù)字+符號,需要的朋友可以參考下
    2014-03-03
  • Lombok 的@StandardException注解解析

    Lombok 的@StandardException注解解析

    @StandardException 是一個實驗性的注解,添加到 Project Lombok 的 v__1.18.22 版本中,在本教程中,我們將使用 Lombok 的 @StandardException 注解自動生成異常類型類的構(gòu)造函數(shù),需要的朋友可以參考下
    2023-05-05
  • Nacos Namespace/Group/DataID三者關(guān)系解讀

    Nacos Namespace/Group/DataID三者關(guān)系解讀

    本文介紹了Nacos中的命名空間(Namespace)、配置分組(Group)和配置集ID(DataID)的概念,并詳細說明了它們之間的關(guān)系和應(yīng)用場景,同時,還提供了三者在不同環(huán)境下的配置切換方案,包括DataID方案、Group方案和命名空間方案
    2024-12-12
  • Java日期格式化如何避免YYYY引發(fā)的時間異常

    Java日期格式化如何避免YYYY引發(fā)的時間異常

    在編程中,日期格式化是一個常見的任務(wù),使用不同的格式化選項可能會導(dǎo)致一些意外的結(jié)果,下面我們就來學(xué)習(xí)一下Java如何避免YYYY引發(fā)的時間異常吧
    2023-11-11
  • SpringBoot使用Micrometer實現(xiàn)度量和監(jiān)控

    SpringBoot使用Micrometer實現(xiàn)度量和監(jiān)控

    在構(gòu)建和維護現(xiàn)代應(yīng)用程序時,度量和監(jiān)控是至關(guān)重要的,它們可以幫助您了解應(yīng)用程序的性能、穩(wěn)定性和可用性,本文將介紹如何在Spring Boot應(yīng)用程序中使用Micrometer進行度量和監(jiān)控,需要的朋友可以參考下
    2023-10-10
  • SpringBoot使用Nacos配置中心的實現(xiàn)

    SpringBoot使用Nacos配置中心的實現(xiàn)

    這篇文章主要介紹了SpringBoot使用Nacos配置中心的實現(xiàn),文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-12-12
  • Spring?boot?整合?Redisson實現(xiàn)分布式鎖并驗證功能

    Spring?boot?整合?Redisson實現(xiàn)分布式鎖并驗證功能

    這篇文章主要介紹了Spring?boot?整合?Redisson實現(xiàn)分布式鎖并驗證,redisson是官方推薦的分布式鎖實現(xiàn)方案,采用redis自身的原子命令和lua腳本來實現(xiàn),需要的朋友可以參考下
    2022-05-05
  • springboot集成es詳解

    springboot集成es詳解

    這篇文章主要介紹了springboot集成es,本文通過實例代碼給大家介紹的非常詳細,對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2020-11-11

最新評論

鹿泉市| 南岸区| 昭苏县| 汪清县| 深泽县| 蒲江县| 龙门县| 来宾市| 丰台区| 承德县| 江川县| 大姚县| 盐池县| 江达县| 峨眉山市| 铜鼓县| 垦利县| 云龙县| 屏东县| 革吉县| 秀山| 黄梅县| 托克托县| 沭阳县| 鄄城县| 本溪| 桑植县| 密云县| 青浦区| 台州市| 柘城县| 乌兰县| 偏关县| 金华市| 建昌县| 普洱| 西吉县| 弥勒县| 留坝县| 临漳县| 湖北省|