Game broadcasting within a LAN

In this article we will look at how you can set up broadcasting within a LAN environment using OBS Studio and NGINX.

This can be very useful in some development scenarios. For example, you may wish to demonstrate your game at an exhibition, and want to show your broadcast stream on a big TV. Connecting your big TV to stream from your Twitch feed would work, but has significant disadvantages:

  1. Your Twitch feed will typically be up to 1 minute behind the gameplay, which could make for a jarring experience if people are watching your players live on the show floor and seeing a very laggy feed on the big screen.
  2. Your Twitch feed would use internet bandwidth, both upstream and downstream. Anyone with experience here will tell you that bandwidth is typically a precious and unreliable commodity at exhibitions. The number of other exhibitors, time pressures on the few IT staff that are trying to keep the whole show floor running, wifi passwords being leaked and resulting in hundreds of mobile phones flooding the routers and stealing all the available IP addresses. It’s a war out there, in an environment where you cannot afford to have network issues. Anything you can do to AVOID a reliance on internet bandwidth, you should.
  3. If you use something like Twitch, it will insert adverts. The last thing your publisher wants to see is your COMPETITOR’S advert popping up on your big screen at a show.

There are other use cases where you may wish to broadcast a stream on a LAN, without a reliance on a 3rd party internet-based streaming service:

  • LAN parties.
  • In your dev studio to help capture and debug issues.
  • Game pitches to publishers.
  • You aren’t ready to show the game to the public yet, but still want to test your broadcast features.

Prerequisites

In this article, we will use OBS Studio to composite your video feed, but instead of streaming it to Twitch, we are going to use NGINX to stream it live to another PC on the LAN. Once this is configured, you will be able to view your live stream using VLC or any other media streaming client, all within the confines of your LAN.

I will assume that you are already familiar with OBS Studio to configure video feeds. There are plenty of tutorials on that already so there Is little point me repeating it here. The NerdOrDie series of tutorials is excellent for learning OBS Studio:

If you are using Amazon Lumberyard, you may also have hooked up some Metastream widgets and have them overlaid on your feed. For more information, check out the Lumberyard Metastream Gem here:

Metastream Gem – Lumberyard

Use the Twitch Metastream feature to customize game streams with overlays of statistics and events.

There’s not much in the way of tutorials for the Metastream system it seems (we should write one!), but in a nutshell it allows you to make HTML widgets to use as overlays in OBS Studio (or your streaming package of choice), which can live-link to your game and pull out whatever stats you would like to expose, and present them in a pretty form to your viewers.

Here’s an example of Metastream at work in our game, The DRG Initiative:

Beat the Devs Rematch: DRG Initiative at EGX Rezzed

DRGinitiative – Beat the Devs Rematch: DRG Initiative at EGX Rezzed – Twitch

In this video, around 1m11s in, you can see the match statistics overlaid on to the video stream. The stats shown are being polled directly from the game client. This is very elegant because the data and the visual look of the widget are entirely separated, allowing users to write their own widgets or customise the ones we provide to their heart’s contents.

Once you’ve got your broadcast set up the way you like in OBS Studio, you might typically configure it to output the final feed to your Twitch channel so that your viewers can watch. Instead, we’re going to set it up using a streaming server that we will host ourselves, using NGINX.

Hardware Setup

To set this up is reasonably involved. You will need 3 PCs all running on the same LAN and able to communicate with one another. The first PC is what we will call the Game PC. This is the PC that will run the game that you want to broadcast, think of it as your player’s PC. The second PC will be your Broadcast PC. This is the PC that will run OBS Studio and generate your composited video feed. The third PC will be your Video Streaming PC. This is the PC that will serve your live stream (essentially your local version of Twitch). You will also need a HDMI capture device.

Typically you could get away with combining some or all of these PCs, but I’ve kept it as using 3 separate PCs for the best experience. Trying to put them all together may lead you to performance and logistics issues, but feel free to adapt this to your needs. When writing this article, I tested combining all of them on to a single PC without any obvious issues.

Set up the hardware with the following configuration:

 

Game PC

Configure your game on the Game PC, and plug your HDMI output in to the capture card that is plugged in to your Broadcast PC. It is best if you have a graphics card with 2 HDMI outputs for this, so that you can have one of them plugged in to a monitor and the other plugged in to the capture card. If this is the case, ensure you have screen mirroring configured in the Windows display settings, so that the same image goes out of both HDMI ports.

Broadcast PC

Install OBS Studio on your Broadcast PC and configure a video capture device input source to capture the video from your Game PC via the capture card. Add in your Metastream overlays as Browser sources, and your webcam feed etc. as you see fit. The real broadcasting potential comes when you set up multiple scenes to switch between as the action unfolds. For example you may have a scene that shows your game with an unobtrusive overlay showing just the match timer, and another scene that is a full screen stats widget with the game feed set in a small picture-in-picture window in the corner. It is up to you, experiment!

Video Streaming PC

Now on to the Video Streaming PC. This PCs job is to capture the output from OBS Studio, encode it in realtime, and offer it up on the LAN as a live video feed, which can be connected to and viewed from other PCs using a video streaming client such as VLC.

You need to install NGINX on the Video Streaming PC. Download it from here, and unzip it to a folder of your choice. Now just run NGINX.exe from that folder and you are done.

The next step is to configure your Broadcast PC to output to the NGINX service now running on the Video Streaming PC. On the Broadcast PC, go in to the OBS Studio settings and head to the Stream tab. Select ‘Custom Streaming Server’ from the dropdown. In the URL box, enter:

rtmp://<ip address of Video Streaming PC>/live

E.g.

rtmp://10.180.10.12/live

In the Streaming key box, type any number, e.g. 1234.

Click ‘Save’, and you should be all set up.

Starting a Stream

Now you are all set up, you should be able to just click ‘Start Streaming’ in OBS Studio on the Broadcast PC. If all has gone well, you will see in the OBS Studio status bar some text indicating that it successfully connected to your Video Streaming PC and is now pushing out the live video feed.

Viewing a Stream

You should be able to use any PC on the LAN to view your video feed. You can use any app capable of connecting to an RTMP stream, such as VLC. Install VLC and go to ‘File -> Open Network Stream’. In the URL box, enter:

rtmp://<ip address of Video Streaming PC>/live/<streaming key>

E.g.

rtmp://10.180.10.12/live/1234

You should see your live stream pop up in VLC, with zero internet bandwidth usage. Great!

I have found that there is still lag in this setup, around 10 seconds in my tests, but I haven’t put any time in to trying to reduce that lag. Please share in the comments if you can help here.

Summary

We’ve shown how you can create your own local video streaming service for your game. This should allow you to show off your game at exhibitions and demos with confidence that you are not reliant on the whims of the internet on your big day. Please use the comments below to share your experience if you’ve decided to use this technique, and also if you find any improvement to things such as reducing the lag, please do share!

Until next time!

Leave a Reply