From: Scott Worley Date: Mon, 6 Oct 2025 06:37:42 +0000 (-0700) Subject: Factor out begin_monitoring_file_size() X-Git-Url: http://git.scottworley.com/srec/commitdiff_plain/8209767e345e49708c246f71fd241c4cc69b70fd?hp=e5b09945620ccdc8759cf6fe8f885854b6837596 Factor out begin_monitoring_file_size() --- 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])