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

Color-shift during painting a QVideoFrame to a QVideoFrame-based QImage using QPainter and strange solution

    XMLWordPrintable

Details

    • Windows

    Description

      Reproducer attached. Environment is Windows (10 or 11), Qt6.5. Steps to reproduce:

      1. Run the sample once first. The there should be a debug and a release folder generated in source folder. Depending on the build mode, one of the folder should have some generated files in it.
      2. Put some videos in that folder.
      3. Go to producer.h, line 32, and change m_videoPath to the video.
      4. Run the sample again and click 'Play' button. Then video should play in main window. And video frames should be copied to sub window every certain time interval.
      5. The issue is that the color of video frame in sub window is obviously shifted to red/yellow end.

      There are 2 solutions:
      1. Use Vulkan as graphics API. All the other APIs ,including Windows default D3D11, shows the color-shift behavior.
      2. Very strangely, uncomment the '(void)sub_video_frame.toImage();'at line 74. I don't know what it does and how it solves the issue.

      The processes of frame copy and (I think) where to look at is all in producer.cpp, especially method 'handleVideoFrameChanged'. It is called continuously as long as video is playing. All the other methods are not relevant I think. The detailed processes is:
      1. A blank QVideoFrame 'sub_video_frame' is created with the same size and format as incoming QVideoFrame. Line 58.
      2. 'sub_video_frame' is mapped. Line 59.
      3. A QImage 'm_videoFrameImage' is assigned to the incoming QVideoFrame. Line 63.
      4. A blank QImage 'subImage' is created from the blank QVideoFrame 'sub_video_frame', with the same format and size. Line 67.
      5. A QPainter is used to paint QImage 'm_videoFrameImage' to 'subImage', and consequently 'sub_video_frame' is also modified. By line 71, 'sub_video_frame' should be the same as the incoming frame.
      6. Assign 'sub_video_frame' to the videoSink of media player in sub window. By line 76, the 'frame copy' is done.
      7. Finally unmap 'sub_video_frame' at line 77.

      Notice that the program is running with 'windows' backend. I could not get FFMPEG work with QML MediaPlayer due to multiple bugs. If anyone can get FFMPEG work and tested with, that will be very much appreciated.

      Attachments

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

        Activity

          People

            anmaatta Antti Määttä
            luqiaochen Luqiao Chen
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes