Today I will tell you how the mechanism for changing the backgrounds on my stream is built. This method has undergone several radical upgrades and improvements, thanks to the developments of SpaceMelodyLab, but I will go from the beginning, covering all the stages, with some lyrical digressions.
[embedyt] https://www.youtube.com/watch?v=7CNRhRk1PPE[/embedyt]Idea
The idea to add visualizations to stream arose even before the start of the very first broadcast and the appearance of the green screen. So the first thing I started looking for was visualizers that could process the inputaudio signal in real time. This search, surprisingly, took several long evenings, but I could not find what I needed except for a couple of paid programs. Only when I was desperate, I accidentally caught sight of a review on YouTube with the program Plane9 (https://www.plane9.com/). Free and functional. And more recently, Flamberg suggested that you can also use plugins for Winamp (Milkdrop or projectM) for this purpose. It is only necessary to dig a little with the input / output signal settings (in fact, the trick is only that in Winamp you need to press CTRL+L (Open Location) and type linein:// so that Winamp starts receiving a signal from an incoming source, then click Play and run the plugin with the visualizer).
There was no green screen, so I just made the visualizer semi-transparent and turned it on periodically (first manually, then through a script for OBS-Visibility Timer https://obsproject.com/forum/resources/visibility-timer.638/). It is clear that this was a compromise option.
When the green screen appeared, it became more fun. I pumped up with https://pixabay.com/ free videos, edited them into one 30-minute video, combined them with the visualizer from Plane9 and set this pack to the background.
For a while, everything remained exactly that way, until I began to spend more time watching other streamers and saw how audio files were launched at the command from the chat. So I discovered the Streamlabs Chatbot. I added sounds, transferred commands from another bot there, skimmed through the manual and stopped there.
Changing scenes
Eventually, I came across a Facelessclown stream and I saw there how the commands from the chat, the scenes change and the gifs start right on the screen. It was he who told me that I needed the Streamlabs Chatbot (which I already had installed) and the OBS Remote Parameter script for it. After sweating for a couple of hours, understanding the instructions and settings, I still achieved the result (a detailed article on setting up this script is in previous articles). So I learned how to change scenes and enable/disable OBS sources, and also went deeper into the capabilities of the Streamlabs Chatbot.
But in fact, for these purposes, it is not necessary to use Streamlabs Chatbot: the same functions can be performed by virtual streamdecks like Lioranboard or TouchPortal (and even more: they still know how to turn on / off source filters — and this is a whole new space for experiments). But because I found out about them later, and Streamlabs Chatbot was already in full use, so I decided to stay on it.
First structure
The original principle was as follows:
In OBS, a new Scene was created (namely the scene, not the source) with the name of the background (e.g. Neon3). The main Stage (e.g. Main) was added to this scene, where all the alerts, widgets, cameras, etc. were displayed. Then a new media source with the video was added and placed in the bottom layer under the Main scene, inside the Neon3 scene. Next, the commandwas created in Streamlabs Chatbot !neon3, which switched the scenes. Accordingly, a separate scene and a separate commandwere created for each background.
Plane9 had to be abandoned because it heavily loaded my processor and the PC could not play video from scenes together with this visualizer without strong lags.
In general, the OBS ability to add a scene to a scene is a very convenient and powerful tool that helps you save a lot of time in individual cases, as well as create crazy visual effects (just try toexperiment with it— for example, the color train of my silhouette is built just on this technique).
Actually, that’s all. The most simple mechanism. And if there are not many such scenes and you do not want to put Streamlabs Chatbot, then you can always use virtual stream decks.
In my case, the number of backgrounds grew at an incredible rate, so in the end I was faced with the fact that the RAM of my computer was clogged to the brim (OBS loads all the scenes and sources into RAM at startup). And I decided that the limit was reached (it was something in the region of 70-80 scenes) – which I announced in the Discord chat and after a little discussion with brainstorming, everything went quiet. But not for long…
MediaRotation
SpaceMelodyLab, being a programmer, quickly burst in with a simple and elegant solution, how to optimize the background change mechanism and overcome the RAM limit. And he presented a working prototype in just a couple of days!
The essence of the idea is that all the scenes are now replaced by just one (!) Browser source (html page) located on the computer’s hard drive. This page is embedded with javascript, which reads every few seconds a text file containing the path to the media (for example. E:/files/neon3.mp4) and if the content of the text file changes, it updates the page tag’s src dynamically (changes the displayed file).
The contents of the text file are rewritten by the Streamlabs Chatbot, which is able to rewrite the text via the $overwritefile parameter in the command response.
Thus, the OBS Remote Parameters script is no longer required, and the load from RAM is transferred to the hard disk.
In each Streamlabs Chatbot command linked to a specific background, the response to the file census with the path to it was simply rewritten:
for example. Command:! neon3 – > Response: $ overwritefile(“E:/media.txt”, ” files\neon3. mp4”)
Plus, for the backgrounds that the viewer offers through a reward for channel points, the script provided a timer with a countdown that blocked the background change for a given time.
The engine was called Mediarotation and I thought that it could not be better. But a few months later, SpaceMelodyLab throws me a completely new script in my personal messages..
SML Widget
The essence remains the same: the source browser, the file rewriting via Streamlabs Chatbot and the timer.
But!
Now all the paths to the necessary files (with an Id assigned to the background and the ability to group them into categories) are stored in a single text file, and in StreamlabsChatbot, ONLY ONE command is responsible for execution now! Plus, the timer has started to live its own separate life (now it can be paused and set any countdown time for different commands).
Roughly speaking, if earlier I had to create a new command for each new background and write the path to the desired file in the response of this command, now it is enough to write the background id and the path to it only in the source file (a text file that is a database). And the only command in the Streamlabs Chatbot is: !bg “title“ rewrites the file, and the script uses the assigned id to find the background and turn it on.
This is a great optimization and time-saving feature.
The script is still being improved and refined. And SpaceMelodyLab plans to publish it on GitHub in the future. Of course, given that it requires Streamlabs Chatbot or another tool that can rewrite text files on request from the chat, and not everyone needs so many backgrounds (at the moment there are 102), this tool can be considered very narrowly focused. But it can still be useful for those streamers who want to do something similar and have low PC power to create a lot of scenes in OBS.
Actually, this is how everything works. I tried to tell you everything in detail and give you as much useful information as possible.
Of course, a huge thank you to SpaceMelodyLab for the effort and time spent on the development of this miracle and all the support heprovides me.
Be sure to follow to his channels on Twitch and Soundcloud. He composes beautiful music in Ableton right on the streams:
https://www.twitch.tv/spacemelodylab
