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

QVideoSink doesn't return valid image

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Not Evaluated Not Evaluated
    • None
    • 6.9.0
    • Multimedia
    • None
    • Qt Creator 16.02
    • Android

      Hello, i made the code, which works perfectly in Windows, but doesn't work in Android.
      The code in order to reproduse a bug:

      ...
                      pplayer->stop();
                      pplayer->setSource(url);
                      int attempts = 25;
                      bool isBroken = (pplayer->mediaStatus() == QMediaPlayer::LoadedMedia) &&
                                      (pplayer->mediaStatus() == QMediaPlayer::InvalidMedia);
                      while(isBroken && pplayer) {
                          QThread::msleep(20);
                          if (!attempts)
                              break;
                          attempts--;
                          isBroken = (pplayer->mediaStatus() == QMediaPlayer::LoadedMedia) &&
                                      (pplayer->mediaStatus() == QMediaPlayer::InvalidMedia);
                      }
                      if (pplayer->mediaStatus() == QMediaPlayer::InvalidMedia) {
                          qWarning() << "No preview for:" << abspath << " QMediaPlayer::InvalidMedia";
                          break;
                      }
                      m_alreadyFrame = false;
                      qWarning() << "before wait:";
                      pplayer->pause();
                      QCoreApplication::processEvents();
                      QThread::msleep(10);
                      attempts = 20;
                      isBroken = (pplayer->mediaStatus() == QMediaPlayer::InvalidMedia);
                      while (!m_alreadyFrame && !isBroken && attempts) {
                          QCoreApplication::processEvents();
                          QThread::msleep(10);
                          isBroken = (pplayer->mediaStatus() == QMediaPlayer::InvalidMedia);
                          attempts--;
                      }
                      qWarning() << "after wait:";
                      QCoreApplication::processEvents();
                      if (m_alreadyFrame) {
                          const QVideoFrame& vf = psink->videoFrame();
                          if (psink->videoFrame().map(QVideoFrame::ReadOnly)) {
                              image = psink->videoFrame().toImage();
                              psink->videoFrame().unmap();
                          }
                          else {
                              qWarning() << "QVideoFrame psink is not mapped";
                              break;
                          }
                          if (image.format() == QImage::Format_Invalid) {
                              qWarning() << "QImage::Format_Invalid";
                              isBroken = true;
                          }
                      }
                      pplayer->stop();
                      m_alreadyFrame = false;
                      if (isBroken || !attempts) {
                          qWarning() << "No preview for:" << abspath ;
                          qWarning() << "attempts:" << attempts << " isBroken:" << isBroken;
                          break;
                      }
                      //setState(TPrevStates::eIdle);
                      //break;
                      QString key = fileName;
                      qWarning() << "key is:" << key << " width is:" << image.width();
          QScopedPointer<QMediaPlayer> pplayer;     QImage image;     QVideoFrame frame;     pplayer.reset(new QMediaPlayer);     QScopedPointer<QVideoSink> psink;     //QVideoSink* psink = pplayer->videoSink();     psink.reset(new QVideoSink);     pplayer->setVideoOutput(psink.get());    connect(psink.get(), &QVideoSink::videoFrameChanged, this,                          [&](const QVideoFrame & _frame){                 if (!_frame.isValid()) {                     qWarning() << "frame is not valid";                     return;                 }                 qWarning() << "frame is valid";                 m_alreadyFrame = true;     });
      

       

        1. buglog.txt
          2 kB
        2. sample-mp4-file.mp4
          10.06 MB
        3. sample-mp4-file-1.mp4
          10.06 MB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            qtmultimediateam Qt Multimedia Team
            pechkin80 Yuriy Petin
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:

                There are no open Gerrit changes