Coder Social home page Coder Social logo

java-rtsp-jsmpeg's Introduction

JAVA-RTSP-JSMpeg

使用JSMpeg播放摄像头RTSP流
using JSMpeg to play IP Camera RTSP stream

是参考gin-rtsp项目构建的,修复了一些边缘情况的bug,目前只在windows下面测试过

使用JAVA调用ffmpeg拉取摄像头rtsp流,通过websocket转发,前端通过JSMpeg来接收websocket数据,播放视频

demo

java -jar .\mihile-cableMonitor-media-1.0-SNAPSHOT.jar
然后打开浏览器,输入localhost:3000,输入正确的rtsp地址,点击play播放,注意,rtsp地址必须正确,否则如果摄像头密码错误之类的,可能造成摄像头因为多次密码错误而被锁定设备,需要一段时间摄像头自己解锁。

画面会在60s后自动停止,要持续播放需要在60s内再次点击play

如果想要有声音,java -jar .\mihile-cableMonitor-media-1.0-SNAPSHOT.jar -audio

demo.png

环境要求

ffmpeg

在命令行输入ffmpeg -v,能够出现版本信息

API

GET /ping

Response
{
    "code": 0,
    "msg": "pong",
    "data": null
}
POST /stream/play
{
    "url":"rtsp://admin:[email protected]:554/Streaming/Channels/102"
}

Response
{
    "code": 0,
    "msg": "success",
    "data": {
        "path": "/stream/live/72b8cf14-f74b-3368-ab63-e5e1bba821b2"
    }
}

websocket播放地址就是 ws://127.0.0.1:3000/stream/live/72b8cf14-f74b-3368-ab63-e5e1bba821b2

每60s需要请求一次POST /stream/play否则会结束拉流

常见问题 FAQ

  1. 画面闪烁
    可能是输入了错误的rtsp地址播放,然后又输入了正确的地址播放,就会造成闪烁。
    解决方法:刷新页面,输入正确的rtsp地址播放
  2. 画面大小
    在top.mihile.cableMonitorMedia.service.RtspTransService这个类中修改ffmpeg参数,默认是640*480
  3. 画面卡顿、延迟
    在top.mihile.cableMonitorMedia.service.RtspTransService这个类中修改ffmpeg参数,不同的转码参数造成的画面质量等会不同。关闭音频也可以缓解卡顿和延迟。
    如果是非局域网环境下,检查服务器带宽是否满足,1Mbps带宽大约可播放480P的视频,调低摄像头画面质量试试。
  4. 没有声音 no audio
    java -jar .\mihile-cableMonitor-media-1.0-SNAPSHOT.jar -audio 加上 -audio 参数,声音会造成视频的延迟增加

java-rtsp-jsmpeg's People

Contributors

leecheck avatar ye-fan avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.