Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-138463

Issue with QAudioDecoder and QAudioSink

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 6.9.1
    • Multimedia
    • None
    • OS: Linux
      Distro: ArchLinux
      Kernel: 6.15.4-arch2-1
      glibc version: 2.41
      ffmpeg version n7.1.1
    • Linux/Wayland

    Description

      So, I have this code
      ```cpp

      MainWindow::MainWindow(QWidget *parent)
          : QMainWindow(parent)
          , ui(new Ui::MainWindow)
      {
          qDebug() << "Qt version" << QT_VERSION_STR;
          ui->setupUi(this);
          QIODevice* device = nullptr;
          QAudioDecoder* decoder = new QAudioDecoder(this);
          decoder->setSource(QUrl::fromLocalFile("/home/klewy/song.mp3"));

          connect(decoder, &QAudioDecoder::bufferReady, this, [=]() mutable {
              QAudioBuffer buffer = decoder->read();
              if (buffer.isValid()) {
                  if (!audioSink)

      {                 QAudioFormat format = buffer.format();                 qDebug() << "Sample rate" << format.sampleRate();                 qDebug() << "Channel count" << format.channelCount();                 qDebug() << "Sample format" << format.sampleFormat();                 audioSink = new QAudioSink(format, this);                 device = audioSink->start();             }

                  const char* rawData = buffer.constData<char>();
                  device->write(rawData, buffer.byteCount());
              }
          });
          connect(decoder, &QAudioDecoder::finished, this, []

      {         qDebug() << "audio finished";     }

      );

          decoder->start();
      }
      ```
      Output:
      ```
      qt.multimedia.ffmpeg: Using Qt multimedia with FFmpeg version n7.1.1 GPL version 3 or later
      Failed to open VDPAU backend libvdpau_nvidia.so: cannot open shared object file: No such file or directory
      Input #0, mp3, from '/home/klewy/song.mp3':
        Metadata:
          title           : Slowed (Muzdark.net)
          artist          : Passo Bem Solto
          album           : Muzdark.net
          comment         : Muzdark.net
          genre           : Muzdark.net
          date            : 2024
        Duration: 00:01:56.14, start: 0.025056, bitrate: 321 kb/s
        Stream #0:0: Audio: mp3 (mp3float), 44100 Hz, stereo, fltp, 320 kb/s
            Metadata:
              encoder         : Lavc58.91
        Stream #0:1: Video: mjpeg (Baseline), yuvj444p(pc, bt470bg/unknown/unknown), 400x400 [SAR 72:72 DAR 1:1], 90k tbr, 90k tbn (attached pic)
            Metadata:
              title           : logo.jpg
              comment         : Other
      [mp3float @ 0x5595dbaf0800] Could not update timestamps for skipped samples.
      Sample rate 44100
      Channel count 2
      Sample format Float
      [mp3float @ 0x5595dbaf0800] Could not update timestamps for discarded samples.
      audio finished
      ```

      The problem is only the last about 10+- seconds are played. 
      As for the file, it is perfectly fine, I tried to play it with different tools and it worked, but just in case I'm attaching that exact .mp3 file
      I also get those mp3float suspicious warnings

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            qtmultimediateam Qt Multimedia Team
            klewy dah afds
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes