All Projects → wanghaoxi3000 → Gin Rtsp

wanghaoxi3000 / Gin Rtsp

Licence: mit
基于Gin + WebSocket + JSMpeg,在HTML页面上直接播放RTSP视频流。

Programming Languages

go
31211 projects - #10 most used programming language
golang
3204 projects

Projects that are alternatives of or similar to Gin Rtsp

Go init
一个用go组织项目结构,主要包括 gin, goredis, gorm, websocket, rabbitmq等。👉
Stars: ✭ 183 (+34.56%)
Mutual labels:  gin, websocket
Gowebsocket
golang基于websocket单台机器支持百万连接分布式聊天(IM)系统
Stars: ✭ 937 (+588.97%)
Mutual labels:  gin, websocket
Zlmediakit
WebRTC/RTSP/RTMP/HTTP/HLS/HTTP-FLV/WebSocket-FLV/HTTP-TS/HTTP-fMP4/WebSocket-TS/WebSocket-fMP4/GB28181 server and client framework based on C++11
Stars: ✭ 5,248 (+3758.82%)
Mutual labels:  rtsp, websocket
Gin Web
由gin + gorm + jwt + casbin组合实现的RBAC权限管理脚手架Golang版, 搭建完成即可快速、高效投入业务开发
Stars: ✭ 107 (-21.32%)
Mutual labels:  gin, websocket
Monibuca
🧩 Monibuca is a Modularized, Extensible framework for building Streaming Server
Stars: ✭ 307 (+125.74%)
Mutual labels:  rtsp, websocket
Chat Room
使用GO+Vue构建的聊天室网站
Stars: ✭ 113 (-16.91%)
Mutual labels:  gin, websocket
Go Http Metrics
Go modular http middleware to measure HTTP requests independent of metrics backend (with Prometheus and OpenCensus as backend implementations) and http framework/library
Stars: ✭ 128 (-5.88%)
Mutual labels:  gin
Jstp
Fast RPC for browser and Node.js based on TCP, WebSocket, and MDSF
Stars: ✭ 132 (-2.94%)
Mutual labels:  websocket
Client Python
A python client library for accessing Polygon's APIs
Stars: ✭ 127 (-6.62%)
Mutual labels:  websocket
Tardis Node
Convenient access to tick-level real-time and historical cryptocurrency market data via Node.js
Stars: ✭ 126 (-7.35%)
Mutual labels:  websocket
Gin Jwt
JWT Middleware for Gin framework
Stars: ✭ 1,957 (+1338.97%)
Mutual labels:  gin
Marewood
🐚 marewood is an open source automatic packaging deployment tool for front-end || MareWood 是一个Go开发的轻量级前端部署工具,可以很灵活的配置各种打包部署环境并提供访问。
Stars: ✭ 135 (-0.74%)
Mutual labels:  websocket
Wxapp
🙋travelib-node 流动图书Node.js后端
Stars: ✭ 132 (-2.94%)
Mutual labels:  websocket
Light Push
轻量级推送服务和实时在线监控平台,同时用于开发即时通信系统,基于node的socket.io,支持web、android、ios客户端,支持移动端离线推送,可进行分布式部署
Stars: ✭ 128 (-5.88%)
Mutual labels:  websocket
Httpexpect
End-to-end HTTP and REST API testing for Go.
Stars: ✭ 1,821 (+1238.97%)
Mutual labels:  websocket
Toho Like Js
Touhou style danmaku shooter game which runs on your chrome.
Stars: ✭ 127 (-6.62%)
Mutual labels:  websocket
Exchanges Php
This is a virtual currency SDK that brings together multiple exchanges
Stars: ✭ 134 (-1.47%)
Mutual labels:  websocket
Pubg
Playerunknown’s Battlegrounds Websocket API example. Feel free to ask questions in Discord: Hormold#0683
Stars: ✭ 126 (-7.35%)
Mutual labels:  websocket
Zerodha live automate trading using ai ml on indian stock market Using Basic Python
Online trading using Artificial Intelligence Machine leaning with basic python on Indian Stock Market, trading using live bots indicator screener and back tester using rest API and websocket 😊
Stars: ✭ 131 (-3.68%)
Mutual labels:  websocket
Kuma
A network library implemented in C++, supports TCP/UDP/HTTP/HTTP2/WebSocket/SSL on platform Linux/Windows/OSX/iOS/Android.
Stars: ✭ 133 (-2.21%)
Mutual labels:  websocket

gin-rtsp

基于 JSMpeg 的原理,在HTML页面上直接播放RTSP视频流,使用Gin框架开发。

主要模块

  • API 接口:接收FFMPEG的推流数据和客户端的HTTP请求,将客户端需要播放的RTSP地址转换为一个对应的WebSocket地址,客户端通过这个WebSocket地址便可以直接播放视频,为了及时释放不再观看的视频流,这里设计为客户端播放时需要在每隔60秒的时间里循环请求这个接口,超过指定时间没有收到请求的话后台便会关闭这个视频流。

  • FFMPEG 视频转换:收到前端的请求后,启动一个Goroutine调用系统的FFMPEG命令转换指定的RTSP视频流并推送到后台对应的接口,自动结束已超时转换任务。

  • WebSocket Manager:管理WebSocket客户端,将请求同一WebSocket地址的客户端添加到一个Group中,向各个Group广播对应的RTSP视频流,删除Group中已断开连接的客户端,释放空闲的Group。

注意

  • 需要摄像头的码流为H264码流

测试

项目需要运行在安装有FFMPEG程序的环境中。通过编写了一份Dockerfile已经封装好了需要的环境,可以使用Docker build后,以Docker的方式运行。

$ docker build -t ginrtsp .
$ docker run -td -p 3000:3000 ginrtsp

使用内置的FFMPEG转换

将需要播放的RTSP流地址提交到 /stream/play 接口,例如:

POST /stream/play
{
   "url": "rtsp://admin:[email protected]:554/cam/realmonitor?channel=1&subtype=0"
}

后台可以正常转换此RTSP地址时便会返回一个对应的地址,例如:

{
    "code": 0,
    "data": {
        "path": "/stream/live/5b96bff4-bdb2-3edb-9d6e-f96eda03da56"
    },
    "msg": "success"
}

编辑html文件夹下view-stream.html文件,将script部分的url修改为此地址,在浏览器中打开,便可以看到视频了。

手动运行FFMPEG

由于后台转换RTSP的进程在超过60秒没有请求后便会停止,也可以通过手动运行ffmpeg命令,来更方便地在测试状态下查看视频。

ffmpeg -rtsp_transport tcp -re -i 'rtsp://admin:[email protected]:554/cam/realmonitor?channel=1&subtype=0' -q 0 -f mpegts -c:v mpeg1video -an -s 960x540 http://127.0.0.1:3000/stream/upload/test

通过如上命令,运行之后在view-stream.html文件的url中填入对应的地址为/stream/live/test,在浏览器中打开查看视频。

显示效果

参考

JSMpeg – MPEG1 Video & MP2 Audio Decoder in JavaScript

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].