python - Displaying a video stream in QLabel with PySide -


Can anyone tell me in the right direction how to create a new QMVI "provider" in PySide?

is a video stream to me that I try to reflect as much as possible as possible (no audio, only an unknown sequence of frames of variable framerate) except that my video come from unconventional sources Used to be. This is not a file, but there is a network stream in a format that is not standardized. I can easily write code that receives each frame and my idea is to create a "QMV provider" so that I can only display this stream on the label like the example above.

My first thought sub-class QMovie and there overwrite some functions, but I started to introduce other ideas about that since I do not know "device I do about" Must be reading my example.

I saw the above documentation that uses QMovie QImageReader, so my next idea is to extend the class and it was reading frame from my stream, for example, I "supported Images (function) "What should be done with the function?

I am using an image updating directly on my QLabel whenever I get a new frame but I have been getting the error again "QPixmap: This is not a safe GUI thread Outside is to use Pixmap ""

Basically I am a little stumped and in fact how any hints or testimonials would appreciate. To get a QLabel to display my video stream in a PySide application.

For the future context here is how I managed to achieve this work.

Using the signal and slot mechanism, the following application works. Signal / slot mechanism is that the image is created inside up_camera_callback function and is coming from a different thread that is emitted to CameraDisplay.updateFrame work it takes to locate and take necessary precautions.

  class CameraDisplay (QtGui.QLabel): def __init __ (self): Super (CameraDisplay, self) .__ init __ () updateFrame (self-image) def: self.setPixmap (QtGui .QPixmap.fromImage (Image)) Square ControlCenter (QtGui.QWidget): up_camera_signal = QtCore.Signal (QtGui.QImage) up_camera = None DEF __init __ (self): Super (ControlCenter, self) .__ init __ () self .up_camera = CameraDisplay () self.up_camera_signal.connect (self.up_camera.updateFrame) grid = QtGui.QGridLayout () grid.setSpacing (10) grid.addWidget (self.up_camera, 0, 0) self.setLayout (grid) self .setGeometry (300, 300, 350, 300) self.setWindowTitle ('Control Center') Self.show () def up_camera_callback (self, data): '' 'This function is used by an external thread Try '' 'Try: image = QtGui.QImage (data.data, data .width, data.height, QtGui.QImage.Format_RGB888) Exception except for self.up_camera_signal.emit (image), e: print ( E) if __name__ == "__main__": application = QtGui.QApplication (sys.argv) pre = ControlCenter () sys.exit (app.exec_ ())    

Comments