Resource icon

OBS Python Additional Replay Buffer 0.1

ODENYGG

New Member
This is a late contribution, but the original script lacks a function to capture several audio streams properly (if you have multiple audio streams configured). To change that, replace the line
Python:
"-vcodec", "copy", "-acodec", "copy", targetname]
with
Python:
"-map", "0?", "-vcodec", "copy", "-c:a", "copy", targetname]

Additionally, you can replace the FFMPEG file from moviepy with a newer version (the one it uses is quite old)
If you installed it using pip, the default location should be
C:\Users\"Your Name"\AppData\Local\Programs\Python\...\Lib\site-packages\imageio_ffmpeg\binaries
or wherever you installed Python to.
I. Love. You. I was desperate to find a solution for this, as it was making the script completely unusable for me. Thank you so much!
 

JohnCarson89

New Member
[additional-replays.py] ModuleNotFoundError: No module named 'moviepy'
Getting this error after attempting to run. Installed moviepy no problem, says it's already in there.
 

JohnCarson89

New Member
Got the above working, but I'm running into this issue.

[additional-replays.py] Traceback (most recent call last):
[additional-replays.py] File "C:/Program Files/obs-studio/data/obs-plugins/frontend-tools/scripts\additional-replays.py", line 154, in save_replay3
[additional-replays.py] subprocess.call([PKG_INSTALL_CMD_FULL])
[additional-replays.py] File "C:/Program Files/obs-studio/data/obs-plugins/frontend-tools/scripts\additional-replays.py", line 196, in save_replay
[additional-replays.py] path = None
[additional-replays.py] TypeError: must be str, not int
 

Suslik V

Active Member
@JohnCarson89 because there are too many versions of the same script, it is hard to tell what is wrong with yours.
Probably you forgot to set new destination (valid path) for new replays in the properties of the script itself (main menu Tools > Scripts > your_script).
 

newuxtreme

New Member
This is a late contribution, but the original script lacks a function to capture several audio streams properly (if you have multiple audio streams configured). To change that, replace the line
Python:
"-vcodec", "copy", "-acodec", "copy", targetname]
with
Python:
"-map", "0?", "-vcodec", "copy", "-c:a", "copy", targetname]

Additionally, you can replace the FFMPEG file from moviepy with a newer version (the one it uses is quite old)
If you installed it using pip, the default location should be
C:\Users\"Your Name"\AppData\Local\Programs\Python\...\Lib\site-packages\imageio_ffmpeg\binaries
or wherever you installed Python to.

I. Love. You. I was desperate to find a solution for this, as it was making the script completely unusable for me. Thank you so much!

@JohnCarson89 because there are too many versions of the same script, it is hard to tell what is wrong with yours.
Probably you forgot to set new destination (valid path) for new replays in the properties of the script itself (main menu Tools > Scripts > your_script).


Would so greatly appreciate some help here please!

So far :

1. Installed Python 3.9
2. Set up the script right afaik, set up hotkeys as Alt 1 (60s), 2(180s), 3 (300s)
3. Set up save folder
4. I have not understood how to update the ffmpeg file as suggested by @KittieCatKay

When I run OBS and press say Alt 1, it seems to just capture and save the overall replay buffer length I have so far which is beyond 5 mins even, so it's not exactly snipping right the way it should I think.

The function seems to do the SAME thing whether I press Alt 1 2 or 3.

If I press say Alt 1 first nothing really happened, no error or anything but it also only saved a 1 kb file of nothing.
Then if I press Alt 2 this error pops up :

1724351325469.png
 

Suslik V

Active Member
@newuxtreme the script has mistake when destination folder for "truncated" replays wasn't set at all (or was set the same as for the regular replays).

It uses FFmpeg v4.2.2, thus only supports codecs known to this version of FFmpeg.

Here is a bit newer, fixed version:

AdditionalReplays_0_2_2_beta_2024_08_23.zip, ~5KiB to download.
CRC of the zip archive MD5:5A54DFE2FF4564498EC844FCE2DA2CB5

inside:
"AdditionalReplays.py" (~20 KiB)

Usage (for test purposes):
  1. Look online for "Windows x86-64 embeddable zip file" of the Python and download it (the "python-3.6.8-embed-amd64.zip" file). Then unpack its contents to any suitable folder (I don't recommend Unicode symbols in the path). You'll see many files in your folder, like: "python.exe", "python3.dll" etc.
  2. Go to OBS Tools > Scripts > Python Settings tab , and set Python Install Path (64bit) to the folder from p1.
  3. Restart OBS.
  4. Go to OBS Tools > Scripts and add "AdditionalReplays.py" file.
  5. Click "Install moviepy with pip" button under the script's description. (3 cmd window will be opened one by one that downloads pip and all required modules for Python).
  6. Wait until message "Restart OBS, please" appear under the button from p5.
  7. Restart OBS.
  8. Set OBS Settings > Hotkeys "Replay 1", "Replay 2" and "Replay 3" hotkeys.
  9. Start Replay Buffer of OBS as usual. Click the "Replay 1" hotkey to save replay that will be cut on the fly to specified length.
Note. p5-p6 are optional and works only for mentioned version of Python. Of course, you may install all required modules manually, the "moviepy" and its dependencies (~160MiB including Python itself).

The tests were running in obsolete Windows OS, OBS v27+ 64-bit (custom build), with the embedded (that itself is not recommended for this use case) version of the Python v3.6.8. I didn't check the whole algorithm, so

As is.
 

Attachments

  • AdditionalReplays_0_2_2_beta_2024_08_23.zip
    4.7 KB · Views: 12

Suslik V

Active Member
Some old issues were triggered when new features implemented. So, new fixes (to old features) comes only with new features. New defaults and option names, so check your settings.

Here is a bit newer, also fixed version:
AdditionalReplays_0_3_1_beta_2024_09_19.zip, ~9KiB to download.
CRC of the zip archive MD5:2120ED7A37CB0DA8B2B9A37058760193

inside:
"AdditionalReplays.py" (~36 KiB)

Usage is the same as written one post above.

Changes:
* "modification" instead of "creation" time in checks for the "new file is ready!" routine. Useful only for replays that has static (constant) names, and no new file ever being created.
Tech details: os.path.getmtime() vs os.path.getctime() in use.​
* the script will not crash if replay media remains busy for a long.
Tech details: now the file-ready check returns null object when all attempts fails, instead of returning real filename that itself remains in use by other threads.​
- the option name "from which end to cut media from" was renamed to become more clear.
Tech details: I mistaken in it too, so now it is named "Drop begin, preserve end".​
- new Defaults.
Tech details: everyone needs last seconds in replay, not unknown first. Useful for live events.​
+ optional Instant Replay functionality. Last truncated replay goes to selected source of OBS.
Tech details: only VLC Video Source is supported because it allows playlists that itself used for the next feature...​
+ ...optional reversed playback of last replay. Short media file plays before actual replay in VLC. Creates kind of "rewind" effect.
Tech details: last replay sped-up to fit into ~2.5 sec, and then reversed. Requires ~0.5 GiB of RAM. Takes some time for encoding.​
+ when job is done script generates hotkey press event for internals of OBS.
Tech details: hotkey "Ctrl + Alt + Num7" triggered when replay is ready.​

Was tested only on Windows, Python v3.6.8.
 

Attachments

  • AdditionalReplays_0_3_1_beta_2024_09_19.zip
    8.6 KB · Views: 29
Last edited:
Top