当前位置: 首页 > news >正文

浏览器WEB播放RTSP

注意:浏览器不能直接播放RTSP,必须转换后才能播放。这一点所有的播放都是如此。

  • 参考

https://github.com/kyriesent/node-rtsp-stream

GitHub - phoboslab/jsmpeg: MPEG1 Video Decoder in JavaScript

  • 相关文件方便下载

https://download.csdn.net/download/quantum7/90459890

  • 安装node/npm
  • 安装ffmpeg
sudo apt install -y ffmpeg
  • 服务器:安装node-rtsp-stream
npm install node-rtsp-stream
  • 服务器:准备RTSP流

 如果没有RTSP流或访问不到,可以自己模拟一个。具体参考:

Ubuntu搭建RTSP服务器_ubuntu安装rtsp服务器-CSDN博客

  • 服务器:启动

文件app.js

Stream = require('node-rtsp-stream')
stream = new Stream({name: 'name',streamUrl: 'rtsp://10.0.2.15:8554/test.264',wsPort: 9999,ffmpegOptions: { // options ffmpeg flags'-stats': '', // an option with no neccessary value uses a blank string'-r': 30 // options with required values specify the value after the key}
})

启动

node app.js
  • 新建index.html
<!DOCTYPE html>
<html>
<head><title>JSMpeg Stream Client</title><style type="text/css">html, body {background-color: #111;text-align: center;}</style></head>
<body><canvas id="video-canvas"></canvas><script type="text/javascript" src="jsmpeg.min.js"></script><script type="text/javascript">var canvas = document.getElementById('video-canvas');var url = 'ws://localhost:9999/';var player = new JSMpeg.Player(url, {canvas: canvas});</script>
</body>
</html>
  • 直接打开index.html,就能播放。

========================================================================

下面是前端方案。

  • 前端:搭建服务器

Ubuntu搭建最简单WEB服务器-CSDN博客

  • 复制jsmpeg.min.js/index.html

默认工作目录是/var/www/html

  • 测试

如果发现不能播放:

检查流是否正常,能否访问(比如在虚拟机中可能就无法访问外部流)。

流是否已结束(此时可以重启服务器,赶紧刷新)。

  • 其他方案

node-rtsp-stream

node-media-server

rtsp-streaming-server

fluent-ffmpeg


http://www.mrgr.cn/news/93388.html

相关文章:

  • 深度学习PyTorch之13种模型精度评估公式及调用方法
  • 为AI聊天工具添加一个知识系统 之138 设计重审 之2 文章学 引言之2 附加符号学和附属诠释学
  • 前端基础入门-高级
  • WLAN无线组网 WI-FI
  • 如何改变怂怂懦弱的气质(2)
  • 从零构建企业级财务分析数仓 | Hive建模实战
  • Spring(四)先注册后注入
  • 为AI聊天工具添加一个知识系统 之138 设计重审 2 文章学 之2 结合诠释学的重组
  • Gazebo11 与 Protobuf 版本管理
  • Python:简单的爬虫程序,从web页面爬取图片与标题并保存MySQL
  • K8s 1.27.1 实战系列(五)Namespace
  • aws(学习笔记第三十一课) aws cdk深入学习(batch-arm64-instance-type)
  • MacOS Big Sur 11 新机安装brew wget python3.12 exo
  • ubuntu20.04已安装 11.6版本 cuda,现需要通过源码编译方式安装使用 cuda 加速的 ffmpeg 步骤
  • AI绘画软件Stable Diffusion详解教程(7):图生图基础篇
  • 【JAVA架构师成长之路】【JVM实战】第2集:生产环境内存飙高排查实战
  • DeepSeek + 飞书多维表格搭建你的高效工作流
  • tcc编译器教程2 编译lua解释器
  • 运算放大器LM358的简单应用
  • thunder bird 配置邮箱