Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QMediaPlayer says !hasAudio
Forum Updated to NodeBB v4.3 + New Features

QMediaPlayer says !hasAudio

Scheduled Pinned Locked Moved Unsolved General and Desktop
11 Posts 5 Posters 1.3k 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.
  • W Offline
    W Offline
    whatabout
    wrote on last edited by
    #1

    I have an MP4 file that I know has audio. FFplay and mplayer play its audio. It exists.

    However when I attempt to play it back with QMediaPlayer in a QVideoWidget, I'm told by QMediaPlay that it doesn't have an audio stream.

    player->setURL(localFileURL);
    if (player->hasAudio()) cout << "yes"; else cout<<"no";
    

    I've also tried putting the play() call before the hasAudio check and it's the same result.

    Is QMediaPlayer not able to play video files that have audio?

    sierdzioS Ronel_qtmasterR 2 Replies Last reply
    0
    • W whatabout

      I have an MP4 file that I know has audio. FFplay and mplayer play its audio. It exists.

      However when I attempt to play it back with QMediaPlayer in a QVideoWidget, I'm told by QMediaPlay that it doesn't have an audio stream.

      player->setURL(localFileURL);
      if (player->hasAudio()) cout << "yes"; else cout<<"no";
      

      I've also tried putting the play() call before the hasAudio check and it's the same result.

      Is QMediaPlayer not able to play video files that have audio?

      sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      @whatabout Some ideas: verify the path with QFileInfo::exists(). Check the docs if player accepts local filesystem URLs. Check if your local URL is correct (starts with file://). Check if the audo stream type is supported by Qt.

      (Z(:^

      W 1 Reply Last reply
      1
      • sierdzioS sierdzio

        @whatabout Some ideas: verify the path with QFileInfo::exists(). Check the docs if player accepts local filesystem URLs. Check if your local URL is correct (starts with file://). Check if the audo stream type is supported by Qt.

        W Offline
        W Offline
        whatabout
        wrote on last edited by whatabout
        #3

        @sierdzio
        The video part of it plays just fine.
        The same goes for a second file that I tried. Video plays without sound.

        File 1 has this audio:
        Stream #0:10x2: Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s (default)

        File 2 has this audio:
        Stream #0:1: Audio: pcm_u8, 11024 Hz, 1 channels, u8, 88 kb/s

        If QMediaPlayer doesn't support these basic types it will be fairly useless to me.

        I checked and my Debian distro has the gstreamer "basic" plugins for audio.

        sierdzioS 1 Reply Last reply
        0
        • W whatabout

          I have an MP4 file that I know has audio. FFplay and mplayer play its audio. It exists.

          However when I attempt to play it back with QMediaPlayer in a QVideoWidget, I'm told by QMediaPlay that it doesn't have an audio stream.

          player->setURL(localFileURL);
          if (player->hasAudio()) cout << "yes"; else cout<<"no";
          

          I've also tried putting the play() call before the hasAudio check and it's the same result.

          Is QMediaPlayer not able to play video files that have audio?

          Ronel_qtmasterR Offline
          Ronel_qtmasterR Offline
          Ronel_qtmaster
          wrote on last edited by
          #4

          @whatabout I think you have to install audio codecs on windows so that it supports all audios types

          sierdzioS 1 Reply Last reply
          0
          • Ronel_qtmasterR Ronel_qtmaster

            @whatabout I think you have to install audio codecs on windows so that it supports all audios types

            sierdzioS Offline
            sierdzioS Offline
            sierdzio
            Moderators
            wrote on last edited by
            #5

            @Ronel_qtmaster said in QMediaPlayer says !hasAudio:

            @whatabout I think you have to install audio codecs on windows so that it supports all audios types

            OP is not on Windows...

            (Z(:^

            1 Reply Last reply
            0
            • W whatabout

              @sierdzio
              The video part of it plays just fine.
              The same goes for a second file that I tried. Video plays without sound.

              File 1 has this audio:
              Stream #0:10x2: Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s (default)

              File 2 has this audio:
              Stream #0:1: Audio: pcm_u8, 11024 Hz, 1 channels, u8, 88 kb/s

              If QMediaPlayer doesn't support these basic types it will be fairly useless to me.

              I checked and my Debian distro has the gstreamer "basic" plugins for audio.

              sierdzioS Offline
              sierdzioS Offline
              sierdzio
              Moderators
              wrote on last edited by
              #6

              @whatabout said in QMediaPlayer says !hasAudio:

              I checked and my Debian distro has the gstreamer "basic" plugins for audio.

              OK that is probably not enough, see: https://doc.qt.io/qt-6/videooverview.html#supported-media-formats

              (Z(:^

              W 1 Reply Last reply
              0
              • sierdzioS sierdzio

                @whatabout said in QMediaPlayer says !hasAudio:

                I checked and my Debian distro has the gstreamer "basic" plugins for audio.

                OK that is probably not enough, see: https://doc.qt.io/qt-6/videooverview.html#supported-media-formats

                W Offline
                W Offline
                whatabout
                wrote on last edited by whatabout
                #7

                @sierdzio
                On x86_64 Debian Linux, I installed "*gstreamer*", which includes all available audio plugins, as well as multimedia-audio-plugins, and there's still no audio detected for these videos. I see no evidence that any audio format is supported.

                I might be willing to change the distro as an experiment, but I think the fault is with Qt 6.

                C 1 Reply Last reply
                0
                • W whatabout

                  @sierdzio
                  On x86_64 Debian Linux, I installed "*gstreamer*", which includes all available audio plugins, as well as multimedia-audio-plugins, and there's still no audio detected for these videos. I see no evidence that any audio format is supported.

                  I might be willing to change the distro as an experiment, but I think the fault is with Qt 6.

                  C Offline
                  C Offline
                  ChrisW67
                  wrote on last edited by
                  #8

                  Is your code using the FFMpeg or GStreamer backend? FFMpeg is the default on most platforms in current Qt6 versions.

                  What happens if you use the other backend?

                  What is the output from this with QT_MEDIA_BACKEND=ffmpeg and QT_MEDIA_BACKEND=gstreamer?

                  #include <QCoreApplication>
                  #include <QMediaFormat>
                  #include <QDebug>
                  
                  int main(int argc, char **argv) {
                          QCoreApplication app(argc, argv);
                  
                          QMediaFormat format(QMediaFormat::MPEG4);
                          //QMediaFormat format(QMediaFormat::Matroska);
                          foreach(auto audioCodec, format.supportedAudioCodecs(QMediaFormat::Decode)) {
                                  qDebug() << QMediaFormat::audioCodecName(audioCodec) << QMediaFormat::audioCodecDescription(audioCodec);
                          }
                          return 0;
                  }
                  

                  I would expect that AAC is in the list for FFMpeg backend. The 8-bit PCM I would not be so sure about.

                  W 1 Reply Last reply
                  1
                  • C ChrisW67

                    Is your code using the FFMpeg or GStreamer backend? FFMpeg is the default on most platforms in current Qt6 versions.

                    What happens if you use the other backend?

                    What is the output from this with QT_MEDIA_BACKEND=ffmpeg and QT_MEDIA_BACKEND=gstreamer?

                    #include <QCoreApplication>
                    #include <QMediaFormat>
                    #include <QDebug>
                    
                    int main(int argc, char **argv) {
                            QCoreApplication app(argc, argv);
                    
                            QMediaFormat format(QMediaFormat::MPEG4);
                            //QMediaFormat format(QMediaFormat::Matroska);
                            foreach(auto audioCodec, format.supportedAudioCodecs(QMediaFormat::Decode)) {
                                    qDebug() << QMediaFormat::audioCodecName(audioCodec) << QMediaFormat::audioCodecDescription(audioCodec);
                            }
                            return 0;
                    }
                    

                    I would expect that AAC is in the list for FFMpeg backend. The 8-bit PCM I would not be so sure about.

                    W Offline
                    W Offline
                    whatabout
                    wrote on last edited by whatabout
                    #9

                    @ChrisW67 Here's the output when I use the ffmpeg backend:

                    Checking HW acceleration for decoder mjpeg
                    [AVHWDeviceContext @ 0x563c30037200] libva: /usr/lib/x86_64-linux-gnu/dri/iHD_drv_video.so init failed
                        Checking HW context: vaapi
                        Using above hw context.
                    Can't obtain QAudioOutput.
                    [mjpeg @ 0x563c30032100] get_buffer() failed
                    [mjpeg @ 0x563c30032100] get_buffer() failed
                    [mjpeg @ 0x563c30032100] get_buffer() failed
                    [mjpeg @ 0x563c30032100] get_buffer() failed
                    [mjpeg @ 0x563c30032100] get_buffer() failed
                    [mjpeg @ 0x563c30032100] get_buffer() failed
                    [mjpeg @ 0x563c30032100] get_buffer() failed
                    [mjpeg @ 0x563c30032100] get_buffer() failed
                    [mjpeg @ 0x563c30032100] get_buffer() failed
                    [mjpeg @ 0x563c30032100] get_buffer() failed
                    [mjpeg @ 0x563c30032100] get_buffer() failed
                    [mjpeg @ 0x563c30032100] get_buffer() failed
                    [mjpeg @ 0x563c30032100] get_buffer() failed
                    [mjpeg @ 0x563c30032100] get_buffer() failed
                    [mjpeg @ 0x563c30032100] get_buffer() failed
                    [mjpeg @ 0x563c30032100] get_buffer() failed
                    [mjpeg @ 0x563c30032100] get_buffer() failed
                    [mjpeg @ 0x563c30032100] get_buffer() failed
                    [mjpeg @ 0x563c30032100] get_buffer() failed
                    [mjpeg @ 0x563c30032100] get_buffer() failed
                    [mjpeg @ 0x563c30032100] get_buffer() failed
                    [mjpeg @ 0x563c30032100] get_buffer() failed
                    [mjpeg @ 0x563c30032100] get_buffer() failed
                    [mjpeg @ 0x563c30032100] get_buffer() failed
                    [mjpeg @ 0x563c30032100] get_buffer() failed
                    [mjpeg @ 0x563c30032100] get_buffer() failed
                    [mjpeg @ 0x563c30032100] get_buffer() failed
                    [mjpeg @ 0x563c30032100] get_buffer() failed
                    [mjpeg @ 0x563c30032100] get_buffer() failed
                    [mjpeg @ 0x563c30032100] get_buffer() failed
                    [mjpeg @ 0x563c30032100] get_buffer() failed
                    [mjpeg @ 0x563c30032100] get_buffer() failed
                    [mjpeg @ 0x563c30032100] get_buffer() failed
                        failed to get textures for frame true
                    [AVHWFramesContext @ 0x7f3fc8015540] Failed to read image from surface 0x4000002: 20 (the requested function is not implemented).
                    Error transferring the data to system memory: -5
                    could not map data of QVideoFrame for upload
                    Invalid texture upload for 0x563c30145c40 layer=0 mip=0
                    Invalid texture upload for 0x7f4068001460 layer=0 mip=0
                    Segmentation fault
                    
                    

                    I would note that FFplay is what I use the play video files on a daily basis, so I know that ffmpeg/ffplay work reliably on their own. Somehow Qt6 isn't using it correctly.

                    As for gstreamer that's what it's using by default.

                    1 Reply Last reply
                    0
                    • W Offline
                      W Offline
                      whatabout
                      wrote on last edited by whatabout
                      #10

                      Does anyone know who it is at Qt corporate that is developing QMediaPlayer? They need to be alerted about these problems.

                      JonBJ 1 Reply Last reply
                      0
                      • W whatabout

                        Does anyone know who it is at Qt corporate that is developing QMediaPlayer? They need to be alerted about these problems.

                        JonBJ Online
                        JonBJ Online
                        JonB
                        wrote on last edited by
                        #11

                        @whatabout You would raise a bug report at https://bugreports.qt.io/

                        1 Reply Last reply
                        2

                        • Login

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