engine: Ctrl+Alt+R saves the configured clip length, not the whole buffer (found in the release-candidate run)
This commit is contained in:
1 parent
8a1b622505
commit
2d2a81167b
3 files changed
+30
-1
No files matched your search
@@ -376,6 +376,7 @@ class Recorder:
|
||||
encoder: str | None = None, device: str = "auto", notify=None, hotkeys: bool = False,
|
||||
drop_when_behind: bool = True, size: tuple | None = None, mark_dir: Path | None = None) -> None:
|
||||
self.clip, self.layout = clip, layout
|
||||
self.default_clip = 0 # seconds a save writes when it is not told (the global key); 0: all that is buffered
|
||||
self.mark_dir = mark_dir # SAVING_DIR when SmoovPlay runs it: before & after videos say they're being made
|
||||
self.size = (size[0] & ~1, size[1] & ~1) if size else None
|
||||
self._prep_lock = threading.Lock()
|
||||
@@ -443,7 +444,7 @@ class Recorder:
|
||||
print(f"[replay] keeping the last {_dur(self.length)}")
|
||||
if self._hotkeys_wanted:
|
||||
if self.length and self._hotkeys is None:
|
||||
keys = {"ctrl+alt+r": lambda: self.save(), "ctrl+alt+b": lambda: self.save("compare")}
|
||||
keys = {"ctrl+alt+r": lambda: self.save(length=self.default_clip or None), "ctrl+alt+b": lambda: self.save("compare")}
|
||||
if sys.platform.startswith("linux"):
|
||||
from .globalkeys import GlobalKeys # X11 key grab, or the Wayland portal
|
||||
self._hotkeys = GlobalKeys(keys)
|
||||
|
||||
@@ -722,6 +722,8 @@ def main() -> int:
|
||||
replay.set_length(settings.replay)
|
||||
elif key == "replay_save":
|
||||
replay.clip = settings.replay_save
|
||||
elif key == "replay_clip": # what the global Ctrl+Alt+R writes (R and Ctrl+1..6 in the window pass their own)
|
||||
replay.default_clip = settings.replay_clip
|
||||
elif key == "replay_layout":
|
||||
replay.layout = settings.replay_layout
|
||||
elif key == "look_clips": # the look in the SmoovPlay video too, drawn by the window at the stream's size
|
||||
@@ -729,6 +731,7 @@ def main() -> int:
|
||||
|
||||
settings.watch(replay_settings)
|
||||
replay_settings()
|
||||
replay_settings("replay_clip")
|
||||
|
||||
# --results: rewritten every 10 s while playing (the launcher's Stop ends the process without warning) and at
|
||||
# the end. `done` holds finished sessions; `live` the running Pipeline (dropped before a restart frees its GPU
|
||||
|
||||
@@ -19,3 +19,28 @@ def test_clip_never_longer_than_buffer():
|
||||
|
||||
def test_memory_for_ten_minutes_is_reasonable():
|
||||
assert 2500 < replay.memory_mb(600) < 3500
|
||||
|
||||
|
||||
def test_global_key_saves_the_default_clip_length_not_the_whole_buffer(monkeypatch):
|
||||
# Ctrl+Alt+R used to call save() with no length: a 60 s buffer with a 30 s default wrote 60 s.
|
||||
from framegen import globalkeys
|
||||
grabbed = {}
|
||||
|
||||
class FakeKeys:
|
||||
def __init__(self, keys): grabbed.update(keys)
|
||||
def start(self): pass
|
||||
def stop(self): pass
|
||||
|
||||
monkeypatch.setattr(globalkeys, "GlobalKeys", FakeKeys)
|
||||
rec = replay.Recorder(0, hotkeys=True, device="cpu")
|
||||
rec.default_clip = 30
|
||||
calls = []
|
||||
monkeypatch.setattr(rec, "save", lambda *a, **k: calls.append((a, k)))
|
||||
rec.length = 60
|
||||
rec.set_length(60) # turns the key grab on
|
||||
grabbed["ctrl+alt+r"]()
|
||||
assert calls == [((), {"length": 30})]
|
||||
rec.default_clip = 0
|
||||
grabbed["ctrl+alt+r"]()
|
||||
assert calls[-1] == ((), {"length": None})
|
||||
rec.close()
|
||||
Reference in new issue
Block a user