I made a very simple PyQt5 desktop app that plays a video. It works fine in Pycharm, which makes me suspect the code is fine and that the problem has something to do with Windows.
I used Pyinstaller to create an .exe file. Unfortunately after running the .exe, the app crashes briefly after opening with the video grayed out instead of playing.
The portion of code used to create the video:
# create link to movie file movie_file = QtCore.QUrl.fromLocalFile('C:/Users/Owner/PycharmProjects/BF4 Deployment Timer/3d video background 2.mp4') media = QtMultimedia.QMediaContent(movie_file) # create video widget self.videoWidget = QtMultimediaWidgets.QVideoWidget() self.setCentralWidget(self.videoWidget) # media player object (video widget goes in media player) self.mediaPlayer = QtMultimedia.QMediaPlayer(None, QtMultimedia.QMediaPlayer.VideoSurface) self.mediaPlayer.setVideoOutput(self.videoWidget) # playlist self.playlist = QtMultimedia.QMediaPlaylist() self.playlist.setCurrentIndex(0) self.playlist.setPlaybackMode(QtMultimedia.QMediaPlaylist.Loop) self.playlist.addMedia(media) # add content to media player self.mediaPlayer.setPlaylist(self.playlist) self.mediaPlayer.play()
The command window gives me the following error message:
DirectShowPlayerService::doSetUrlSource: Unresolved error code 0x80004005 (Unspecified error)
I have not been able to learn enough googling or on stack overflow to fix it, and it's a real challenge since I'm a fairly new programmer.
A solution or ideas for what to try are much appreciated!
Apparently QtMultimedia from PyQt5 relies on DirectShowPlayerService, for which you need to install a DirectShow decoder, such as LAV Filters. So, it was in fact a problem on my machine and not the program.
A basic install of LAV filters solved my video playback problems.
I found this answer after google translating this Chinese site: https://blog.csdn.net/Wangguang_/article/details/93312629
LAV filters can be found here: https://www.videohelp.com/software/LAV-Filters
User contributions licensed under CC BY-SA 3.0