A Python script to automate OBS Studio recording, allowing for quick, hotkey-driven screen recordings. This tool is designed for users who frequently record short clips and want to streamline their workflow.
demo_obs_auto.webm
This script simplifies the process of settings filenames per recording.
- Hotkey-driven recording: Start and stop recordings with global hotkeys.
- Customizable filenames: Prompt for a human-readable filename before recording.
- Automatic playback: Instantly opens the recorded video after stopping.
- OBS Studio integration: Uses
obs-websocketfor seamless control. - Configurable: Configurable paths for OBS and media player, and
obs-websocketconnection details viaconfig.ini.
- Python 3.12 or newer.
- OBS Studio installed and running.
- obs-websocket plugin installed for OBS Studio, you need to install it before using this script.
uvis recommended for dependency management and project environments. If not installed, you can install it usingpip install uv.- The script is tested in Linux environment, in other OS it may require additional setup.
- Clone the repository:
git clone https://github.com/iturdikulov/obs_auto
cd obs_auto- Install dependencies using
uv:
uv venv
source .venv/bin/activate
uv pip install -e .Alternatively, if you do not use uv, you can attempt to use pip:
python -m venv .venv
source .venv/bin/activate
pip install -e .Edit the config.ini file in the project, adjust values as per your setup:
Important: Make sure to enable the obs-websocket server in OBS Studio
(Tools -> Websocket Server Settings). If you use a password, configure one
in config.ini.
The script is designed to be triggered by global hotkeys.
Run the script in its default mode:
./obs_record.py
# You can run it alternatively, useful for non-unix environment
PATH_TO_PROJECT/.venv/bin/python obs_record.pyThis will ensure OBS is running, open a small window to ask for a filename, and then start recording in OBS with the specified name.
Run the script with the --mode stop argument:
python obs_record.py --mode stopThis will stop the current recording in OBS, save the file, and then open it with your configured media player.
You can bind these commands to global hotkeys in your desktop environment's settings.
Example for "Start Recording": cd PATH_TO_PROJECT && ./obs_record.py, hotkey: Meta + R
Example for "Stop Recording": cd PATH_TO_PROJECT && ./obs_record.py --mode=stop, hotkey: Meta + Shift + R