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. QMediaPlayer only plays video not audio
Qt 6.11 is out! See what's new in the release blog

QMediaPlayer only plays video not audio

Scheduled Pinned Locked Moved Unsolved Qt for Python
2 Posts 2 Posters 1.1k 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.
  • ReaperXR Offline
    ReaperXR Offline
    ReaperX
    wrote on last edited by
    #1

    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.

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

      Hi and welcome to devnet,

      Can you play this file successfully with ffmpeg ?

      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