How to create a music scene with subtitles in OBS

During the pandemic I found myself broadcasting music to a live audience. It started out as just a background audio track whilst showing a camera feed but as time passed people expressed a desire to sing along.

It sounded reasonable enough and surely it could be done and thus I set out into the world of broadcasting software, subtitling, and muxing.

Note: The subtitles I’m describing in this post are made before the broadcast, they are not a live caption based on an audio input or caption service such as you see with YouTube automatic caption.

What we will be making today

Process Summary

The process consists of the following logical step, which I will explain in greater detail in this post:

  • Combine green image with audio file into video file
  • Create scene in broadcasting software
  • Add created video file to scene (as VLC Video Source)
  • Add image to display (could also be a camera feed or video) to scene
  • Set green chromakey to video source
  • Add backdrop to subtitles for clarity

Starting Resources

For the purpose of this post I will assume you have the following resources available:

  • Audio File (mp3)
  • Picture to display during the music
  • A Subtitle file. You can use my example subtitle file for testing purposes. You have to right click the link and select save link as otherwise your browser just displays the content
  • OBS (Open Broadcaster Software) installed (https://obsproject.com/)
  • VLC Media Player installed (https://www.videolan.org/)

Combine green image with audio file into video file

We will start with the most technical part, muxing the audio (mp3) with a green image into a video.

We can’t simply add a subtitle file to OBS. But if we use a VLC Video Source (instead of an audio source), VLC will automatically look for and display a subtitle file.

We add a green image so we can chromakey (remove a certain color from a video source) the background of the video in a later step. Whereas if you would just use a black background in your video the subtitle borders would also get removed and your subtitles won’t look as good.

Create Green Image

First we will create a new image of appropriate dimensions (in this case I want to broadcast at Full HD also know as 1080p or in other words 1920×1080 pixel). Or you can skip this step and just download my green image file

1) Start Paint by clicking the start button and start typing paint until the icon appears then click on it

2) Once paint has started click on File and then Image Properties

3) Change the width and height to the appropriate dimensions and click ok

4) Click the green color in the color palette, then click the fill tool and finally click on the canvas

5) Save the file by clicking file and then save. Store the file in a location you will remember. I stored my file as Green1920x1080.png

Preparing FFmpeg

In order to mux the newly created green image and your audio file we will use a tool called FFmpeg

  1. Download the tool from https://www.gyan.dev/ffmpeg/builds/ffmpeg-release-essentials.zip
  2. Extract the tool somewhere (if you extract it in c:\temp\music it will be easier to perform the next steps)
  3. Place your audio, subtitle and green image in the same directory. Make sure there are no spaces in the directory names because FFmpeg will throw errors. A good directory would be c:\temp\music but c:\temp\music test\ would cause issues

You eventually need to execute the following command to mux an image and audio file, but keep reading C:\temp\music\ffmpeg-5.0-essentials_build\bin\ffmpeg.exe -loop 1 -i c:\temp\music\Green1920x1080.png -i c:\temp\music\music.mp3 -c:a copy -c:v libx264 -shortest c:\temp\music\music.mp4

To simplify the process I wrote a small batch script which can be downloaded however keep in mind that this is a script file and you should always check scripts you download from the internet to make sure there isn’t anything malicious. In that same spirit, windows will automatically block you from using this script. Unless you lift this block by right clicking on the file -> properties -> check unblock -> ok

If you prefer not to download the script you can also create the script file yourself, the contents is as following

@echo off
SET MP3=%1
SET MP4=%MP3:.mp3=.mp4%
echo %MP3%
echo %MP4%
C:\temp\music\ffmpeg-5.0-essentials_build\bin\ffmpeg.exe -loop 1 -i %~dp0\Green1920x1080.png -i %MP3% -c:a copy -c:v libx264 -shortest %MP4%
pause

Whether you choose to call the FFmpeg by hand, download or create the script. You probably have to update the location of your ffmpeg.exe file unless you downloaded the zip file and extracted in c:\temp\music

Running FFmpeg

1) At this point you should have a directory (without spaces) that looks similar to this

2a) If you download or created the script you can simply drag and drop your music.mp3 onto the convertToMp4.bat file.


2b) If you don’t use the script you have to use the following command

C:\temp\music\ffmpeg-5.0-essentials_build\bin\ffmpeg.exe -loop 1 -i c:\temp\music\Green1920x1080.png -i c:\temp\music\music.mp3 -c:a copy -c:v libx264 -shortest c:\temp\music\music.mp4

3) FFmpeg will mux your image and audio file and display a screen similar to the following.

And you will have a music.mp4 file!

4) If you would play your mp4 file at this point it should look like this. Keep in mind that if your subtitles start after a few seconds into the music (which is likely) you might have to move the progression slider a bit forward

Configure OBS

Now we have all required files we can start adding them as sources to our OBS scene

Add Video to Scene

1) Add a VLC Video Source to your scene by clicking the add button in the sources dock and then click VLC Video Source

2) Give your new source a name (for example music-subtitles) and click ok

3) Add the mp4 we created (the one with the audio and green image) as source by clicking the add button next to the playlist and then add files. If you copied the video file to another location remember that the video and subtitle file should be in the same folder.

