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

D3D11 Removing Device on QVideoSink save frame

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P2: Important
    • None
    • 6.5.0, 6.6.0, 6.7, 6.8
    • Multimedia
    • Windows 10.0.19044 Build 19044
      Lenovo Thinkpad E530
      NVIDIA GeForce GT 635M - Intel HD Graphics 4000
    • Windows
    • 30eb2b241 (dev), b63e9a465 (6.7), fec0682bc (tqtc/lts-6.5)

    Description

      the requirement is saving a frame of QML media player.
      I reported this problem here before but I have some updates and clarifications so decided to make a new one.

      first of all there isn't "QOpenGLContext current in a different thread" anymore, But there are kinda tow new error:

      damaged.mp4

       

      failed to get textures for frame true
      D3D11: Removing Device.
      Failed to map readback staging texture: COM error 0x887a0005: The GPU device instance has been suspended. Use GetDeviceRemovedReason to determine the appropriate action.

       

       

       

      crash.mp4

      qt.multimedia.ffmpeg.mediadataholder: AVStream duration -9223372036854775808 is invalid. Taking it from the metadata
      qt.multimedia.ffmpeg.mediadataholder: AVStream duration -9223372036854775808 is invalid. Taking it from the metadata
      D3D11: Removing Device.
      Failed to map readback staging texture: COM error 0x887a0005: The GPU device instance has been suspended. Use GetDeviceRemovedReason to determine the appropriate action.

      I found out this bug directly depends on what media is playing, so I attached 3 video files with full code of the sample application to be reproduceable :

      • good.mp4 : there isn't any problem
      • crash.mp4 : app crashes and saved frame is damaged
      • damaged.mp4 : app not crash but saved frame is damaged

       

      helper.h

       

      class Helper : public QObject
      {
          Q_OBJECT
          QML_ELEMENT
      public:
          explicit Helper(QObject *parent = nullptr);
          Q_INVOKABLE void setVideoSink(QObject *videoOutput);
          Q_INVOKABLE void saveCurrentFrame();
      private:
          QVideoSink *m_sink = nullptr;
      };
      

       

      helper.cpp

       

       
      void Helper::setVideoSink(QObject *videoOutput){
          m_sink = qvariant_cast<QVideoSink*>(videoOutput->property("videoSink"));
      }
      void Helper::saveCurrentFrame(){
          m_sink->videoFrame().toImage().save("frame.png");
      }
      

       

      Main.qml
      **

       

      Button {
          text: "save frame"
          onClicked: {
              helper.saveCurrentFrame()
           }
       }
      
      MediaPlayer {
              id: player
              audioOutput: AudioOutput {}
              videoOutput: videoOutput        onMediaStatusChanged: {
                  if (player.mediaStatus === MediaPlayer.BufferedMedia) {
                      helper.setVideoSink(videoOutput)
                  }
              }
       }

       

       

       

      Attachments

        1. crash.mp4
          1.23 MB
        2. d3d11.png
          d3d11.png
          204 kB
        3. D3D11-videoSink-frame.zip
          3 kB
        4. damaged.mp4
          1.50 MB
        5. damaged.png
          damaged.png
          66 kB
        6. good.mp4
          689 kB

        Issue Links

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

          Activity

            People

              johanseg Jøger Hansegård
              spfl97 Dawn Walker
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes