Closed thelabcat closed 3 months ago
Renamed current clip command, since it will still be useful for third-party actor running.
Did not mean to close, oops.
Good news! Test code successfully received and saved a VOB stream via TCP from OBS. We used the Advanced output settings to have FFmpeg send the "recording" from OBS to a local host. TYJ!
import socket
import select
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind(("localhost", 3119))
s.listen(1)
if True:
c, info = s.accept()
print("connected")
f = open("test.vob", "wb")
data = True
while data:
select.select([c], [], [])
data = c.recv(1024)
print("data received")
f.write(data)
f.close()
Better method: Record to an ordinary TS file, and do this:
import os
import shutil
from tkinter import filedialog, Tk
from moviepy.editor import VideoFileClip
root = Tk()
root.withdraw()
fn = filedialog.askopenfilename(title = "Select OBS recording in progress")
container = fn.split(".")[-1]
copy_fn = "recording_isolated." + container
input("Press enter to save clip")
print("Making frozen copy of recording")
shutil.copy(fn, copy_fn)
print("Loading copy")
recording = VideoFileClip(copy_fn)
print("Trimming")
clip = recording.subclip(max((recording.duration - 10, 0)), recording.duration)
print("Saving clip")
clip.write_videofile("test.mp4", logger = None)
print("Closing and deleting frozen copy")
recording.close()
os.system("rm " + copy_fn)
Basically, the TS file will still have FFmpeg-compatible duration information even if copied mid-recording. I did a test, and there's about a 2 second delay before the live goes to file, which considering stream latency is probably fine. TYJ, we have a stage two!
A developer for RumBot pointed out to me that downloading clips from Rumble is rather round Robin's barn if the clip system is running on the streaming computer. Why not just grab the local video output straight from OBS? I've looked into this, and found a few possible options for how to send video from OBS to Python via plugins+libraries:
I'm kinda burned out on making the existing implementation work, but I do intend to implement this in the future.