Added IPMPV_HWDEC env var, better error checking, 512k buffer when high latency

This commit is contained in:
Ignacio Rivero 2025-03-09 14:05:59 -03:00
parent 2c9059d4e6
commit a6045ba9ce
10 changed files with 5 additions and 3 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -5,6 +5,7 @@ import mpv
import threading
import time
import traceback
from utils import hwdec
class Player:
"""MPV player wrapper with IPMPV-specific functionality."""
@ -15,7 +16,7 @@ class Player:
self.player = mpv.MPV(
log_handler=self.error_check,
vo='gpu',
hwdec='auto-safe',
hwdec=hwdec if hwdec is not None else 'auto-safe',
demuxer_lavf_o='reconnect=1',
deinterlace='no',
keepaspect='no',
@ -44,7 +45,7 @@ class Player:
def error_check(self, loglevel, component, message):
"""Check for errors in MPV logs."""
print(f"[{loglevel}] {component}: {message}")
if loglevel == 'error' and (component == 'ffmpeg' or component == 'cplayer') and 'Failed' in message:
if loglevel == 'error' and (component == 'ffmpeg' or component == 'cplayer') and 'Failed to recognize file format' in message:
self.player.loadfile("./nosignal.png")
self.to_qt_queue.put({
'action': 'start_close'
@ -142,7 +143,7 @@ class Player:
self.player['video-sync'] = 'audio'
self.player['interpolation'] = 'no'
self.player['video-latency-hacks'] = 'yes' if self.low_latency else 'no'
self.player['stream-buffer-size'] = '4k' if self.low_latency else '128k'
self.player['stream-buffer-size'] = '4k' if self.low_latency else '512k'
return self.low_latency
def stop(self):

View File

@ -10,6 +10,7 @@ is_wayland = "WAYLAND_DISPLAY" in os.environ
osd_corner_radius = os.environ.get("IPMPV_CORNER_RADIUS")
ipmpv_retroarch_cmd = os.environ.get("IPMPV_RETROARCH_CMD")
m3u_url = os.environ.get('IPMPV_M3U_URL')
hwdec = os.environ.get('IPMPV_HWDEC')
def setup_environment():
"""Set up environment variables."""