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 os
import threading import threading
import argparse import argparse
import signal
import atexit
from pathlib import Path from pathlib import Path
from typing import Optional, Tuple, List 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: class HardwareAcceleration:
"""Detect and configure hardware acceleration.""" """Detect and configure hardware acceleration."""
@@ -357,6 +369,7 @@ class TranscodeJob:
self.start_time = time.time() self.start_time = time.time()
self.process = subprocess.Popen( self.process = subprocess.Popen(
cmd, cmd,
stdin=subprocess.DEVNULL,
stdout=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.PIPE, stderr=subprocess.PIPE,
text=True text=True
@@ -439,9 +452,13 @@ class Benchmark:
# If failed, print first error for debugging # If failed, print first error for debugging
for job in jobs: for job in jobs:
if not job.success and hasattr(job, 'stderr'): if not job.success and hasattr(job, 'stderr'):
# Only print first few lines of error # Skip FFmpeg header and show actual error (last 10 non-empty lines)
error_lines = job.stderr.split('\n')[:5] error_lines = [line for line in job.stderr.split('\n') if line.strip()]
print(f"\n Debug - First error: {' '.join(error_lines)}") 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 break
return False, 0.0 return False, 0.0