@@ -889,7 +889,7 @@ def __init__(self):
889
889
self .recording_animation = None
890
890
self .opacity_effect = None
891
891
892
- # Initialize VLC
892
+ # Initialize VLC with basic instance first
893
893
print ("Debug: Initializing VLC instance" )
894
894
try :
895
895
if getattr (sys , 'frozen' , False ):
@@ -906,12 +906,21 @@ def __init__(self):
906
906
907
907
print (f"Debug: VLC plugin path set to: { plugin_path } " )
908
908
909
- # Initialize VLC without arguments
910
- self .instance = vlc .Instance ()
909
+ # Initialize VLC with hardware acceleration parameters
910
+ vlc_args = [
911
+ # Enable hardware decoding
912
+ '--avcodec-hw=any' , # Try any hardware acceleration method
913
+ '--file-caching=1000' , # Increase file caching for smoother playback
914
+ '--network-caching=1000' , # Increase network caching for streaming
915
+ '--no-video-title-show' , # Don't show the video title
916
+ '--no-snapshot-preview' , # Don't show snapshot previews
917
+ ]
918
+
919
+ self .instance = vlc .Instance (vlc_args )
911
920
if not self .instance :
912
921
raise RuntimeError ("VLC Instance creation returned None" )
913
922
914
- print ("Debug: VLC instance created successfully" )
923
+ print ("Debug: VLC instance created successfully with hardware acceleration " )
915
924
916
925
self .media_player = self .instance .media_player_new ()
917
926
if not self .media_player :
@@ -923,26 +932,44 @@ def __init__(self):
923
932
print (f"Error initializing VLC: { str (e )} " )
924
933
raise RuntimeError (f"Failed to initialize VLC: { str (e )} " )
925
934
926
-
927
-
928
935
# Then setup UI
929
936
self .setup_ui ()
930
937
931
938
# Update to use config for last server
932
939
self .server_combo .setCurrentIndex (self .config .get ('last_server' , 0 ))
933
940
934
- #Set player window - with proper type conversion
935
-
936
- if sys .platform .startswith ('linux' ):
937
- handle = self .video_frame .winId ().__int__ ()
938
- if handle is not None :
939
- self .media_player .set_xwindow (handle )
940
- elif sys .platform == "win32" :
941
- self .media_player .set_hwnd (self .video_frame .winId ().__int__ ())
942
- elif sys .platform == "darwin" :
943
- self .media_player .set_nsobject (self .video_frame .winId ().__int__ ())
944
-
945
-
941
+ # Now configure hardware acceleration after UI is set up
942
+ try :
943
+ # Set player window - with proper type conversion
944
+ if sys .platform .startswith ('linux' ):
945
+ handle = self .video_frame .winId ().__int__ ()
946
+ if handle is not None :
947
+ self .media_player .set_xwindow (handle )
948
+ elif sys .platform == "win32" :
949
+ self .media_player .set_hwnd (self .video_frame .winId ().__int__ ())
950
+ elif sys .platform == "darwin" :
951
+ self .media_player .set_nsobject (self .video_frame .winId ().__int__ ())
952
+
953
+ # Set hardware decoding to automatic
954
+ if hasattr (self .media_player , 'set_hardware_decoding' ):
955
+ self .media_player .set_hardware_decoding (True )
956
+ else :
957
+ # Alternative method for older VLC Python bindings
958
+ self .media_player .video_set_key_input (False )
959
+ self .media_player .video_set_mouse_input (False )
960
+
961
+ # Add a timer to check which hardware acceleration method is being used
962
+ # This will check after playback starts
963
+ self .hw_check_timer = QTimer ()
964
+ self .hw_check_timer .setSingleShot (True )
965
+ self .hw_check_timer .timeout .connect (self .check_hardware_acceleration )
966
+ self .hw_check_timer .start (5000 ) # Check after 5 seconds of playback
967
+
968
+ print ("Debug: Hardware acceleration configured for VLC" )
969
+
970
+ except Exception as e :
971
+ print (f"Warning: Could not configure hardware acceleration: { str (e )} " )
972
+ print ("Continuing without hardware acceleration" )
946
973
947
974
def setup_paths (self ):
948
975
"""Setup application paths for resources"""
@@ -2528,6 +2555,52 @@ def filter_channels(self, search_text):
2528
2555
channel_name = item .text ().lower ()
2529
2556
self .channel_list .setRowHidden (row , search_text not in channel_name )
2530
2557
2558
+ def check_hardware_acceleration (self ):
2559
+ """Check and print which hardware acceleration method is being used"""
2560
+ if not self .media_player :
2561
+ return
2562
+
2563
+ # This only works if a media is playing
2564
+ if not self .media_player .is_playing ():
2565
+ return
2566
+
2567
+ try :
2568
+ # Get media statistics - handle different VLC Python binding versions
2569
+ media = self .media_player .get_media ()
2570
+ if not media :
2571
+ print ("No media currently playing" )
2572
+ return
2573
+
2574
+ # Different versions of python-vlc have different APIs for get_stats
2575
+ try :
2576
+ # Newer versions (direct call)
2577
+ stats = media .get_stats ()
2578
+ print ("VLC Playback Statistics:" )
2579
+ print (f"Decoded video blocks: { stats .decoded_video } " )
2580
+ print (f"Displayed pictures: { stats .displayed_pictures } " )
2581
+ print (f"Lost pictures: { stats .lost_pictures } " )
2582
+ except TypeError :
2583
+ # Older versions (requiring a stats object parameter)
2584
+ stats = vlc .MediaStats ()
2585
+ media .get_stats (stats )
2586
+ print ("VLC Playback Statistics:" )
2587
+ print (f"Decoded video blocks: { stats .decoded_video } " )
2588
+ print (f"Displayed pictures: { stats .displayed_pictures } " )
2589
+ print (f"Lost pictures: { stats .lost_pictures } " )
2590
+
2591
+ # Check if hardware decoding is enabled
2592
+ if hasattr (self .media_player , 'get_role' ):
2593
+ print (f"Media player role: { self .media_player .get_role ()} " )
2594
+
2595
+ # Try to get more detailed hardware acceleration info
2596
+ print ("Hardware acceleration is active if you see 'Using ... for hardware decoding' in the logs above" )
2597
+ print ("For more details, run VLC with the same content and use:" )
2598
+ print ("Tools -> Messages -> Info to see which decoder is being used" )
2599
+
2600
+ except Exception as e :
2601
+ print (f"Error checking hardware acceleration: { e } " )
2602
+ print (f"Traceback: { traceback .format_exc ()} " )
2603
+
2531
2604
2532
2605
2533
2606
class EPGDialog (QDialog ):
0 commit comments