QMediaPlayer only plays video not audio
-
In my program, a QMediaPlayer object is supposed to play an mp4 file that has video and audio. Video plays correct, but there is no sound.
My relevant code fragment is:
Player = QMediaPlayer() playWidget = QVideoWidget() Player.setVideoOutput(self.playWidget) Player.setSource(QUrl.fromLocalFile(mp4_filename)) Player.play()errorString() is empty after setting the source, however, activeAudioTrack() returns -1, indicating disabled audio.
Trying to force the audio to track 0 via
Player.setActiveAudioTrack(1)after setting the source produces the error
Cannot set active track without open source
I can not find any reference to this error message and don't understand what it means. A source is set, so why would it say there is no open source?
During playback of the mp4 file, the following messages are also generated on the console:
No support for codec h264 profile 100.
Failed setup for format vaapi: hwaccel initialisation returned error.I find these messages confusing because they seem to refer to video decoding problems, but the video is playing fine. I can't understand how these issues would be related to the audio.
My original mp4 file has the audio encoded in AAC; I created a version where the audio stream is MP3, but this made no difference.
I'm on a Manjaro Linux system with AMD CPU and GPU. I am using Python 3.11.6 and pyqt 6.6.1-1.
I would be grateful for any help. I'm out of ideas.
-
Hi and welcome to devnet,
Can you play this file successfully with ffmpeg ?