a-rose / obs-headless

Headless OBS in Docker via gRPC
110 stars 15 forks source link
docker grpc obs obs-studio rtmp streaming video

obs-headless

C++ program based on libobs (from obs-studio), designed to read RTMP streams and compose them as sources in different scenes.

The main part consists of a gRPC server. An example client is also provided.

This project uses Docker to ease build and deployment. If you follow the prerequisites below, accessing the GPU with Docker should work out of the box.

Prerequisites

CUDA versions

Check which CUDA version is installed on your host using nvidia-smi. If needed, edit Dockerfile to use the same version as a base image: FROM nvidia/cudagl:<YOUR CUDA VERSION HERE>-devel-ubuntu22.04

Existing tags: https://hub.docker.com/r/nvidia/cudagl/tags

Building and running

Build and run the server:

make build
make run

Start the client in an other terminal:

make client

From the client, you can switch the source using by pressing s and Enter.

X Server Access Control

In order to allow the container to use the host's X Server, the Makefile runs the xhost + command everytime you use the run or targets.

You can undo this by executing xhost - on your host machine.

OBS version

You can specify which OBS version to build and run with, for example:

make obs_version=28.0.3 build
make obs_version=28.0.3 run

Configuration

Input: edit etc/shows/default.json to set the default scene when starting obs-headless. It contains two RTMP sources as inputs, for which you must set the URL of public or local RTMP streams (see STREAMING.md).

Output: edit config.txt to set server and key with your output stream URL and key. You can stream to any platform supporting RTMP (Twitch, Youtube, ...). You can also use any local RTMP server (see STREAMING.md).

Development

The build system uses three images:

Using the dev image: you can start a container with obs-headless sources attached as volumes, so you can edit sources and rebuild in the container.

  1. Start the container: make shell-dev.
  2. Build obs-headless (see Dockerfiles for build instructions)
  3. You can now edit the sources and rebuild from the container. Rebuild with rb and start with st (see etc/bashrc for aliases).

Using the base image, you can also build obs-studio from sources.

  1. Clone obs-studio on your host (see obs-headless-builder.Dockerfile for the repo URL)
  2. Set obs_sources in Makefile to the path where you just cloned obs-studio
  3. Start the container: make shell-base.
  4. Build obs-studio and obs-headless (see Dockerfiles for build instructions)
  5. You can now edit the sources and rebuild from the container. Rebuild with rb and start with st (see etc/bashrc for aliases).

TODO