From f28536d007168ea5a2db0afbb8f0612259d64b14 Mon Sep 17 00:00:00 2001 From: j Date: Sun, 12 Oct 2025 20:22:01 +1300 Subject: [PATCH] Update transcode_bench.py --- transcode_bench.py | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/transcode_bench.py b/transcode_bench.py index cde3036..e088acc 100755 --- a/transcode_bench.py +++ b/transcode_bench.py @@ -11,10 +11,22 @@ import tempfile import os import threading import argparse +import signal +import atexit from pathlib import Path from typing import Optional, Tuple, List +def restore_terminal(): + """Restore terminal settings.""" + if sys.platform != 'win32': + os.system('stty sane') + + +# Register cleanup function +atexit.register(restore_terminal) + + class HardwareAcceleration: """Detect and configure hardware acceleration.""" @@ -357,6 +369,7 @@ class TranscodeJob: self.start_time = time.time() self.process = subprocess.Popen( cmd, + stdin=subprocess.DEVNULL, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True @@ -439,9 +452,13 @@ class Benchmark: # If failed, print first error for debugging for job in jobs: if not job.success and hasattr(job, 'stderr'): - # Only print first few lines of error - error_lines = job.stderr.split('\n')[:5] - print(f"\n Debug - First error: {' '.join(error_lines)}") + # Skip FFmpeg header and show actual error (last 10 non-empty lines) + error_lines = [line for line in job.stderr.split('\n') if line.strip()] + if len(error_lines) > 10: + error_lines = error_lines[-10:] + print(f"\n Debug - Error output:") + for line in error_lines: + print(f" {line}") break return False, 0.0