From: Scott Worley Date: Mon, 6 Oct 2025 06:13:59 +0000 (-0700) Subject: Don't hang if ffmpeg exits on its own X-Git-Url: http://git.scottworley.com/srec/commitdiff_plain/5bb94ece79ceeb409f656352ed2e5623f7b32185?ds=sidebyside Don't hang if ffmpeg exits on its own --- diff --git a/srec.py b/srec.py index 50f311c..e905483 100644 --- a/srec.py +++ b/srec.py @@ -8,6 +8,7 @@ from dataclasses import dataclass from datetime import datetime import os import subprocess +import sys from typing import Any, Callable import gi @@ -25,8 +26,11 @@ class Recording: def stop(self) -> None: stdin = self.process.stdin assert stdin is not None - stdin.write(b'q') - stdin.flush() + try: + stdin.write(b'q') + stdin.flush() + except BrokenPipeError: + print("Stream already stopped?", file=sys.stderr) self.process.wait()