Skip to content Skip to sidebar Skip to footer

How To Read Video Data From Memory Use Pyqt5

i have an encrypted video file, i want to decrypt this file into memory and then use this data play video. but qt mediaplayer class is to pass a file name in, i need to have any go

Solution 1:

i have solved this problem, and the solutions are as follows code

#!/usr/bin/env pythonfrom PyQt5.QtCore import QFile, QFileInfo, QIODevice, QUrl, QDataStream, QBuffer, QByteArray
from PyQt5.QtWidgets import QApplication
from PyQt5.QtMultimedia import QMediaPlayer, QMediaContent
from PyQt5.QtMultimediaWidgets import QVideoWidget

if __name__ == '__main__':

import sys
app = QApplication(sys.argv)
player = QMediaPlayer()

file = QFile('mymusic-encrypt.avi')

isOpen = file.open(QIODevice.ReadOnly)

buffer = QBuffer()
buffer.open(QIODevice.ReadWrite)

player.setMedia(QMediaContent(), buffer)

if isOpen:
    whilenot file.atEnd():
        temp = file.readLine()
        # temp = QByteArray.fromBase64(temp)
        buffer.write(temp)

videoWidget = QVideoWidget()
player.setVideoOutput(videoWidget)
videoWidget.show()

player.play()
sys.exit(app.exec_())

i need carefully read api, thanks everyone.

Post a Comment for "How To Read Video Data From Memory Use Pyqt5"