I saw your code on the OBS Forum as well and wanted to help here too.
I made some tweaks to your Python example and it worked great!
I want to clarify some things in case anyone wants to do exacly what OP wanted. You should follow these steps:
- Install the obs-websocket plugin
- Install the obs-websocket-py which is the Python tool for the plugin (you can do this using pip)
- Create a new .py file wth this code:
Python:
import obswebsocket
from obswebsocket import obsws, events, requests
client = obswebsocket.obsws("localhost", 4444, "") #Change this if you have a different name, port or password
client.connect()
client.call(obswebsocket.requests.GetFilenameFormatting())
print("Hi! I'm your new video\nWhat's my name?\nFilename:")
client.call(obswebsocket.requests.SetFilenameFormatting(input() + " - %MM-%DD %hh-%mm")) #Custom name + date. The best of two worlds
client.call(obswebsocket.requests.StartRecording())
print(client.call(obswebsocket.requests.GetFilenameFormatting()))
client.call(obswebsocket.requests.SetFilenameFormatting("-%MM-%DD %hh-%mm-%ss"))
print(client.call(obswebsocket.requests.GetFilenameFormatting()))
client.disconnect()
- Open OBS and execute the code
And voilà! A new window will open and it should ask you for your video's name and then start recording.
I wanted to write this bc it took me a lot of time to figure this out. So let me know if it helped you too.