快速上手
启动 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:v6Docker 快速路径(pull → play)
Section titled “Docker 快速路径(pull → play)”需要 Monibuca + coturn 一键试播(含 WebRTC 双栈 ICE 与 TURN)时,用仓库参考 Compose:
git clone https://github.com/Monibuca/Enterprise.gitcd Enterprise/deploy/composedocker pull langhuihui/monibuca:v6cp .env.example .env # 编辑 PUBLIC_IPdocker compose up -d推流:ffmpeg -re -i input.mp4 -c copy -f flv rtmp://localhost/live/test
播放:浏览器打开 http://localhost:8180/flv/live/test.flv 或 http://localhost:8180/demo/live-room
完整步骤(镜像标签、WHIP/WHEP、防火墙):deploy/compose/README.md。
创建 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"端口与防火墙
Section titled “端口与防火墙”公网 / NAT 部署前请放行所需入站端口。完整矩阵见 端口与防火墙(HTTP 8180、RTMP 1935、RTSP 8554、SRT 6000/udp、WebRTC ICE port_range、集群 QUIC 8002/udp、coturn 3478 等)。
启用 WebRTC 双栈 ICE 时需同时开放 UDP 与 TCP 端口段,并配置 public_ip / TURN,详见 WebRTC。
需要本机一键验证 origin + coturn 时,可直接使用仓库参考 Compose:deploy/compose/(复制 .env.example → .env,填写 PUBLIC_IP 后 docker compose up -d)。
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)
管理 API(/api/*、/v6/api/*、配置读写等)在配置了 JWT secret 后需要 admin 角色登录。管理后台会自动跳转 /login 并携带 Bearer token。
推荐配置(YAML):
global: auth: secret: "your-jwt-secret-key" users: - username: admin password: your_secure_password role: admin环境变量:
export M7S_AUTH_SECRET="your-jwt-secret-key"本地开发(跳过鉴权,勿用于生产):
export M7S_ADMIN_DEV_MODE=1登录接口:POST /api/auth/login → 返回 access_token / refresh_token;Admin SPA 会自动刷新 token 并在 401 时重定向登录页。
环境变量配置
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/v6/api/streams?page=1&per_page=20'
# 获取插件列表curl http://localhost:8180/api/plugins- 配置说明 — 深入了解配置系统
- 端口与防火墙 — 常用端口与放行说明
- deploy/compose — Docker Compose:Monibuca + coturn
- 系统架构 — 理解 Monibuca 的内部设计
- 协议总览 — 各协议的详细使用方法
联系我们