瀏覽器播放rtsp視頻,基于nodeJs
1:安裝ffmpeg,并且配置環(huán)境變量。
下載地址:http://ffmpeg.zeranoe.com/builds/ 或者:
百度云鏈接:https://pan.baidu.com/s/1PBt18BHFGpdr0lpoUp5cKw
提取碼:hx08
配置:
復制文件地址,返回桌面,右鍵我的電腦/此電腦,點擊高級系統(tǒng)設(shè)置,高級,點擊環(huán)境變量
點擊path
設(shè)置路徑
win + r 輸入cmd
輸入ffmpeg 回車
成功
2:npm install?node-rtsp-stream ws
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
|
node xx.js 啟動服務
3: html頁面播放視頻
jsmpeg/jsmpeg.min.js at master · phoboslab/jsmpeg · GitHub
文章來源:http://www.zghlxwxcb.cn/news/detail-412629.html
<!DOCTYPE html> <html> <head> <title>JSMpeg Stream Client</title> <style type="text/css"> *{ padding: 0; margin: 0; } .container{ margin: 0 auto; } canvas{ background-color: aqua; display: block; margin: 10px 0; } </style> </head> <body> <div class="container"> <canvas id="video-canvas" width="1366" height="750" style="width:980px;height:544px"></canvas> </div> <script type="text/javascript" src="./scripts/jsmpeg.js"></script> <script type="text/javascript"> const width = document.body.clientWidth; const height = document.body.clientHeight; console.log(width,height) const canvas = document.getElementById('video-canvas'); console.log(document.location.hostname) var urls = 'ws://localhost:9998'; var players = new JSMpeg.Player(urls, {canvas: canvas}); </script> </body> </html>
文章來源地址http://www.zghlxwxcb.cn/news/detail-412629.html
到了這里,關(guān)于瀏覽器播放rtsp視頻,基于nodeJs的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!