Answers.Body: <p>I've managed to achieve this using obs-websocket and simple/dirty python script.
  The obs-websocket plugin can get/set the pattern used by OBS to save recording files.</p>
  <p>Steps:
  Install/configure obs-websocket plugin.
  Then use obs-cli (<a href="https://github.com/leafac/obs-cli" rel="nofollow noreferrer">https://github.com/leafac/obs-cli</a>) or obswebsocket (<a href="https://pypi.org/project/obs-websocket-py/" rel="nofollow noreferrer">https://pypi.org/project/obs-websocket-py/</a>).</p>
  <p>cli example (under Windows os, beware of double quotes):</p>
  <pre><code>obs-cli-win SetFilenameFormatting=&quot;{ &quot;&quot;filename-formatting&quot;&quot;: &quot;&quot;TESTNAME %CCYY-%MM-%DD %hh-%mm-%ss&quot;&quot; }&quot; &amp;&amp; ^
  obs-cli-win StartRecording &amp;&amp; ^
  obs-cli-win SetFilenameFormatting=&quot;{ &quot;&quot;filename-formatting&quot;&quot;: &quot;&quot;%CCYY-%MM-%DD %hh-%mm-%ss&quot;&quot; }&quot; &amp;&amp; ^
  obs-cli-win GetFilenameFormatting
  </code></pre>
  <p>python example:</p>
  <pre class="lang-python prettyprint-override"><code>client = obswebsocket.obsws(&quot;localhost&quot;, 4444, &quot;&quot;)
  client.connect()
  print(client.call(obswebsocket.requests.GetFilenameFormatting()))
  client.call(obswebsocket.requests.SetFilenameFormatting(&quot;TESTNAME&quot; + &quot; - %CCYY-%MM-%DD %hh-%mm-%ss&quot;))
  client.call(obswebsocket.requests.StartRecording())
  print(client.call(obswebsocket.requests.GetFilenameFormatting()))
  client.call(obswebsocket.requests.SetFilenameFormatting(&quot;%CCYY-%MM-%DD %hh-%mm-%ss&quot;))
  print(client.call(obswebsocket.requests.GetFilenameFormatting()))
  client.disconnect()
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-05-08T20:25:17.203Z
Answers.LastActivityDate: 2021-05-08T20:25:17.203Z
Answers.UserDisplayName: wwk
Answers.Body: <p>I saw your code on the OBS Forum as well and wanted to help here too.</p>
  <p>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:</p>
  <ol>
  <li>Install the obs-websocket plugin</li>
  <li>Install the obs-websocket-py which is the Python tool for the plugin (you can do this using pip)</li>
  <li>Create a new .py file wth this code:</li>
  </ol>
  <p>Python:</p>
  <pre><code>import obswebsocket
  from obswebsocket import obsws, events, requests
  
  client = obswebsocket.obsws(&quot;localhost&quot;, 4444, &quot;&quot;) #Change this if you have a different name, port or password
  client.connect()
  client.call(obswebsocket.requests.GetFilenameFormatting())
  print(&quot;Hi! I'm your new video\nWhat's my name?\nFilename:&quot;)
  client.call(obswebsocket.requests.SetFilenameFormatting(input() + &quot; - %MM-%DD %hh-%mm&quot;)) #Custom name + date. The best of two worlds
  client.call(obswebsocket.requests.StartRecording())
  print(client.call(obswebsocket.requests.GetFilenameFormatting()))
  client.call(obswebsocket.requests.SetFilenameFormatting(&quot;-%MM-%DD %hh-%mm-%ss&quot;))
  print(client.call(obswebsocket.requests.GetFilenameFormatting()))
  client.disconnect()
  </code></pre>
  <ol start="4">
  <li>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.</li>
  </ol>
  <p>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.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-05-19T17:28:35.463Z
Answers.Text: Thanks for sharing.
Answers.UserDisplayName: wwk
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-05-16T05:13:19.483Z
Answers.LastActivityDate: 2022-05-16T05:13:19.483Z
Answers.UserDisplayName: lucasdepetris
Answers.Body: <p>My final solution is a simple python script (for Windows) that starts OBS minimised (if not started yet), asks for the filename prefix and starts recording.
  Dirty but fits my needs.</p>
  <pre class="lang-python prettyprint-override"><code>#!/usr/bin/env python
  import psutil
  import obswebsocket
  import obswebsocket.requests
  import subprocess
  import sys
  import signal
  import time
  
  def signal_handler(sig, frame):
      print('\n\nExiting.')
      sys.exit(0)
  
  obs_process_name = &quot;obs64.exe&quot;
  obs_bin_dir = &quot;C:\\Program Files\\obs-studio\\bin\\64bit\\&quot;
  obs_bin_full_path = obs_bin_dir + obs_process_name
  obs_params = &quot;--minimize-to-tray&quot;
  
  signal.signal(signal.SIGINT, signal_handler)
  
  if len(sys.argv) &gt;= 2:
      file_name_prefix = ' '.join(sys.argv[1:])
  else:
      print(&quot;Enter recording name or exit with CTRL-C.&quot;)
      file_name_prefix = input(&quot;Recording name: &quot;)
  
  if not obs_process_name in (p.name() for p in psutil.process_iter()):
      print(&quot;Process &quot; + obs_process_name + &quot; not running. Starting.&quot;)
      subprocess.Popen([obs_bin_full_path, obs_params], cwd=obs_bin_dir)
  else:
      print(&quot;Process &quot; + obs_process_name + &quot; already running.&quot;)
  
  file_name_prefix = &quot;&quot;.join([c for c in file_name_prefix if c.isalpha() or c.isdigit() or c == ' ']).rstrip()
  
  print(&quot;Will use name [&quot; + file_name_prefix + &quot;].&quot;)
  
  client = obswebsocket.obsws(&quot;localhost&quot;, PORT_NUMBER, &quot;PASSWORD&quot;)
  
  while True:
      try:
          client.connect()
      except:
          sys.stdout.write(&quot;.&quot;)
          continue
      else:
          client.call(obswebsocket.requests.SetFilenameFormatting(file_name_prefix + &quot; - %CCYY-%MM-%DD %hh-%mm-%ss&quot;))
          client.call(obswebsocket.requests.StartRecording())
          client.call(obswebsocket.requests.SetFilenameFormatting(&quot;%CCYY-%MM-%DD %hh-%mm-%ss&quot;))
          client.disconnect()
          break
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-05-19T17:38:46.597Z
Answers.LastActivityDate: 2022-05-19T17:38:46.597Z
Answers.UserDisplayName: wwk
Body: <p>OBS allows you to change the pattern for the recordings filenames but there is no simple way to update the file name with any custom string before every recording.</p>
  <p>You need to visit the options pane and change settings manualy.
  The default for the filename formating is: &quot;%CCYY-%MM-%DD %hh-%mm-%ss&quot;</p>
  <p>Let's say you've changed the pattern to &quot;MY-<strong>HOME</strong>-VIDEO %CCYY-%MM-%DD %hh-%mm-%ss&quot; and recorded a file.</p>
  <p>Then if you need to make another recording about something else with the prefix &quot;MY-<strong>OTHER</strong>-VIDEO &quot; you need to change the pattern again, manually.</p>
  <p>How to update the filename formating without visiting options pane every time?</p>
  
Tags: <video-capture><obs><recording>
Title: OBS custom filename for recordings
UserDisplayName: wwk
ThreadText: # OBS custom filename for recordings
  
  (Asked by: username_0 on 2021-05-08)
  
  OBS allows you to change the pattern for the recordings filenames but there is no simple way to update the file name with any custom string before every recording.
  
  You need to visit the options pane and change settings manualy.
  The default for the filename formating is: "%CCYY-%MM-%DD %hh-%mm-%ss"
  
  Let's say you've changed the pattern to "MY-**HOME**-VIDEO %CCYY-%MM-%DD %hh-%mm-%ss" and recorded a file.
  
  Then if you need to make another recording about something else with the prefix "MY-**OTHER**-VIDEO " you need to change the pattern again, manually.
  
  How to update the filename formating without visiting options pane every time?
  
  **Tags:** video-capture, obs, recording
  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_0 on 2021-05-08. Score: 1
  
  I've managed to achieve this using obs-websocket and simple/dirty python script.
  The obs-websocket plugin can get/set the pattern used by OBS to save recording files.
  
  Steps:
  Install/configure obs-websocket plugin.
  Then use obs-cli (<https://github.com/leafac/obs-cli>) or obswebsocket (<https://pypi.org/project/obs-websocket-py/>).
  
  cli example (under Windows os, beware of double quotes):
  
  ```
  obs-cli-win SetFilenameFormatting="{ ""filename-formatting"": ""TESTNAME %CCYY-%MM-%DD %hh-%mm-%ss"" }" && ^
  obs-cli-win StartRecording && ^
  obs-cli-win SetFilenameFormatting="{ ""filename-formatting"": ""%CCYY-%MM-%DD %hh-%mm-%ss"" }" && ^
  obs-cli-win GetFilenameFormatting
  
  ```
  
  python example:
  
  ```python
  client = obswebsocket.obsws("localhost", 4444, "")
  client.connect()
  print(client.call(obswebsocket.requests.GetFilenameFormatting()))
  client.call(obswebsocket.requests.SetFilenameFormatting("TESTNAME" + " - %CCYY-%MM-%DD %hh-%mm-%ss"))
  client.call(obswebsocket.requests.StartRecording())
  print(client.call(obswebsocket.requests.GetFilenameFormatting()))
  client.call(obswebsocket.requests.SetFilenameFormatting("%CCYY-%MM-%DD %hh-%mm-%ss"))
  print(client.call(obswebsocket.requests.GetFilenameFormatting()))
  client.disconnect()
  
  ```
  
  
  ---
  
  ### Answer by username_1 on 2022-05-16. Score: 1
  
  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:
  
  1. Install the obs-websocket plugin
  2. Install the obs-websocket-py which is the Python tool for the plugin (you can do this using pip)
  3. 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()
  
  ```
  
  4. 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.
  
  > **Comments:**
  > **username_0**: Thanks for sharing.  
  
  ---
  
  ### Answer by username_0 on 2022-05-19. Score: 0
  
  My final solution is a simple python script (for Windows) that starts OBS minimised (if not started yet), asks for the filename prefix and starts recording.
  Dirty but fits my needs.
  
  ```python
  #!/usr/bin/env python
  import psutil
  import obswebsocket
  import obswebsocket.requests
  import subprocess
  import sys
  import signal
  import time
  
  def signal_handler(sig, frame):
      print('\n\nExiting.')
      sys.exit(0)
  
  obs_process_name = "obs64.exe"
  obs_bin_dir = "C:\\Program Files\\obs-studio\\bin\\64bit\\"
  obs_bin_full_path = obs_bin_dir + obs_process_name
  obs_params = "--minimize-to-tray"
  
  signal.signal(signal.SIGINT, signal_handler)
  
  if len(sys.argv) >= 2:
      file_name_prefix = ' '.join(sys.argv[1:])
  else:
      print("Enter recording name or exit with CTRL-C.")
      file_name_prefix = input("Recording name: ")
  
  if not obs_process_name in (p.name() for p in psutil.process_iter()):
      print("Process " + obs_process_name + " not running. Starting.")
      subprocess.Popen([obs_bin_full_path, obs_params], cwd=obs_bin_dir)
  else:
      print("Process " + obs_process_name + " already running.")
  
  file_name_prefix = "".join([c for c in file_name_prefix if c.isalpha() or c.isdigit() or c == ' ']).rstrip()
  
  print("Will use name [" + file_name_prefix + "].")
  
  client = obswebsocket.obsws("localhost", PORT_NUMBER, "PASSWORD")
  
  while True:
      try:
          client.connect()
      except:
          sys.stdout.write(".")
          continue
      else:
          client.call(obswebsocket.requests.SetFilenameFormatting(file_name_prefix + " - %CCYY-%MM-%DD %hh-%mm-%ss"))
          client.call(obswebsocket.requests.StartRecording())
          client.call(obswebsocket.requests.SetFilenameFormatting("%CCYY-%MM-%DD %hh-%mm-%ss"))
          client.disconnect()
          break
  
  ```
  
  
  ---
  
  