From 8209767e345e49708c246f71fd241c4cc69b70fd Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Sun, 5 Oct 2025 23:37:42 -0700 Subject: [PATCH 1/1] Factor out begin_monitoring_file_size() --- srec.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/srec.py b/srec.py index 944cc5c..64f2d07 100644 --- a/srec.py +++ b/srec.py @@ -74,13 +74,7 @@ def summarize_size(n: int) -> str: return str(n) -def on_start_recording(_: Gtk.Button, stack: Gtk.Stack) -> None: - global recording # pylint: disable=global-statement - assert recording is None - - filename = make_filename() - size_display = find_size_display(stack) - +def begin_monitoring_file_size(size_display: Gtk.Label, filename: str) -> None: def update_size_display() -> Any: try: size = summarize_size(os.stat(filename).st_size) @@ -90,6 +84,14 @@ def on_start_recording(_: Gtk.Button, stack: Gtk.Stack) -> None: return GLib.SOURCE_REMOVE if recording is None else GLib.SOURCE_CONTINUE GLib.timeout_add_seconds(1, update_size_display) + +def on_start_recording(_: Gtk.Button, stack: Gtk.Stack) -> None: + global recording # pylint: disable=global-statement + assert recording is None + + filename = make_filename() + begin_monitoring_file_size(find_size_display(stack), filename) + recording = Stream.start( ['ffmpeg', '-framerate', '25'] + video_source(stack) + ['-f', 'pulse', '-ac', '2', '-i', 'default', filename]) -- 2.50.1