Add NVIDIA support for FFmpeg in Docker and enhance chat rendering functionality
All checks were successful
Publish Twitch Archive Container / publish (push) Successful in 7m36s

- Introduced a new docker-compose.nvidia.yml for NVIDIA GPU support.
- Updated dockerstart.bat to allow optional NVIDIA runtime.
- Enhanced ContentDownloader to manage chat rendering status and font settings.
- Improved hardware acceleration detection in utils.py.
- Added tests for hardware acceleration and chat rendering behavior.

Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
MaddoScientisto 2026-04-25 12:28:59 +02:00
commit ec44981a9d
8 changed files with 226 additions and 18 deletions

View file

@ -269,20 +269,57 @@ def detect_hardware_acceleration(hwaccel_config: str, os_type: str) -> Optional[
if hwaccel_config in ['nvenc', 'qsv', 'amf', 'vaapi']:
return hwaccel_config
# Auto-detect: try to determine available hardware
# Auto-detect: choose only hardware we can reasonably prove is present.
if hwaccel_config == 'auto':
# On Windows, NVIDIA is most common
if os_type == 'windows':
# Could check for nvidia-smi, but just return 'auto' for ffmpeg to decide
return 'auto'
else:
# On Linux, VAAPI is common for Intel/AMD, or NVENC for NVIDIA
# Let ffmpeg auto-detect
return 'auto'
if is_nvidia_runtime_available():
return 'nvenc'
if is_vaapi_runtime_available():
return 'vaapi'
return 'none'
return None
def is_nvidia_runtime_available() -> bool:
"""Return True when the current runtime appears to expose an NVIDIA GPU."""
visible_devices = os.getenv('NVIDIA_VISIBLE_DEVICES', '').strip().lower()
if visible_devices in {'void', 'none'}:
return False
if visible_devices and visible_devices != 'all':
return True
if shutil.which('nvidia-smi'):
return True
return any(
os.path.exists(device_path)
for device_path in ('/dev/nvidiactl', '/dev/nvidia0', '/dev/nvidia-modeset')
)
def is_vaapi_runtime_available() -> bool:
"""Return True when Linux VAAPI render nodes are present."""
return any(
os.path.exists(device_path)
for device_path in ('/dev/dri/renderD128', '/dev/dri/card0')
)
def resolve_hwaccel_type(hwaccel_type: Optional[str], os_type: str) -> Optional[str]:
"""Return a safe hardware acceleration choice for the current runtime."""
if hwaccel_type in (None, 'none'):
return 'none'
if hwaccel_type == 'nvenc':
return 'nvenc' if is_nvidia_runtime_available() else 'none'
if hwaccel_type == 'vaapi':
return 'vaapi' if is_vaapi_runtime_available() else 'none'
# Leave explicit QSV/AMF unchanged for non-container users; container auto-detect no longer picks them blindly.
return hwaccel_type
def get_hwaccel_encoder(hwaccel_type: str) -> str:
"""
Get the appropriate hardware-accelerated encoder for the given acceleration type.