Created
July 17, 2025 18:09
-
-
Save Cdaprod/15429c0c8ef73ada78869ef4f4d7561d to your computer and use it in GitHub Desktop.
• Every time the Stream Deck (or any other trigger) stops a recording, the finished file is moved to your UNC share \\cda-desktop\b\Video\_INCOMING\sources\OBS-NDI-GARAGE. • If the share isn’t currently mapped, the script attempts a one-shot net use so it works even when OBS is running elevated. • All status / errors are written to the normal O…
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| Move each finished recording to a UNC share. | |
| OBS ▶ Tools ▸ Scripts ▸ + ▸ select this file | |
| --------------------------------------------------------- | |
| • Works with Simple or Advanced output mode. | |
| • No change to your regular Recording Path is required; | |
| in fact, keeping it on a local SSD makes the initial write faster. | |
| --------------------------------------------------------- | |
| Tested with Python 3.11 + OBS 30. | |
| """ | |
| import obspython as obs | |
| import os | |
| import shutil | |
| import ctypes | |
| import time | |
| # ──────────────── CONFIG – EDIT ONLY IF PATH CHANGES ──────────────── | |
| TARGET_DIR = r"\\cda-desktop\b\Video\_INCOMING\sources\OBS-NDI-GARAGE" | |
| # ───────────────────────────────────────────────────────────────────── | |
| def ensure_share_ready(): | |
| """Return True if TARGET_DIR is reachable; try to mount once if not.""" | |
| if os.path.exists(TARGET_DIR): | |
| return True | |
| # Silent net use (no console popup) | |
| cmd = fr'net use "{TARGET_DIR}" /persistent:no' | |
| ctypes.windll.shell32.ShellExecuteW(None, "open", "cmd.exe", | |
| f'/c {cmd}', None, 0) | |
| time.sleep(2) # give Windows a moment | |
| return os.path.exists(TARGET_DIR) | |
| def on_event(event): | |
| if event == obs.OBS_FRONTEND_EVENT_RECORDING_STOPPED: | |
| src = obs.obs_frontend_get_last_recording() | |
| if not src: | |
| return | |
| if not ensure_share_ready(): | |
| obs.script_log(obs.LOG_WARNING, | |
| f"UNC share unreachable, leaving file at {src}") | |
| return | |
| dest = os.path.join(TARGET_DIR, os.path.basename(src)) | |
| try: | |
| shutil.move(src, dest) | |
| obs.script_log(obs.LOG_INFO, f"Moved → {dest}") | |
| except Exception as e: | |
| obs.script_log(obs.LOG_ERROR, f"Move failed: {e}") | |
| # ───────────── OBS API hooks ───────────── | |
| def script_load(settings): | |
| obs.obs_frontend_add_event_callback(on_event) | |
| def script_description(): | |
| return ("Moves every completed recording to the UNC share defined in " | |
| "TARGET_DIR, so you never have to change the Recording Path.") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment