快速上手
启动 Monibuca
Section titled “启动 Monibuca”使用默认配置启动
Section titled “使用默认配置启动”# 下载并运行预编译二进制(amd64 示例)wget https://download.m7s.live/bin/monibuca_v6_linux_amd64.tar.gztar -xzf monibuca_v6_linux_amd64.tar.gzchmod +x monibuca_linux_amd64./monibuca_linux_amd64指定配置文件启动
Section titled “指定配置文件启动”# 使用自定义配置文件./monibuca -c config.yamlDocker 启动
Section titled “Docker 启动”docker run -d \ --name monibuca \ -p 8180:8180 \ -p 8443:8443 \ -p 1935:1935 \ -p 8554:8554 \ -p 50051:50051 \ -p 6000:6000/udp \ -p 9000-9100:9000-9100/udp \ langhuihui/monibuca:v6创建 config.yaml 文件:
global: loglevel: info http: listenaddr: ":8180" cors: true tcp: listenaddr: ":50051" publish: ringsize: 256 subscribe: subtimeout: 10 waittimeout: 10 db: dsn: "sqlite:m7s.db?mode=rwc" admin: enablelogin: false
# RTMP - 推拉流rtmp: enable: true tcp: listenaddr: ":1935"
# RTSP - 监控设备接入rtsp: enable: true tcp: listenaddr: ":8554"
# HLS - 广泛兼容的播放方式hls: enable: true segmentduration: 6 maxsegments: 5
# WebRTC - 超低延迟webrtc: enable: true portrange: "udp:9000-9100"
# SRT - 安全可靠传输srt: enable: true listenaddr: ":6000"RTMP 推流
Section titled “RTMP 推流”使用 FFmpeg 将视频文件推送到 Monibuca:
# 推流到 live/test 路径ffmpeg -re -i input.mp4 -c copy -f flv rtmp://localhost/live/test
# 推送摄像头(macOS)ffmpeg -f avfoundation -i "0" -c:v libx264 -f flv rtmp://localhost/live/camera
# 推送桌面(Linux)ffmpeg -f x11grab -i :0.0 -c:v libx264 -f flv rtmp://localhost/live/screen使用 OBS 推流:
- 打开 OBS → 设置 → 推流
- 服务:自定义
- 服务器:
rtmp://localhost - 推流密钥:
live/test
SRT 推流
Section titled “SRT 推流”ffmpeg -re -i input.mp4 -c copy -f mpegts \ "srt://localhost:6000?streamid=publish:/live/test"WebRTC 推流(WHIP)
Section titled “WebRTC 推流(WHIP)”# 使用 WHIP 协议推流# POST http://localhost:8180/webrtc/whip?app=live&stream=test# Body: SDP Offer (application/sdp)推流成功后,可以通过多种协议播放同一路流:
HTTP-FLV
Section titled “HTTP-FLV”# 浏览器或播放器打开http://localhost:8180/flv/live/test.flv
# 使用 ffplay 播放ffplay http://localhost:8180/flv/live/test.flv# 浏览器或播放器打开http://localhost:8180/hls/live/test/index.m3u8
# 使用 ffplay 播放ffplay http://localhost:8180/hls/live/test/index.m3u8WebRTC(WHEP)
Section titled “WebRTC(WHEP)”# 使用 WHEP 协议拉流# POST http://localhost:8180/webrtc/whep?app=live&stream=test# Body: SDP Offer (application/sdp)ffplay "srt://localhost:6000?streamid=subscribe:/live/test"ffplay rtsp://localhost:8554/live/testMonibuca 内置了 Web 管理面板,提供流管理、系统监控等功能。
http://localhost:8180/adminDemo 访问地址
Section titled “Demo 访问地址”http://localhost:8180/demo/live-roomhttp://localhost:8180/demo/meeting-roomhttp://localhost:8180/demo/customer-service- 流列表:查看当前所有活跃的流,包括发布者和订阅者信息
- 系统信息:CPU、内存、网络等系统资源监控
- 插件状态:查看已加载的插件及其配置
- 配置管理:在线修改配置(通过 API)
默认情况下管理面板无需登录。如需启用认证:
global: admin: enablelogin: true username: admin password: your_secure_password环境变量配置
Section titled “环境变量配置”Monibuca 支持通过环境变量覆盖配置文件中的值,格式为:
M7S_{PLUGIN}_{FIELD}所有字母大写,嵌套字段用下划线分隔。
# 修改 RTMP 监听端口export M7S_RTMP_TCP_LISTENADDR=":1936"
# 修改全局日志级别export M7S_GLOBAL_LOGLEVEL="debug"
# 修改发布超时export M7S_GLOBAL_PUBLISH_PUBTIMEOUT="30"
# 修改 WebRTC ICE 服务器export M7S_WEBRTC_ICESERVERS="stun:stun.l.google.com:19302"在 Docker 中使用
Section titled “在 Docker 中使用”docker run -d \ --name monibuca \ -e M7S_GLOBAL_LOGLEVEL=info \ -e M7S_RTMP_TCP_LISTENADDR=":1935" \ -e M7S_GLOBAL_HTTP_LISTENADDR=":8180" \ -p 8180:8180 \ -p 1935:1935 \ langhuihui/monibuca:v6常用 API
Section titled “常用 API”启动后可以通过 HTTP API 查询服务状态:
# 获取系统摘要curl http://localhost:8180/api/summary
# 获取流列表curl http://localhost:8180/api/stream/list
# 获取插件列表curl http://localhost:8180/api/plugins联系我们
微信公众号:不卡科技
腾讯频道:流媒体技术
QQ 频道:p0qq0crz08
QQ 群:751639168