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

QMediaPayer reports wrong duration for ogg files on http server

    XMLWordPrintable

Details

    • Bug
    • Resolution: Out of scope
    • P2: Important
    • None
    • 5.13.1
    • Multimedia
    • None
    • Linux/X11

    Description

      I have a local nginx server and 4 sec ogg files with opus stream inside.
      I can try to play this file with VLC or for example with

      gst-launch-1.0 -m souphttpsrc location=http://127.0.0.1/test.ogg ! decodebin ! progressreport update-freq=1 ! audioconvert ! audioresample ! autoaudiosink
      

      Both report correct position and duration.

      But with QMediaPlayer only position is reported properly while duration looks somewhat random.

      If instead of http I load the same file with file:// it's duration is detected properly. So it's purely http-related problem.

      Also if I recode this file to mpeg4 container (still with opus) then duration is always reported correctly regardless of file source.
      I also tried to fully recode the file to pcm and back to ogg+opus to make sure it's not anyhow damaged but results are the same.

      Below is the code I used for testing

      #include <QDebug>
      #include <QMediaPlayer>
      #include <QtCore/QCoreApplication>
      
      using namespace std;
      
      int main(int argc, char* argv[])
      {
          QCoreApplication app(argc, argv);
      
          auto mp = new QMediaPlayer();
          mp->connect(mp, &QMediaPlayer::durationChanged, &app, [](qint64 d) {
              qDebug("duration=%lld", d);
          });
          mp->connect(mp, &QMediaPlayer::positionChanged, &app, [](qint64 p) {
              qDebug("position=%lld", p);
          });
          mp->connect(mp, &QMediaPlayer::mediaStatusChanged, &app, [](QMediaPlayer::MediaStatus status) {
              qDebug() << "status=" << status;
              if (status >= QMediaPlayer::EndOfMedia)
                  qApp->quit();
          });
      
          auto src = "http://localhost/test.ogg";
          QUrl url(src);
          qDebug() << url;
      
          mp->setMedia(QMediaContent(url));
          mp->play();
      
          return app.exec();
      }
      

      And output may look like following (no duration reported at all and position jumped to 0 in the end)

      QUrl("http://localhost/test.ogg")
      position=0
      status= QMediaPlayer::LoadingMedia
      position=0
      status= QMediaPlayer::BufferedMedia
      position=0
      position=839
      position=1792
      position=2743
      position=3691
      position=0
      status= QMediaPlayer::EndOfMedia
      

      or like this (wrong duration and weird position jumps)

      QUrl("http://localhost/test.ogg")
      position=0
      status= QMediaPlayer::LoadingMedia
      position=0
      duration=1533
      status= QMediaPlayer::BufferedMedia
      position=0
      status= QMediaPlayer::StalledMedia
      status= QMediaPlayer::BufferedMedia
      status= QMediaPlayer::StalledMedia
      status= QMediaPlayer::BufferedMedia
      position=0
      position=929
      position=1980
      position=3030
      position=4030
      position=1533
      status= QMediaPlayer::EndOfMedia
      

      Attachments

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

        Activity

          People

            valentyn.doroshchuk Valentyn Doroshchuk
            rion Rion
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes