Update transcode_bench.py

This commit is contained in:
2025-10-12 20:47:26 +13:00
parent 469319a386
commit 5031aefdd1

View File

@@ -486,6 +486,7 @@ class Benchmark:
self.hwaccel_args = hwaccel_args
self.accel_name = accel_name
self.hw_decode = hw_decode
self.hit_nvenc_limit = False # Track if we hit NVIDIA session limit
# Determine HEVC encoder (hardware or software fallback)
self.hevc_encoder = self._detect_hevc_encoder()
@@ -578,9 +579,15 @@ class Benchmark:
avg_fps = sum(job.fps for job in jobs) / len(jobs) if jobs else 0.0
return True, avg_fps
# If failed, print first error for debugging
# If failed, check for NVENC session limit and print debug info
for job in jobs:
if not job.success and hasattr(job, 'stderr'):
# Check for NVIDIA session limit error
if 'OpenEncodeSessionEx failed' in job.stderr or 'incompatible client key' in job.stderr:
self.hit_nvenc_limit = True
print(f"✗ (NVIDIA concurrent session limit reached)")
return False, 0.0
# 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:
@@ -644,8 +651,8 @@ class Benchmark:
print(f"✗ (failed)")
high = mid - 1
# If we have headroom, try one more stream
if max_streams > 0:
# If we have headroom, try one more stream (unless we hit NVENC limit)
if max_streams > 0 and not self.hit_nvenc_limit:
print(f"Testing {max_streams + 1} simultaneous streams (checking headroom)...", end=' ', flush=True)
success, avg_fps = self.run_parallel_transcodes(max_streams + 1)
@@ -655,7 +662,8 @@ class Benchmark:
else:
if success:
print(f"✗ (avg {avg_fps:.1f} fps - below real-time)")
else:
elif not self.hit_nvenc_limit:
# Only print "failed" if we didn't already print NVENC limit message
print(f"✗ (failed)")
return max_streams
@@ -735,10 +743,21 @@ def main():
print(f"Transcode Task: 1080p H.264 → 720p H.265")
print(f"Maximum Simultaneous Streams: {max_streams}")
print(f"(at {args.min_fps} FPS or better)")
# Show NVIDIA session limit warning if hit
if benchmark.hit_nvenc_limit:
print("\n⚠ IMPORTANT: Hit NVIDIA driver concurrent session limit!")
print(" Your GPU may be capable of more streams, but NVIDIA")
print(" GeForce drivers artificially limit concurrent NVENC sessions.")
print(" Typical limits: 2-5 sessions (older), 5-8 (RTX 3000/4000)")
print(" Quadro/Tesla cards have unlimited sessions.")
print("=" * 60)
# Also output just the number for easy parsing
print(f"\nBenchmark Score: {max_streams}")
if benchmark.hit_nvenc_limit:
print("(Limited by NVIDIA driver, not hardware performance)")
finally:
# Cleanup