Update transcode_bench.py

This commit is contained in:
2025-10-12 20:22:01 +13:00
parent b5d3863a48
commit f28536d007

View File

@@ -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