网页播放rtsp流

220 阅读1分钟

github.com/bluenviron/…

下载地址:Releases · bluenviron/mediamtx

mediamtx支持windows和Linxu

解压后配置yml文件

在最后添加paths即可

paths:
  my_camera:
    source: rtsp://admin:xxx@192.168.0.xx:554/h264/ch1/main/av_stream

如果是Linux上的usb摄像头

paths:
  my_camera:
     runOnInit: ffmpeg -f v4l2 -i /dev/video0 -c:v libx264 -preset ultrafast -b:v 6000k -f rtsp rtsp://localhost:$RTSP_PORT/$MTX_PATH
     runOnInitRestart: yes

设置好后,使用命令行运行mediamtx服务即可

windows下双击mediamtx.exe

Linux下执行./mediamtx

网页播放

hls:(有延迟)

http://localhost:8888/my_camera/

webrtc:(低延迟,谷歌google浏览器支持直接访问)

http://localhost:8889/my_camera/