Building a video soundboard in OBS

Despite the fact that I do not stream as much anymore, I continue to tinker with OBS on a daily basis. For a while now I wanted to have what I would call a “video soundboard”, a simple mechanism that allows me to quickly play short clips during my stream.

Now, this doesn’t really sound too hard. Create many scenes, add media sources, slap a StreamDeck button on top of that – boom, you are done. This is a crappy solution because it requires a ton of additional work to add new videos into the mix.

I wanted to have a mechanism that relies entirely on one single scene with one single media source for all the content. Control over what gets played is wholly set on the StreamDeck and the StreamDeck only, meaning that adding new content is as easy as adding a single new command to a new button on the StreamDeck.

Sounds interesting? Here is how it works.

Prerequisites

Before we start, you will need the following things ready:

The Basic Setup

Create a new button on your StreamDeck with the Text File Tools plugin.

Specify a target filename and set the Input Text to the location of your desired media file (i.e. C:/Temp/heheboi.mp4). Leave the “Append” checkbox unchecked so the entire file gets rewritten.

This is all you will need to do to add new media to the scene. We can now set up OBS.

Within OBS, create a new scene (i.e. “Scene – Memes”) and add a media source to that scene (i.e. “Media Source – Memes”). Make sure this is a media source and not a VLC source!

Open the properties of the media source and be sure to check the “Local File” checkbox, “Restart playback when source becomes active”, “Use hardware decoding when available” and “Show nothing when playback ends”.

Hide the media source via the Sources list by clicking on the “eye” icon in the source list.

Setting up Advanced Scene Switcher macros

Now open the Advanced Scene Switcher plugin via Tools – Advanced Scene Switcher, navigate to the Macro tab and add a new Macro called “Meme Scene (Start)”.

Check the “Perform actions only on condition change” checkbox and add the following condition:

[ If ] [ File ]
Content of [ local file ] [ <PATH ON STREAMDECK BUTTON> ] matches:
.*

(Yes, that is dot asterisk – no space or anything else before, after or inbetween)
Check the “use regular expressions” checkbox and the “if modification date changed” checkbox, and leave “if content changed” unchecked.

Now add the following actions:

[ Switch scene ]
Switch to scene [ Scene - Memes ]
Check the "Wait until transition to target scene is complete" checkbox.

[ Scene item visibility ]
On [ Scene - Memes ] [ Show ] [ Source ] [ Media Source - Memes ]

This takes care of actually playing the video when a change in the file is detected. But we also want to switch back to the previous scene when playback has finished, so we must add another macro.

Add the second macro “Meme Scene (End)”, check the “Perform actions only on condition change” checkbox and add the following conditions:

[ If ] [ Scene ]
[ Current scene is ] [ Scene - Memes ]

[ And ] [ Scene item visibility ] (Click the clock) [ For at least] [ 1.00 ] [ seconds ]
On [ Scene - Memes ] [ Media Source - Memes ] is [ Shown ]

[ And ] [ Media ]
[ Media Source - Memes ] state is [ Ended ]

Add the following actions to the second macro:

[ Switch scene ]
Switch to scene [ Previous Scene ]
(Check the "Wait until transition to target scene is complete" checkbox)

[ Scene item visibility ]
On [ Scene - Memes ] [ Hide ] [ Source ] [ Media Source - Memes ]

Now we should be good, right? Well, almost. While we react to changes in the file thanks to the macro and switch between the scenes, we still do not set the media file on the source. This is handled by the Lua script which we must set up as a final step.

Setting up the Lua script

Open the Scripts window via Tools – Scripts and add the VideoFileFromText.lua script.

You should see some options on the right side of the window.

Set the interval to 50ms, browse to select the same text file you used on the Elgato StreamDeck button for the Video File List, and select the “Scene – Memes” scene for the Scene, as well as the “Media Source – Memes” for the Media Source. Finally, check the “Enable script” button and you are done.

Tying it all together

Be sure that the Advanced Scene Switcher is active and press the button on the StreamDeck. The scene should switch to your Meme scene, play the video and then switch back. Add another button on the StreamDeck that writes a different video file path to the same text file.

Now press the new button, and the second video file should play.

This makes adding short clips really simple and pain-free. No need to manually create multiple scenes or deal with multi-action steps on the StreamDeck. Adding a new video is as quick as adding a new button, setting the path to the desired media file and giving it a nice button image.

Of course, this is just the solution that I came up with, so your mileage may vary.

However, I do think that the inherent simplicity makes it an ideal solution. What do you think?

Mplayer + CoreAVC

Windows, despite all it’s flaws, is nice for a few things. First of all, there’s a buttload of cool, gory games. And second there’s a really nice multimedia support; many companies/individuals write highly optimized software for video splitting, decoding, muxing, output etc.

Now, three cool programs are Haali’s Media Splitter (comes with Haali’s Media Renderer), CoreCodec’s CoreAVC and nVidia’s PureVideo. Combining these leads to a boost in performance, allowing my 2GHz notebook to play 1080p content steadily without hard framedrops.

Linux on the other hand is a little cornered. Yes, we do have XvMC for hardware MPEG-2 decoding but this doesn’t really help with HD content at this point. So until there’s a counterpart to PureVideo Linux will always be slower.

As you may know I only recommend Mplayer and Xine on Linux. They’re the greatest, the best and if you think otherwise you must be stupid 😉 .

Mplayer can be patched to use CoreAVC for a little performance boost (we all need a little boost, do we?). This is great stuff. The patch will fail a chunk against loader/Makefile, but it’s no problem to add the missing lines by hand. Also, please note that you’ve to run ./configure –disable-mencoder before applying the patch.

So, how much does it give us in terms of raw performance? Not too much, unfortunately, but for my system 5-12% already make a big difference.

Most of the performance loss is still being caused by the lack of hardware MPEG-4 decoding and the use of the old Overlay mixer.

Nevertheless, if you have bought CoreAVC you owe it to yourself to give it a try.