網(wǎng)站首頁(yè) 編程語(yǔ)言 正文
所需環(huán)境
node.js + FFmpeg
此方式客戶端只需要通過(guò)video標(biāo)簽就可播放
ffmpeg下載鏈接:https://pan.baidu.com/s/1ntOVSpxmtHO861V-dT5Kyg?pwd=nx7y?
提取碼:nx7y?
FFmpeg環(huán)境安裝
1. 安裝FFmpeg的依賴yasm
?yum方式安裝yasm,也可以通過(guò)Download - The Yasm Modular Assembler Project下載安裝
yum install yasm -y
# 編譯
./configure
# 安裝
make && make install
2. 安裝FFmpeg
?wget獲取ffmpeg,有可能下載不下來(lái),建議用我提供的ffmpeg-4.1.8.tar.bz2手動(dòng)上傳到服務(wù)器
wget https://ffmpeg.org/releases/ffmpeg-4.1.8.tar.bz2
# 解壓
tar -xjvf ffmpeg-4.1.8.tar.bz2
# 進(jìn)入解壓目錄
cd ffmpeg-4.1.8
# 編譯
./configure
# 安裝
make && make install
3. 驗(yàn)證是否安裝成功
輸入ffmpeg命令,查看控制臺(tái)是否有輸出,有則代表安裝ffmpeg成功。
NodeJS環(huán)境安裝
1. NodeJS的安裝步驟忽略。。
2. 安裝rtsp2web插件
# 創(chuàng)建一個(gè)目錄,目錄名稱不能是rtsp2web,進(jìn)入目錄執(zhí)行以下命令安裝rtsp2web插件
npm init --yes
npm i rtsp2web
3. 創(chuàng)建?index.js,并運(yùn)行,運(yùn)行命令node index.js
// index.js
const RTSP2web = require('rtsp2web')
// 服務(wù)端長(zhǎng)連接占據(jù)的端口號(hào);端口號(hào)可以自定義
const port = 9999
new RTSP2web({
port
})
至此視頻轉(zhuǎn)碼服務(wù)安裝完成。
在此提供公開(kāi)的rtsp流可用于測(cè)試:
rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mp4
驗(yàn)證html播放實(shí)時(shí)視頻
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no,viewport-fit=cover">
<script src="https://jsmpeg.com/jsmpeg.min.js" charset="utf-8"></script>
<title>播放rtsp</title>
</head>
<body>
<canvas id="canvas" style="width: 600px; height: 600px;"></canvas>
</body>
<script>
// 改成你的rtsp流
var rtsp = 'rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mp4'
window.onload = () => {
// location為node服務(wù)所在的服務(wù)地址,端口為rtsp2web設(shè)置的端口
new JSMpeg.Player("ws://localhost:9999/rtsp?url="+btoa(rtsp), {
canvas: document.getElementById("canvas")
})
}
</script>
</html>
將該html copy到桌面打開(kāi)看看效果。
原文鏈接:https://blog.csdn.net/qq_36881887/article/details/125423111
- 上一篇:跨域的五種解決方案
- 下一篇:jenkins數(shù)據(jù)遷移和備份
相關(guān)推薦
- 2022-08-13 二分查找思路及模板
- 2022-08-07 pandas中pd.groupby()的用法詳解_python
- 2022-11-29 C#泛型的使用案例_C#教程
- 2022-09-01 ASP.NET輕量級(jí)MVC框架Nancy的基本用法_實(shí)用技巧
- 2022-10-18 Qt實(shí)現(xiàn)TCP客戶端和服務(wù)器通訊程序_C 語(yǔ)言
- 2022-10-07 關(guān)于pyqt5彈出提示框的詳細(xì)介紹_python
- 2022-08-04 python多核處理器算力浪費(fèi)問(wèn)題解決_python
- 2022-03-29 關(guān)于C#?調(diào)用Dll?傳遞字符串指針參數(shù)的問(wèn)題_C#教程
- 最近更新
-
- window11 系統(tǒng)安裝 yarn
- 超詳細(xì)win安裝深度學(xué)習(xí)環(huán)境2025年最新版(
- Linux 中運(yùn)行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲(chǔ)小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎(chǔ)操作-- 運(yùn)算符,流程控制 Flo
- 1. Int 和Integer 的區(qū)別,Jav
- spring @retryable不生效的一種
- Spring Security之認(rèn)證信息的處理
- Spring Security之認(rèn)證過(guò)濾器
- Spring Security概述快速入門(mén)
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權(quán)
- redisson分布式鎖中waittime的設(shè)
- maven:解決release錯(cuò)誤:Artif
- restTemplate使用總結(jié)
- Spring Security之安全異常處理
- MybatisPlus優(yōu)雅實(shí)現(xiàn)加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務(wù)發(fā)現(xiàn)-Nac
- Spring Security之基于HttpR
- Redis 底層數(shù)據(jù)結(jié)構(gòu)-簡(jiǎn)單動(dòng)態(tài)字符串(SD
- arthas操作spring被代理目標(biāo)對(duì)象命令
- Spring中的單例模式應(yīng)用詳解
- 聊聊消息隊(duì)列,發(fā)送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠(yuǎn)程分支