'PyQt Video doesnt load?

Im trying to play a Video with PyQt. It plays the sound but not the Video, and i couldnt manage to find the mistake. Here is the part of the code where the MediaPlayer is created:

self.playlist = QMediaPlaylist()
        self.playlist.addMedia(QMediaContent(QUrl.fromLocalFile('moskaushort.mp4')))
        self.playlist.addMedia(QMediaContent(QUrl.fromLocalFile('Crabrave.mp4')))
        self.playlist.setCurrentIndex(1)
        self.player = QMediaPlayer(self.centralwidget, QMediaPlayer.VideoSurface)
        self.player.setPlaylist(self.playlist)
        self.VideoPlayer = QVideoWidget(self.centralwidget)
        self.VideoPlayer.setGeometry(QtCore.QRect(40, 190, 371, 231))
        font = QtGui.QFont()
        font.setStyleStrategy(QtGui.QFont.PreferDefault)
        self.VideoPlayer.setFont(font)
        self.VideoPlayer.setAccessibleName("")
        self.VideoPlayer.setAutoFillBackground(True)
        self.VideoPlayer.setObjectName("VideoPlayer")
        self.player.setVideoOutput(self.VideoPlayer)
        self.player.stateChanged.connect(self.mediaStateChanged)
        self.player.error.connect(self.handleError)

If you need more code i´ll post it.



Solution 1:[1]

Okay, just found out that im somewhat stupid and it was the most obvious mistake... I just installed the K-Lite Codec pack and it works ^^

Solution 2:[2]

If you are on windows, this worked for me for loading mp4 files:

os.environ['QT_MULTIMEDIA_PREFERRED_PLUGINS'] = 'windowsmediafoundation'

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Philipe
Solution 2 seb huart