Add ffmpeg-python support and virtualization compatibility fixes

- Add comprehensive ffmpeg-python hidden imports to build.py and PyInstaller specs
- Include ffmpeg._run, ffmpeg._utils, ffmpeg.nodes, ffmpeg.streams, ffmpeg.filter modules
- Create MbetterClient_wrapper.sh for automatic virtualization detection
- Apply Mesa software rendering with transparency optimizations for VMs
- Fix VMware vmwgfx_dri.so crashes and Chromium shared memory permission errors
- Disable Vulkan extensions that cause VK_KHR_video_decode_queue errors
- Enable hardware acceleration detection for optimal performance on physical hardware
parent 54bbadd4
#!/bin/bash
# MbetterClient Comprehensive Compatibility Wrapper
# Automatically detects virtualization and hardware acceleration
# Applies Mesa GLX with transparency optimizations when needed
echo "=== MbetterClient Comprehensive Compatibility Wrapper ==="
echo "Detecting environment and applying optimal settings..."
echo ""
# Function to detect virtualization
detect_virtualization() {
local VIRT_TYPE=""
# VMware detection
if [ -f "/proc/driver/vmwgfx/version" ] || \
grep -q "VMware" /proc/scsi/scsi 2>/dev/null || \
lspci 2>/dev/null | grep -i vmware >/dev/null 2>&1; then
VIRT_TYPE="VMware"
fi
# VirtualBox detection
if [ -z "$VIRT_TYPE" ]; then
if [ -f "/proc/driver/vboxdrv" ] || \
lsmod 2>/dev/null | grep -q vbox || \
lspci 2>/dev/null | grep -i virtualbox >/dev/null 2>&1; then
VIRT_TYPE="VirtualBox"
fi
fi
# Other virtualization detection
if [ -z "$VIRT_TYPE" ]; then
if grep -q "QEMU" /proc/cpuinfo 2>/dev/null || \
[ -f "/dev/kvm" ] || \
systemd-detect-virt 2>/dev/null | grep -v "none" >/dev/null 2>&1; then
VIRT_TYPE="Other"
fi
fi
echo "$VIRT_TYPE"
}
# Function to test hardware acceleration
test_hw_acceleration() {
echo "Testing hardware acceleration availability..."
# Test 1: Check for NVIDIA GPU
if command -v nvidia-smi >/dev/null 2>&1; then
if nvidia-smi --query-gpu=name --format=csv,noheader >/dev/null 2>&1; then
echo "✓ NVIDIA GPU detected"
return 0
fi
fi
# Test 2: Check for AMD GPU
if lspci 2>/dev/null | grep -i "vga\|3d\|display" | grep -i "amd\|ati\|radeon" >/dev/null 2>&1; then
echo "✓ AMD GPU detected"
return 0
fi
# Test 3: Check for Intel integrated graphics
if lspci 2>/dev/null | grep -i "vga\|3d\|display" | grep -i "intel" >/dev/null 2>&1; then
echo "✓ Intel integrated graphics detected"
return 0
fi
# Test 4: Try to initialize OpenGL context
if command -v glxinfo >/dev/null 2>&1; then
if glxinfo 2>/dev/null | grep -q "OpenGL version"; then
echo "✓ OpenGL context available"
return 0
fi
fi
# Test 5: Check Vulkan availability
if command -v vulkaninfo >/dev/null 2>&1; then
if vulkaninfo --summary >/dev/null 2>&1; then
echo "✓ Vulkan available"
return 0
fi
fi
echo "✗ No hardware acceleration detected"
return 1
}
# Function to setup Mesa software rendering with optimizations
setup_mesa_software() {
echo "Setting up Mesa software rendering with transparency optimizations..."
# Create optimized temp directory
USER_TEMP="$HOME/.cache/MbetterClient"
mkdir -p "$USER_TEMP"
# Redirect all temp directories
export TMPDIR="$USER_TEMP"
export TEMP="$USER_TEMP"
export TMP="$USER_TEMP"
export XDG_RUNTIME_DIR="$USER_TEMP"
# Mesa software rendering optimizations
export LIBGL_ALWAYS_SOFTWARE=1
export MESA_GL_VERSION_OVERRIDE=3.3
export MESA_GLSL_VERSION_OVERRIDE=330
export LP_NUM_THREADS=$(nproc) # Use all CPU cores
export MESA_GLSL_CACHE_DISABLE=0 # Enable GLSL caching
export MESA_SHADER_CACHE_DISABLE=0 # Enable shader caching
export MESA_NO_VULKAN=1 # Disable Vulkan in Mesa
# Qt WebEngine configuration for software rendering
export QTWEBENGINE_CHROMIUM_FLAGS="--no-sandbox --disable-gpu --disable-gpu-sandbox --disable-dev-shm-usage --disable-software-rasterizer --disable-accelerated-video-decode --disable-accelerated-video-encode --disable-gpu-compositing --disable-gpu-rasterization --disable-vulkan --disable-vulkan-surface --disable-features=Vulkan --user-data-dir=$USER_TEMP --enable-transparent-visuals --disable-background-timer-throttling --disable-renderer-backgrounding --disable-vulkan-fallback"
# Qt configuration
export QT_OPENGL=software
export QTWEBENGINE_DISABLE_SANDBOX=1
export QT_QPA_PLATFORM=xcb
export QT_XCB_GL_INTEGRATION=xcb # Better transparency support
export QT_ENABLE_HIGHDPI_SCALING=0 # Better performance
# Vulkan disables
export VK_ICD_FILENAMES=""
export DISABLE_VULKAN=1
export MESA_VK_DISABLE=1
echo "✓ Mesa software rendering configured"
echo "✓ Transparency optimizations enabled"
echo "✓ Multi-threaded rendering: $LP_NUM_THREADS cores"
}
# Function to setup hardware acceleration
setup_hw_acceleration() {
echo "Setting up hardware acceleration..."
# Create temp directory
USER_TEMP="$HOME/.cache/MbetterClient"
mkdir -p "$USER_TEMP"
# Minimal Chromium flags for hardware acceleration
export QTWEBENGINE_CHROMIUM_FLAGS="--user-data-dir=$USER_TEMP"
# Qt configuration for hardware
export QT_QPA_PLATFORM=xcb
export QT_ENABLE_HIGHDPI_SCALING=1
echo "✓ Hardware acceleration enabled"
}
# Main detection and configuration logic
VIRT_TYPE=$(detect_virtualization)
HW_ACCEL=0
if [ -n "$VIRT_TYPE" ]; then
echo "✓ Virtualization detected: $VIRT_TYPE"
NEEDS_SOFTWARE=1
else
echo "✓ Physical hardware detected"
if test_hw_acceleration; then
HW_ACCEL=1
NEEDS_SOFTWARE=0
else
echo "⚠ Hardware acceleration not available or not working"
NEEDS_SOFTWARE=1
fi
fi
# Apply appropriate configuration
if [ $NEEDS_SOFTWARE -eq 1 ]; then
echo ""
echo "=== Applying Software Rendering Configuration ==="
setup_mesa_software
CONFIG_TYPE="Mesa Software Rendering (Optimized)"
else
echo ""
echo "=== Applying Hardware Acceleration Configuration ==="
setup_hw_acceleration
CONFIG_TYPE="Hardware Acceleration"
fi
# Final setup
echo ""
echo "=== Configuration Summary ==="
echo "Environment: $(if [ -n "$VIRT_TYPE" ]; then echo "$VIRT_TYPE VM"; else echo "Physical Hardware"; fi)"
echo "Acceleration: $(if [ $HW_ACCEL -eq 1 ]; then echo "Hardware"; else echo "Software"; fi)"
echo "Rendering: $CONFIG_TYPE"
echo "Temp Directory: $USER_TEMP"
echo ""
# Verify binary exists
if [ ! -f "./MbetterClient" ]; then
echo "ERROR: MbetterClient binary not found in current directory"
echo "Please run this script from the directory containing MbetterClient"
exit 1
fi
echo "Starting MbetterClient..."
echo "=========================================="
# Execute with all configured settings
exec ./MbetterClient "$@"
\ No newline at end of file
...@@ -165,30 +165,48 @@ def collect_hidden_imports() -> List[str]: ...@@ -165,30 +165,48 @@ def collect_hidden_imports() -> List[str]:
'PyQt6.QtMultimediaWidgets', 'PyQt6.QtMultimediaWidgets',
'PyQt6.QtWebEngineWidgets', 'PyQt6.QtWebEngineWidgets',
'PyQt6.QtWebChannel', 'PyQt6.QtWebChannel',
# Flask and web dependencies # Flask and web dependencies
'flask', 'flask',
'flask_login', 'flask_login',
'flask_jwt_extended', 'flask_jwt_extended',
'werkzeug.security', 'werkzeug.security',
'jinja2', 'jinja2',
# SQLAlchemy # SQLAlchemy
'sqlalchemy', 'sqlalchemy',
'sqlalchemy.sql.default_comparator', 'sqlalchemy.sql.default_comparator',
# Requests and HTTP # Requests and HTTP
'requests', 'requests',
'urllib3', 'urllib3',
# Logging # Logging
'loguru', 'loguru',
# File watching for template system # File watching for template system
'watchdog', 'watchdog',
'watchdog.observers', 'watchdog.observers',
'watchdog.events', 'watchdog.events',
# FFmpeg-python and related modules
'ffmpeg',
'ffmpeg._run',
'ffmpeg._utils',
'ffmpeg.nodes',
'ffmpeg.streams',
'ffmpeg.filter',
'ffmpeg.filter.graph',
'ffmpeg.input',
'ffmpeg.output',
'ffmpeg.run',
'ffmpeg.run_async',
'ffmpeg.overwrite_output',
'ffmpeg.concat',
'ffmpeg.filter_complex',
'ffmpeg.global_args',
'ffmpeg.merge_outputs',
# Other dependencies # Other dependencies
'packaging', 'packaging',
'pkg_resources', 'pkg_resources',
......
...@@ -12,9 +12,16 @@ a = Analysis( ...@@ -12,9 +12,16 @@ a = Analysis(
datas=[], datas=[],
hiddenimports=[ hiddenimports=[
'PyQt6.QtCore', 'PyQt6.QtCore',
'PyQt6.QtGui', 'PyQt6.QtGui',
'PyQt6.QtWidgets', 'PyQt6.QtWidgets',
'netifaces', 'netifaces',
'ffmpeg',
'ffmpeg._run',
'ffmpeg._utils',
'ffmpeg.nodes',
'ffmpeg.streams',
'ffmpeg.filter',
'ffmpeg.filter.graph',
], ],
hookspath=[], hookspath=[],
hooksconfig={}, hooksconfig={},
......
...@@ -12,9 +12,16 @@ a = Analysis( ...@@ -12,9 +12,16 @@ a = Analysis(
datas=[], datas=[],
hiddenimports=[ hiddenimports=[
'PyQt6.QtCore', 'PyQt6.QtCore',
'PyQt6.QtGui', 'PyQt6.QtGui',
'PyQt6.QtWidgets', 'PyQt6.QtWidgets',
'netifaces', 'netifaces',
'ffmpeg',
'ffmpeg._run',
'ffmpeg._utils',
'ffmpeg.nodes',
'ffmpeg.streams',
'ffmpeg.filter',
'ffmpeg.filter.graph',
], ],
hookspath=[], hookspath=[],
hooksconfig={}, hooksconfig={},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment