Skip to content

Instantly share code, notes, and snippets.

@dewiniaid
Created July 13, 2020 10:10
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dewiniaid/e0036009d98c6469eea13eeece822e8b to your computer and use it in GitHub Desktop.
Save dewiniaid/e0036009d98c6469eea13eeece822e8b to your computer and use it in GitHub Desktop.
Internal restreaming with MonaTiny

Internal Restreaming Guide

This is a quick guide on how to stream from one computer to another in a way that can be recaptured for use in, e.g. Twitch streams that show multiple computers.

At the end of this, you will have secondary PCs streaming to your own private stream server (instead of streaming to Twitch), and your primary PC will bring in each of these streams as media sources to be restreamed to Twitch.

Terminology

You'll need at least two PCs, ideally with wired internet on the same network.

Primary: PC in charge of actually streaming to Twitch and with a fully-fledged pretty overlay and whatnot.
Secondary: PC that will by the end of this basically be streaming to the other computer.

Downloads

  • Streamlabs OBS or your preferred choice of broadcasting software
  • MonaTiny, MonaServer or your preferred choice of RTMP server software.
  • VideoLan VLC is not required, but highly recommended for troubleshooting.

These instructions all assume you are using Streamlabs OBS, MonaTiny and VLC are available.

MonaTiny setup

MonaTiny is a small self-contained streaming server. Your secondary PCs will be streaming to your own private MonaTiny server rather than streaming to Twitch.

  1. Download and unzip MonaTiny on one of your PCs. In my setup, I use the secondary for this; it should only be needed on one system. Note there is no install or configuration process.

  2. Start MonaTiny. Windows will probably prompt you about firewall permissions, allow it. It should pop up a console window which you can mostly ignore. Keep this running for the duration of your stream.
    Note: MonaTiny has no authentication mechanism. You'll want to find another option if you don't trust your internal network/firewall setup.

Configure secondary OBS

Perform all of these steps on the secondary PC(s):

  1. Install OBS if it is not already installed.

  2. Edit your settings in OBS (gear icon in the lower left)

  • Under "Video", ensure Base (Canvas) Resolution and Output (Scaled) Resolution are set to the same value for best quality. If you know exactly how much space will be used on the final output, you change these resolutions to match -- i.e. if you're one vertical half of a 1920x1080 stream, set these to 960x1080

  • Under "Stream", change "Stream Type" to "Custom Streaming Server"

    • For URL, use rtfmp://127.0.0.1 if the secondary PC is running MonaTiny. Replace 127.0.0.1 with the correct IP address if the primary PC (or some other computer) is running MonaTiny.
    • For Stream Key, enter a key to identify your stream. Unlike Twitch, this is not like a password and does not need to be secret. Don't use your Twitch stream key. You'll want something simple to remember.
    • If you are using multiple secondary PCs, they need different keys.

    For the rest of this guide, I assume your key is key.

  • Click Done to finish editing settings.

  1. Build a scene in OBS.
  • This only needs to capture whatever window(s) and other devices (cameras?) you want to share.
  • Adding pretty background effects and other things is unneccessary and only adds to how much bandwidth you need between the primary and secondary PCs. Do all that on the primary PC instead and just use a plain black background (or another solid color)
  1. Click "Go Live"
  • If you look at the MonaTiny console window, there should be a message that says something like
    MonaTiny.cpp[157] Client publish key, where key is the stream key you chose earlier.

Testing

  1. Open VLC on whichever system MonaTiny is on.

  2. Choose Media -> Open Network String.

  3. For the network URL, use rtmp://127.0.0.1/key/key. Replace both copies of key with the stream key you chose earlier

    • Yes, the URL begins with rtmp not rtfmp here.
    • Yes, the stream key is in the URL twice.
  4. Choose Play. You should see your secondary PC's stream.

  5. If MonaTiny isn't on the primary PC, repeat this test there -- replacing 127.0.0.1 with the secondary PC's IP address.

Configuring primary OBS

  1. Add a new media source to your scene in OBS. This media source will represent the output from the secondary PC, so name it acordingly.

    • Uncheck the "Local File" box.
    • Check the "Restart playback when source becomes active" option.
    • Reduce Network Buffering to the minimum possible value to reduce stream delay.
    • For Input, use rtmp://127.0.0.1/key/key.
      • Replace 127.0.0.1 with the IP address of the system running MonaTiny (probably the secondary PC's)
      • Replace both copies of key with the stream key you chose earlier.
    • Input Format can be left empty. Adjust the remaining options to taste.
  2. Resize and crop this source into your stream layout.

  3. Additional copies of the media source can be included in your stream layout as needed if you want to crop/scale different window regions -- make sure to re-use the existing media source rather than adding multiple copies of it.

  4. Done!

Notes

OBS on the primary PC may not immediately start streaming media on the secondary PC(s), particularly after a screen transition. This usually will sort itself out in a few seconds -- but if it does not:

  1. Double click on the media source to edit it.
  2. Uncheck "Restart playback when source becomes active"
  3. Recheck "Restart playback when source becomes active"
  4. Click "Done"

That should fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment