<div dir="ltr">hi,<div><br></div><div>i've this little script :</div><div>__________________________________________</div><div><div>import sys</div><div>import os</div><div>from PyQt5.QtGui import *</div><div>from PyQt5.QtWidgets import *</div><div>from PyQt5.QtCore import *</div><div>from PyQt5.QtMultimedia import *</div><div>from PyQt5.QtMultimediaWidgets import *</div><div><br></div><div><br></div><div>class VideoSurface(QAbstractVideoSurface):</div><div><br></div><div>     def __init__(self, parent=None):</div><div>         QAbstractVideoSurface.__init__(self, parent)</div><div>         self.imageFormat = QImage.Format_Invalid</div><div><br></div><div>     def supportedPixelFormats(self,handleType=QAbstractVideoBuffer.NoHandle):</div><div>         formats = [QVideoFrame.PixelFormat()]</div><div>         if (handleType == QAbstractVideoBuffer.NoHandle):</div><div>             for f in [QVideoFrame.Format_RGB32,</div><div>                       QVideoFrame.Format_ARGB32,</div><div>                       QVideoFrame.Format_ARGB32_Premultiplied,</div><div>                       QVideoFrame.Format_RGB565,</div><div>                       QVideoFrame.Format_RGB555</div><div>                       ]:</div><div>                 formats.append(f)</div><div>         return formats</div><div><br></div><div>     def isFormatSupported(self, _format):</div><div>         imageFormat = QVideoFrame.imageFormatFromPixelFormat(_format.pixelFormat())</div><div>         size = _format.frameSize()</div><div>         _bool = False</div><div>         if (imageFormat != QImage.Format_Invalid and not</div><div>             size.isEmpty() and</div><div>             _format.handleType() == QAbstractVideoBuffer.NoHandle):</div><div>             _bool = True</div><div>         return _bool</div><div><br></div><div>     def start(self, _format):</div><div>         imageFormat = QVideoFrame.imageFormatFromPixelFormat(_format.pixelFormat())</div><div>         size = _format.frameSize()</div><div>         if (imageFormat != QImage.Format_Invalid and not size.isEmpty()):</div><div>             self.imageFormat = imageFormat</div><div>             self.imageSize = size</div><div>             self.sourceRect = _format.viewport()</div><div>             QAbstractVideoSurface.start(self, _format)</div><div>             return True</div><div>         else:</div><div>             return False</div><div><br></div><div>     def stop(self):</div><div>         self.currentFrame = QVideoFrame()</div><div>         QAbstractVideoSurface.stop(self)</div><div><br></div><div><br></div><div>     def present(self, frame):</div><div>         if (self.surfaceFormat().pixelFormat() != frame.pixelFormat() or self.surfaceFormat().frameSize() != frame.size()):</div><div>             self.setError(QAbstractVideoSurface.IncorrectFormatError)</div><div>             self.stop()</div><div>             return False</div><div>         else:</div><div>             self.currentFrame = frame</div><div>             return True</div><div><br></div><div><br></div><div>if __name__=="__main__":</div><div>    import sys</div><div>    app = QApplication(sys.argv)</div><div>    surface = VideoSurface()</div><div>    mediaPlayer = QMediaPlayer(None, QMediaPlayer.VideoSurface)</div><div>    mediaPlayer.setVideoOutput(surface)</div><div>    app.exec_()</div><div>______________________________________________________________________</div><div><br></div><div>this script is base on this post :</div></div><div><a href="http://www.riverbankcomputing.com/pipermail/pyqt/2013-October/033256.html">http://www.riverbankcomputing.com/pipermail/pyqt/2013-October/033256.html</a><br></div><div><br></div><div>this script failed ( crash ) if i comment this import:</div><div>from PyQt5.QtMultimediaWidgets import *<br></div><div><br></div><div><br></div><div>I'm on windows</div><div>Python version 2.7.9 x64</div><div><div>QT_VERSION_STR    '5.4.0'</div></div><div><div>PYQT_VERSION_STR '5.4'</div></div><div><div>SIP_VERSION_STR '4.16.5'</div></div><div><br></div><div><br></div></div>