流管理 API
流管理是 Monibuca 的核心 API,提供对音视频流的完整控制能力,包括流的查询、拉流创建、停止、暂停/恢复以及订阅者管理。
GET /api/streams返回当前引擎中所有活跃流的摘要信息。
响应示例:
{ "code": 0, "message": "success", "data": { "total": 3, "streams": [ { "path": "live/camera01", "state": "publishing", "publisher": { "type": "rtmp", "remote_addr": "192.168.1.100:54321", "start_time": "2026-03-18T14:00:00Z" }, "subscribers": 5, "video_codec": "H264", "audio_codec": "AAC", "video_bitrate": 2500, "audio_bitrate": 128, "duration": 1800 }, { "path": "live/camera02", "state": "publishing", "publisher": { "type": "rtsp", "remote_addr": "192.168.1.101:554", "start_time": "2026-03-18T13:30:00Z" }, "subscribers": 2, "video_codec": "H265", "audio_codec": "AAC", "video_bitrate": 4000, "audio_bitrate": 128, "duration": 3600 } ] }}GET /api/stream/{stream_path}返回指定流的详细信息,包括轨道(Track)详情和订阅者列表。
请求示例:
curl http://localhost:8080/api/stream/live/camera01响应示例:
{ "code": 0, "message": "success", "data": { "path": "live/camera01", "state": "publishing", "publisher": { "type": "rtmp", "remote_addr": "192.168.1.100:54321", "start_time": "2026-03-18T14:00:00Z" }, "tracks": { "video": { "codec": "H264", "width": 1920, "height": 1080, "fps": 30, "bitrate": 2500, "gop_size": 60, "bps": 312500 }, "audio": { "codec": "AAC", "sample_rate": 44100, "channels": 2, "bitrate": 128, "bps": 16000 } }, "subscribers": [ { "id": "sub_001", "type": "flv", "remote_addr": "192.168.1.200:12345", "start_time": "2026-03-18T14:05:00Z", "duration": 1500 }, { "id": "sub_002", "type": "hls", "remote_addr": "192.168.1.201:23456", "start_time": "2026-03-18T14:10:00Z", "duration": 1200 } ], "subscriber_count": 2, "duration": 1800, "bytes_in": 562500000, "bytes_out": 1125000000 }}POST /api/stream/pullContent-Type: application/json
{ "stream_path": "live/remote_camera", "url": "rtsp://192.168.1.50:554/stream1", "proxy": false}从远程 URL 拉取流并在本地发布。支持 RTMP、RTSP、HTTP-FLV 等协议源。
响应示例:
{ "code": 0, "message": "success", "data": { "stream_path": "live/remote_camera", "source_url": "rtsp://192.168.1.50:554/stream1", "status": "pulling" }}POST /api/stream/stopContent-Type: application/json
{ "stream_path": "live/camera01"}强制停止指定流。会断开发布者连接并通知所有订阅者。
响应示例:
{ "code": 0, "message": "success", "data": { "stream_path": "live/camera01", "status": "stopped" }}暂停/恢复流
Section titled “暂停/恢复流”POST /api/stream/pauseContent-Type: application/json
{ "stream_path": "live/camera01"}暂停流的分发,发布者继续推流但订阅者不再接收新数据。
POST /api/stream/resumeContent-Type: application/json
{ "stream_path": "live/camera01"}恢复暂停的流分发。
GET /api/stream/{stream_path}/subscribers返回指定流的所有订阅者信息。
响应示例:
{ "code": 0, "message": "success", "data": { "stream_path": "live/camera01", "total": 5, "subscribers": [ { "id": "sub_001", "type": "flv", "remote_addr": "192.168.1.200:12345", "start_time": "2026-03-18T14:05:00Z", "duration": 1500, "bytes_out": 37500000 } ] }}POST /api/stream/{stream_path}/subscriber/kickContent-Type: application/json
{ "subscriber_id": "sub_001"}强制断开指定的订阅者连接。
Track 快照
Section titled “Track 快照”GET /api/stream/{stream_path}/tracks获取流的轨道信息快照,包含实时编码参数和统计数据。
响应示例:
{ "code": 0, "message": "success", "data": { "video": { "codec": "H264", "profile": "High", "level": "4.1", "width": 1920, "height": 1080, "fps": 30.0, "bitrate_kbps": 2500, "keyframe_interval": 2.0, "total_frames": 54000, "total_keyframes": 900, "ring_buffer_size": 256, "ring_buffer_used": 128 }, "audio": { "codec": "AAC", "profile": "LC", "sample_rate": 44100, "channels": 2, "bitrate_kbps": 128, "total_frames": 84375 } }}GET /api/sysinfo返回引擎运行状态和系统资源使用情况。
响应示例:
{ "code": 0, "data": { "version": "6.0.0", "uptime": 86400, "os": "linux", "arch": "x86_64", "cpu_usage": 15.5, "memory_usage": 256000000, "total_streams": 10, "total_subscribers": 45, "total_bytes_in": 5000000000, "total_bytes_out": 25000000000 }}GET /api/plugins返回所有已加载插件的状态信息。
响应示例:
{ "code": 0, "data": { "plugins": [ { "name": "rtmp", "version": "6.0.0", "state": "running", "description": "RTMP protocol plugin" }, { "name": "flv", "version": "6.0.0", "state": "running", "description": "HTTP-FLV protocol plugin" } ] }}联系我们
微信公众号:不卡科技
腾讯频道:流媒体技术
QQ 频道:p0qq0crz08
QQ 群:751639168