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

Bad Quality of Video on VideoOutput (QML) with YUV Format

    XMLWordPrintable

Details

    Description

      We have tested the YUV Format on QML VideoOutput with an QAbstractVideoSurface.The picture 'yuyv_source.png' is a screenshot of the source QVideoFrame and the 'yuyv_QVideoOutput.png' is a screenshot of the VideoOutput. There you can see a huge different in the quality of the image, where the QT rendering is pretty bad. In our application we need the YUV Rendering, because it is much faster an need les cpu performance, as the conversion from YUV in RGB on CPU. But with this quality the YUV rendering capability ist not useful.

       

      // C++
      QAbstractVideoSurface* m_videoSurface;
      
      m_surfaceFormat = QVideoSurfaceFormat(QSize(bmiHeader.biWidth,
                                                  bmiHeader.biHeight),
                                            QVideoFrame::Format_YUYV,
                                            QAbstractVideoBuffer::NoHandle);
                   m_surfaceFormat.setScanLineDirection(QVideoSurfaceFormat::TopToBottom);                m_surfaceFormat.setYCbCrColorSpace(QVideoSurfaceFormat::YCbCr_xvYCC709);
      
      QAbstractVideoSurface* ANTCapCamDevice::videoSurface() const
      {
          return m_videoSurface;
      }
      
      void ANTCapCamDevice::setVideoSurface(QAbstractVideoSurface* surface)
      {
          if((m_videoSurface != surface) &&
             (m_videoSurface) &&
             (m_videoSurface->isActive()))
          {
              m_videoSurface->stop();
          }
          m_videoSurface = surface;
      }
      
      void ANTCapCamDevice::onVideoFrameAvailable(QVideoFrame frame)
      {
          /** Variablen **/
          /** Start **/
      
          if(m_videoSurface != NULL)
          {
              m_videoSurface->present(frame);
          }
      
         // video.yuyv shown at http://rawpixels.net
         // video.yuyv is the source image (yuyv_source.png) 
         QFile file;
         file.setFileName(QLatin1String("C:\\video.yuyv"));
         file.open(QIODevice::ReadWrite|QIODevice::Truncate);
      
         frame.map(QAbstractVideoBuffer::ReadOnly);
         file.write((char*)frame.bits(),frame.width()*frame.height()*2);
         frame.unmap();
      }
      
      void ANTCapCamDevice::startPreview()
      {
          /** Variablen **/
          /** Start **/
      
          // Start surface
          putDebug << "Start VideoSurface" << m_videoSurface;
          putDebug << "VideoSurfaceFormat:" << m_surfaceFormat;
      
          if(m_videoSurface->isActive()) {m_videoSurface->stop();}
      
          if((m_videoSurface->start(m_surfaceFormat)) != true)
          {
              // Error
          }
          /** Ende **/
      }
      
      // QML
      // screenshot from VideoOutput is the image (yuyv_QVideoOutput.png) 
      
      VideoOutput {
         id: videoOutput_livestream
      
         width: (resizingOfLive)?(parent.width):(sourceRect.width)
         height: (resizingOfLive)?(parent.height):(sourceRect.height)
      
         anchors.centerIn: parent
         visible: true
      
         fillMode: VideoOutput.PreserveAspectFit
      
         source = classHandle.camDeviceListModel.get(activeCameraIndex).videoOutput
      }

       

      Attachments

        1. error.yuv
          1.32 MB
        2. yuyv_QVideoOutput.png
          yuyv_QVideoOutput.png
          59 kB
        3. yuyv_source.png
          yuyv_source.png
          51 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            valentyn.doroshchuk Valentyn Doroshchuk
            ant-solutions Andreas Hauser
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes