howl.moe

Multi-streaming on three different platforms

Published (click to see context) on 25/04/2020 by Morgan Bazalgette • 2 minutes

Today I needed to do this and I made a nice set up using docker-compose and restreamer. Nobody’s probably ever going to need this, but I’ll leave this here.

version: '3'

services:
    youtube:
        image: datarhei/restreamer:latest
        ports:
            - '1935:1935'
            - '10000:8080'
        environment:
            - 'RS_USERNAME=user'
            - 'RS_PASSWORD=pass
            - 'RS_TOKEN=streamtoken'
            - 'RS_INPUTSTREAM=rtmp://localhost/live/external.stream?token=streamtoken
        volumes:
            - './db/youtube:/restreamer/db'
        networks:
            re:
                aliases:
                    - youtube
    basi1:
        image: datarhei/restreamer:latest
        ports:
            - '12000:8080'
        environment:
            - 'RS_USERNAME=user'
            - 'RS_PASSWORD=pass
            - 'RS_INPUTSTREAM=rtmp://youtube/live/external.stream?token=streamtoken'
        volumes:
            - './db/basi1:/restreamer/db'
        networks:
            - re
    basi2:
        image: datarhei/restreamer:latest
        ports:
            - '12001:8080'
        environment:
            - 'RS_USERNAME=user'
            - 'RS_PASSWORD=pass
            - 'RS_INPUTSTREAM=rtmp://youtube/live/external.stream?token=streamtoken'
        volumes:
            - './db/basi2:/restreamer/db'
        networks:
            - re
    lazio1:
        image: datarhei/restreamer:latest
        ports:
            - '12010:8080'
        environment:
            - 'RS_USERNAME=user'
            - 'RS_PASSWORD=pass'
            - 'RS_INPUTSTREAM=rtmp://youtube/live/external.stream?token=streamtoken'
        volumes:
            - './db/lazio1:/restreamer/db'
        networks:
            - re
    lazio2:
        image: datarhei/restreamer:latest
        ports:
            - '12011:8080'
        environment:
            - 'RS_USERNAME=user'
            - 'RS_PASSWORD=pass'
            - 'RS_INPUTSTREAM=rtmp://youtube/live/external.stream?token=streamtoken'
        volumes:
            - './db/lazio2:/restreamer/db'
        networks:
            - re

networks:
    re:

This sets up multiple instances of Restreamer, which is a nice program that you can run on your server and allows you to set up a RTMP server and forward its data to another service. What’s curious about it is that setting up multiple instances you can stream from your computer to a single instance - in my case, the one under the “youtube” service, which exposes the 1935 RTMP port - which then can be fed into all of the instances - and thus can feed the data to the external streaming service of preference.

Another edit I added in last-minute was adding a custom configuration file, by setting the conf directory as a volume for basi2 and lazio2. This allowed me to set -vf transpose=1, which rotated the video sideways and allowed for streaming vertically (ie. instagram). Restreamer then handled everything on the server with my computer only needing to do one stream, and everything went quite smooth. A simple Scaleway dev server for 6 hours proved to be enough.

#blogpost #development