From c12a85ceec63829f822b39b7871286e335bf7288 Mon Sep 17 00:00:00 2001 From: pat-e Date: Sat, 25 Oct 2025 13:05:12 +0200 Subject: [PATCH] updated output-capture for JSON parsing --- MkvOpusEnc.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/MkvOpusEnc.py b/MkvOpusEnc.py index 07459f5..771a1c9 100644 --- a/MkvOpusEnc.py +++ b/MkvOpusEnc.py @@ -108,11 +108,14 @@ def convert_audio_track(stream_index, channels, temp_dir, source_file, should_do # Read stderr and print progress updates. The Tee class now handles '\r' correctly. stderr_output = "" - for line in iter(process.stderr.readline, ''): - stderr_output += line # Buffer the full output for parsing - # Print the line to stdout, clearing the line and using a carriage return. - # This will be handled by the Tee class. - sys.stdout.write(line.strip() + '\x1B[K\r') + with process.stderr as pipe: + for line in iter(pipe.readline, ''): + stderr_output += line # Buffer the full output for parsing + # Print the line to stdout, clearing the line and using a carriage return. + # This will be handled by the Tee class. + sys.stdout.write(line.strip() + '\x1B[K\r') + # After the loop, read any remaining data (the JSON block) + stderr_output += pipe.read() process.wait() # Wait for the process to terminate if process.returncode != 0: