[Guide] Twitch streaming on Linux

Introduction:

I have been using linux (mostly ubuntu based distros) as my main operating system for a few years. Recently I became interested in starting live streaming on twitch, so I had to look up how to configure everything in order to get live streaming working without any drawbacks.

This is a guide explaining what I had to go through and help others getting everything ready.

Please note that half of this guide is just to set up Twitch soundtrack which is only native on windows at the moment. Once they have a native linux version this guide will be way shorter.

Streaming software:

TL;DR: snap install obs-studio

Like everyone I use OBS to record and stream. However there are multiple options when installing OBS and each one has their own benefits or drawbacks.

Since I currently use Kubuntu 21.04 there are two installation options: debian package or snap package.

The debian package has better access to your storage and makes managing the recorded videos a little bit easier. The problem is that the default package is a bit outdated or you have to add the OBS ppa which will get tricky when you upgrade your system to the next major version.

The snap package is the installation method I would recommend. It is always up to date and has very little restrictions. In addition to that this works on basically every distro and the snap version has more features that the debian package (I don’t know why but whatever).

You can install the snap package using the command: snap install obs-studio

Installing Twitch soundtrack

TL;DR: just install it in a new 64 wine prefix, with wine set to windows 10 and install calibri and arial using winetricks

Twitch soundtrack is a tool to enable every streamer to have background music in their streams without needing to worry about copyright claims. The music should only be on stream and not in the VOD so there is an OBS plugin to make that easy.

The problem is that this is windows only at the moment. So how do we get it working on linux?

As always if you want to get windows applications running under linux the answer is wine. I use lutris to manage all of the applications I installed using wine since each one might need a different environment. The wine version I used for this is 6.11-staging others might work too but I did not test them. Look at these installation instructions by the wine development team to get wine staging on your distro.

First you have to download the installer from the official website. Just keep it in the downloads folder you will need it later.

Next up is setting up the new ‘game’ in lutris:

  • Click on the + in the top left corner to add a new game.
  • Enter a name for this new ‘game’ so that you can easily find it
  • Select wine as the runner
  • click on the ‘game options’ tab
  • select 64-bit as ‘prefix architecture’
  • select a new empty folder as the wine prefix
  • click on the ‘runner options’ tab
  • click on ‘wine version’ menu and select ‘System (6.11 (Staging))’
  • click on save in the bottom right corner to save the configuration

Now that the ‘game’ is configured you can install Twitch soundtrack. To run the installer click on the drop down menu next to the glass of wine and select ‘Run EXE inside Wine prefix’ (I attached a screenshot to show which menu I mean and you should see it below this paragraph). Now you can select the installer an run it. The installer should show up and you can click on a single button which installs the application.

Once the installation is finished it will automatically start twitch soundtrack, which should be a black window. Close that window by selecting ‘Kill all Wine processes’ in the same drop down menu.

To get Twitch soundtrack fully working you need to install the missing fonts in the prefix. Go to the same as before and select ‘Winetricks’. Once the winetricks menu opens click on ok (this just selects your current prefix which is what you want). Now select ‘Install a font’ and click ok. Select arial and calibri and click ok. Once the window appears again the installation is finished and you can close winetricks by clicking on ‘Cancel’ until winetricks is gone.

Last but not least you have to select which application the game should start. Click on the drop down menu next to the play button and click on ‘Configure’. Select the ‘Game options’ tab and browse the ‘executable’. First navigate to your prefix folder, then select drive_c, users, YOUR_USERNAME, Desktop and there should be a file called ‘Soundtrack by Twitch.lnk’. Select that and click OK. Save the configuration and you are good to go.

You can now start Twitch soundtrack by clicking on Play. Log in with your twitch account and skip the rest of the setup. Twitch soundtrack will annoy you that it cannot find the streaming software and cannot install the plugin. This is how it should be since you have not installed obs in the same prefix as twitch soundtrack. You can simply ignore this the application works just fine.

Setting up the VOD / Streaming audio

TL;DR: create sinks to have virtual output devices and loopbacks to connect them to your headphones.

This section describes how to set up your audio so that you have separate stream and VOD audio outputs. Here two virtual output devices are created: a VOD output and a stream output. I have configured it in a way so that by default everything on the VOD is also on stream but the stream can have additional audio like music.

Before I explain how this is done I have to explain a few terms when you deal with pulseaudio and its configuration:

  • sink: an output device where sound can be sent to
  • loopback: a connection between an output and a sink
  • source: an input device where sound can come from

By default if you create a new sink it also has a source (called monitor) so that you can retrieve the audio from each source and send it somewhere else.

 I create two new sinks VOD and Stream. Everything that I want to have on the VOD will be sent to the VOD output device.

The monitor of the VOD is connected via a loopback to the Stream. This causes everything that should be on the VOD to also be on the Stream but not the other way around.

Finally there is another loopback that sends all of the audio from the Stream to my headphones.

In the attachments there is the script I use to set this up, since this has to be set after each reboot. You might have to change the name of your audio output. You can get it with the command ‘pacmd list-sinks’. Just replace the name of the output device in the script with the name of the output device that should receive the output.

You have to use a tool like pavucontrol or the sound applet on KDE plasma to set the output device for each application. This way you have full control over what is output and where it is output to without the need for any external tool.

The last thing you have to do is configure OBS. I created a new scene where I put all of the audio stuff. That scene can be added to other scenes so you don’t have to worry about having too many sources in all of your scenes.

To have VOD only sound in twitch stream you have to open the OBS settings and go to the output tab. Select advanced as the output mode otherwise you will not see the option. Now you can select a track as twitch VOD Track. I usually use track 6 for this but you can use everything (as far as I know). You can now apply the settings and close them.

Now you have to add two audio sources to your scene, one for the VOD and one for the stream. Select VOD and Stream respectively as the audio source.

The last thing you have to do is change the audio configuration. Click on Edit then on ‘advanced audio configuration’. Now disable Track 6 for the stream audio source and any other source that should not be on the VOD and make sure that track 6 is enabled on the VOD source.

That should be everything you need when it comes to the audio configuration.

Ending words

This might sound like a lot and I didn’t even touch how you can configure scenes and stuff in OBS but there are other tutorials that explain that and it works the same on every OS. Like mentioned in the beginning most of this is just to set up Twitch soundtrack and have a dedicated VOD and Stream output. Luckily pulseaudio has all of the functions needed to make that work, since you need a tool like voicemeeter to do the same on windows.

That is it for now have fun streaming whatever you want from your linux machines.

This content is for Patrons only, it's not locked for you because you are an Administrator