def present(self, frame: QVideoFrame): print("present called") if frame.isValid(): clone_frame = QVideoFrame(frame) clone_frame.map(QAbstractVideoBuffer.ReadOnly) image = QImage(clone_frame.bits(), frame.width(), frame.height(), frame.bytesPerLine(), \ QVideoFrame.imageFormatFromPixelFormat(frame.pixelFormat())) clone_frame.unmap() self.frame_available.emit(image) if self.surfaceFormat().pixelFormat() != frame.pixelFormat() or \ self.surfaceFormat().frameSize() != frame.size(): self.setError(QAbstractVideoSurface.IncorrectFormatError) self.stop() print("present finished: Return False") return False else: self.current_frame = frame print("present finished: Return True") return True
def present(self, frame: QVideoFrame): """ Called by the video player :param frame: frame to present """ if frame.isValid(): clone_frame = QVideoFrame(frame) clone_frame.map(QAbstractVideoBuffer.ReadOnly) image = QImage( clone_frame.bits(), clone_frame.width(), clone_frame.height(), QVideoFrame.imageFormatFromPixelFormat( clone_frame.pixelFormat())) self.frameAvailable.emit(image) clone_frame.unmap() if self.surfaceFormat().pixelFormat() != frame.pixelFormat( ) or self.surfaceFormat().frameSize() != frame.size(): self.setError(self.IncorrectFormatError) self.stop() return False else: self.currentFrame = frame self.widget.repaint() return True