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.
Before we start, you will need the following things ready:
- An Elgato StreamDeck with BarRaider’s Text File Tools plugin installed. The plugin is available in Elgato’s plugin store.
- OBS with the Advanced Scene Switcher plugin installed.
- This handy Lua script that I frankenstein’d together.
- Some media (preferably videos) you want to play.
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?