Skip to content

Monibuca Quick Start Guide

This guide will help you get started with Monibuca v5, a high-performance streaming server framework developed purely in Go.

Prerequisites

  • Go 1.23 or higher (Download Go)
  • Basic understanding of streaming protocols

Installation

Method 1: Run Pre-built Example

The easiest way to start with Monibuca is to use the default example configuration:

bash
git clone https://github.com/langhuihui/monibuca.git
# Or use Gitee
git clone https://gitee.com/m7s/monibuca.git
cd monibuca/example/default
go run -tags sqlite main.go

This will start Monibuca with the default configuration and SQLite database support.

Method 2: Include Monibuca in Your Own Project

Add Monibuca to your Go project:

bash
go get m7s.live/v5

Create a simple main.go file:

go
package main

import (
	"context"
	"flag"

	"m7s.live/v5"
	// Import the plugins you need
	_ "m7s.live/v5/plugin/flv"
	_ "m7s.live/v5/plugin/rtmp"
	_ "m7s.live/v5/plugin/hls"
	// Add more plugins as needed
)

func main() {
	conf := flag.String("c", "config.yaml", "config file")
	flag.Parse()
	m7s.Run(context.Background(), *conf)
}

Create a basic config.yaml file:

yaml
global:
  loglevel: debug

Then run your application:

bash
go run -tags sqlite main.go

Web UI

Monibuca comes with a built-in web UI for management and monitoring. To use it:

  1. Download the latest admin.zip from the releases or use the one included in the example.
  2. Place the admin.zip file (do not unzip) in the same directory as your configuration file.
  3. Visit http://localhost:8080 in your browser to access the UI.

Basic Usage

Stream Publishing

You can publish streams to Monibuca using various protocols:

RTMP

Use FFmpeg or OBS to publish an RTMP stream:

bash
# Using FFmpeg
ffmpeg -re -i your_video.mp4 -c copy -f flv rtmp://localhost:1935/live/test

# In OBS, set the server to: rtmp://localhost:1935/live
# And the stream key to: test

RTSP

For RTSP publishing:

bash
ffmpeg -re -i your_video.mp4 -c copy -f rtsp -rtsp_transport tcp rtsp://localhost:8554/live/test

Stream Playback

You can play streams using different protocols:

Configuration Options

Monibuca is highly configurable through the config.yaml file. Here are some key configuration sections:

Global Configuration

yaml
global:
  loglevel: debug  # debug, info, warn, error
  http:
    listenaddr: :8080
  admin:
    enablelogin: false  # Enable/disable admin login

Protocol Plugins

Each protocol plugin has its own configuration section:

yaml
rtmp:
  listenaddr: :1935

rtsp:
  listenaddr: :8554

flv:
  publish:
    delayclosetimeout: 3s

hls:
  fragmentduration: 5s
  segmentduration: 10s

Stream Pulling

You can configure Monibuca to automatically pull streams from other sources:

yaml
rtmp:
  pull:
    live/remote_stream: rtmp://example.com/live/source_stream

rtsp:
  pull:
    live/camera_feed: rtsp://admin:password@192.168.1.100:554/stream

Stream Recording

Configure recording settings:

yaml
mp4:
  onpub:
    record:
      ^live/.+:
        fragment: 1m
        filepath: record/$0

Running Multiple Instances

You can run multiple Monibuca instances on the same machine:

go
package main

import (
	"context"
	"flag"
	"m7s.live/v5"
	// Import your plugins
)

func main() {
	ctx := context.Background()
	conf1 := flag.String("c1", "", "config1 file")
	conf2 := flag.String("c2", "", "config2 file")
	flag.Parse()
	go m7s.Run(ctx, *conf2)  // Run second instance in a goroutine
	m7s.Run(ctx, *conf1)     // Run main instance
}

Build Tags

You can customize your Monibuca build using the following build tags:

Build TagDescription
sqliteEnables SQLite database support
mysqlEnables MySQL database support
postgresEnables PostgreSQL database support
duckdbEnables DuckDB database support
disable_rmDisables the memory pool

Example usage:

bash
go run -tags "sqlite mysql" main.go

Next Steps

  • Explore the plugin development guide to create your own plugins

For more examples, check out the example directory in the Monibuca repository.

Released under the AGPL License