4) The next step seems optional but there is no harm in doing it. Scroll down in the music-subtitles source window and tick the box next to subtitles enabled then click ok

5) Your scene should now look like this (again keep in mind the subtitles might not appear if the current position of the music doesn’t have subtitles)

Add Image

1) Add an image source to your scene by clicking the add button in the sources dock and then click Image.

2) Give the new source a name (for example music-background) and click ok

3) Add your image by clicking browse and once you selected your image click ok

4) The order of your sources in OBS determine in what order they are displayed on top of each other. Make sure that your music-subtitles (VLC video source) is higher in your sources list, or in other words it will be displayed in front of your background

Apply chromakey

1) Remove the green background from the video with subtitles by right clicking on the VLC Video Source music-subtitles and then filters

2) Add a Chroma Key filter by clicking the add button at the bottom of the effects filters list and select Chroma Key

3) Give it a name and click ok

4) By default the chroma key is set to green so we don’t have to do anything extra, just click close. Just keep in mind that if you for some reason want to use green in your subtitles you can by making the background a different color (blue for example) and then select that color in the chroma key properties

5) In your scene you should now be able to see your video (with subtitles) and the background image

Add subtitles backdrop

Depending on your background image it can be hard to read the subtitles, to make it easier for your audience we can add an transparent backdrop.

1) Add an colour source to your scene by clicking the add button in the sources dock and then click Colour Source.

2) Give the new source a name (for example music-subtitle-backdrop) and click ok

3) Change the color of your colour source to black by clicking select colour

4) Select black and click ok

5) Change the width and height of your colour source and then click ok. I like the backdrop to be the full width of the scene so keep the width at the same maximum width as the scene (in this case 1920 pixels). The appropriate height of your colour source will depend on your subtitle size, spacing and the number of maximum lines on the screen at the same time. In my case 240 pixels works out nicely.

I would suggest you move the properties for ‘music-subtitle-backdrop’ window a bit to the side so you can see your scene in the background. This allows you to see changes in realtime, and you can even drag your color source on top of the subtitles to check if it is the right size.

6) Position your backdrop (if you haven’t done already) by dragging it into position. If your backdrop is on top of your subtitles you have to change the source order in the sources dock.

7) Make the colour source transparent by right clicking on the colour source music-subtitle-backdrop and then filters

8) Add a Colour Correctionfilter by clicking the add button at the bottom of the effects filters list and select Colour Correction

9) Give it a name and click ok

10) Change the opacity of your colour correction filter and then click close.

Remember to move the filters for ‘music-subtitle-backdrop’ window a bit to the side to see your scene in the background. Allowing you to see changes in realtime.

That is it! Your scene is now completed

Closing Remarks
There are a number of options to go from here

  • Add multiple videos (with subtitles) to your VLC Video Source
  • Replace the background image with a slideshow or camera feed
  • I noticed that running OBS 27.1.3 kept crashing on Windows 11. Enabling Compatibility Mode and setting it to Windows 8 resolved that instability for me.

How I connected an Aqara Sensor to VeraPlus

Several months ago I came across the Xiaomi Aqara Door and Window Sensor. It appears to be a simple reed switch with ZigBee connectivity, and they are very affordable at the price of approximately 8,50€ (10$) including shipping when buying from the regular sites.

The internet never ceases to prove you can read whatever you want. I read several post it is impossible to connect the sensor to VeraPlus, the main reason being cited is that the Aqara sensor deviates from the ZigBee protocol and only supports the Xiaomi Aqara Hub. However other people successfully connected the device.

I ventured and bought one of the sensors. Below I’ll describe how I succesfully connected the Xiaomi Aqara Door and Wndows Sensor to VeraPlus

Pairing Process

  1. Press button on Aqara for 3-5 seconds to ‘reset’ it
  2. Add Generic ZigBee device in VeraPlus through the UI
  3. Press and immediately release button on Aqara every few seconds until it pairs (this only seems to work when close to the Vera device).
  4. Complete the wizard in Vera (name device and select room)

Changing Generic ZigBee device to Door Sensor

  1. Go to the newly created device -> Advanced -> Params
  2. Change category_num to 4 (Security Sensor)
  3. Change subcategory_num to 1 (Door Sensor)

For a complete list of device category and sub category values see http://wiki.micasaverde.com/index.php/Luup_Device_Categories

Polling

Some people mentioned that Vera reports “Can’t Detect Device” which makes sense considering that it appears the Aqara sensor only activates when a change is detected (most likely to save battery). And therefore when Vera wants to poll the device it can’t find it.

To disable polling go to device -> advanced -> params and set PollEnabled to 0 (it was already disabled in my case)

Some Additional Observations

  • Sensor manafacturer shows up as LUMI (not Xiaomi as expected)
  • Sensor model shows up as lumi.sensor_magnet.aq2
  • Device is recognized as catagory 11 (Generic I/O) because we selected a generic ZigBee device. This needs to be changed in order for Home Assistant to pick up the device. When changing it to Security Sensor – Door Sensor it will be recognized as binary sensor in Home Assistant.
  • When I tried to change the category in Vera I initially caused the device to go into ‘ wait for wakeup to configure device’ state. This was resolved when I brought the device next to the VeraPlus.

Design a site like this with WordPress.com
Get started