Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. The QMediaPlayer aways crash when play a video

The QMediaPlayer aways crash when play a video

Scheduled Pinned Locked Moved Unsolved Qt for Python
6 Posts 2 Posters 1.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    LeoQT
    wrote on last edited by LeoQT
    #1

    Hi, there is a bug for the mediaplayer?
    I have try different video files and test the mdiaplayer.
    But just give a response: Process finished with exit code 132 (interrupted by signal 4: SIGILL)
    The some response on: Mac OS 11.15.1 intel CPU, and Windows 10 on ThinkPad X13 Gen2. on Python 3.8.2, 3.9.10
    I install PyQt6 in virtualenv. version as:

    PyQt6                     6.3.0
    PyQt6-Qt6                 6.3.0
    PyQt6-sip                 13.3.1
    

    Here is my test code, It's can play audio (.mp3) normally. But crashed any video play:

    #!/usr/bin/env python3
    # encoding: utf-8
    
    import sys
    from PyQt6.QtWidgets import QApplication
    from PyQt6.QtCore import QUrl
    from PyQt6.QtWidgets import QMainWindow
    from PyQt6.QtMultimedia import QMediaPlayer, QAudioOutput
    from PyQt6.QtMultimediaWidgets import QVideoWidget
    
    
    class MainWindow(QMainWindow):
        def __init__(self, parent=None):
            super(MainWindow, self).__init__(parent)
    
            self.resize(800, 600)
            self.setWindowTitle(self.tr('PyQt6 Video Player'))
    
            self.videoWidget = QVideoWidget()
            self.setCentralWidget(self.videoWidget)
    
            self.player = QMediaPlayer()
            self.audioOutput = QAudioOutput()
            self.player.setAudioOutput(self.audioOutput)
            self.player.setVideoOutput(self.videoWidget)
            self.player.mediaStatusChanged.connect(self.mediaStatusChanged)
            self.player.errorOccurred.connect(self.mediaErrorOccured)
            self.player.metaDataChanged.connect(self.metaChanged)
            self.audioOutput.setVolume(1.0)
    
            # http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4
            media = r'/Users/leo/Movies/big_buck_bunny.mp4'
            source = QUrl.fromLocalFile(media)
    
            # any video when call the setSource 
            # the application will be crashed immediately. 
            self.player.setSource(source) 
    
        def metaChanged(self, meta):
            print('meta:', meta)
    
        def mediaErrorOccured(self, error, message):
            print('error:', error, message)
    
        def mediaStatusChanged(self, status):
            print('status:', status)
            if status == QMediaPlayer.MediaStatus.LoadedMedia:
                self.videoWidget.show()
                self.player.play()
    
    
    if __name__ == '__main__':
        app = QApplication(sys.argv)
        window = MainWindow()
        window.show()
        app.exec()
    
    

    There is my console output:

    status: MediaStatus.LoadingMedia

    Process finished with exit code 132 (interrupted by signal 4: SIGILL)

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      Which version of PySide6 ?
      On which platform ?
      How did you install it ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • L Offline
        L Offline
        LeoQT
        wrote on last edited by
        #3

        Hi @SGaist
        I have updated these information and on PyQt6.2.3 or PyQt6.3. There is a same result.
        There was something wrong may be when the process reading the media file.
        Even it cann't read or read error content, It killed itself.
        I can receive the first signal from the mediaStatusChanged slot. and then crashed.
        Thanks.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Which version of Python are you using ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          L 1 Reply Last reply
          0
          • SGaistS SGaist

            Which version of Python are you using ?

            L Offline
            L Offline
            LeoQT
            wrote on last edited by
            #5

            @SGaist On Python 3.8.2 (mac OS) and 3.9.10 (Windows) any version as the same crash response.

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              I just tested your code on macOS 12.3.1, using python 3.10.4 (installed with conda but PyQt6 with pip) and the only issue is your metaChanged slot which signature is wrong. Other than that, it loaded the big buck bunny 10s 30MB video without issue.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved