0

Calling QVideoWidget with self.mediaPlayer.setVideoOutput(self.widget), below code is to play the video:

def play(self):
if self.mediaPlayer.state() == QtMultimedia.QMediaPlayer.PlayingState:
    self.mediaPlayer.pause()
else:
    self.mediaPlayer.play()

I searched on internet and found the below code to take screenshot of widget and tried but not working.

def screen_capture(self):
p = QPixmap.grabWindow(self.widget())


save, _ = QFileDialog.getSaveFileName(self,"Salvar Arquivo",
                                    filter="PNG(*.png);; JPEG(*.jpg)")
if save:
    p.save(save)

Please let me know that how to take screenshots from videoWidget.

user3030327
  • 411
  • 1
  • 7
  • 19
  • No, this is not. – user3030327 Apr 04 '20 at 13:25
  • Do you mean that you tried that answer and it didn't grab the image? You can't use `grabWindow` against a QWidget, and you shouldn't use it (nor `grabWidget`) because they're obsolete, and it wouldn't work anyway because video rendering usually depends on the operating system, so no direct method of widget grabbing/rendering is able to capture it. Using a temporary video output (or subclassing QAbstractVideoSurface) is the *only* solution. – musicamante Apr 04 '20 at 14:21

0 Answers0