0

I am trying to write a viewer for motionphoto pictures taken by my smartphone. The camera captures a few seconds of video before the image is taken and then saves both the video and jpeg file in the same jpeg file. [jpg binary data followed by mp4 binary data].jpg

I use python to open the saved jpeg file and read the jpeg and mp4 data into separate memory buffers (QBuffers). Using QWidgets, I am able to pass the QBuffer to QMediaPlayer and am able play the video using a QVideoWidget. Before the video finishes, I overlay it with the captured high quality image.

This works fine, however there is an annoying blink of black screen for a fraction of a second. Using QGraphicsScene, the blink is not there, but the video and image quality is worse.

I thought QML might not suffer from this black blink. QML allows one to define a MediaPlayer, however it requires a QUrl. This can be a local file or a web resource, but I haven't found a way of providing the data already loaded in memory to the MediaPlayer.

I cannot access the QML MediaPlayer object from PySide6, so I thought I would ask the powerful community for ideas :)

I read a suggestion to provide a custom QNetworkAccessManager Dynamically Loading QML from Memory Instead of a URL however I tried somehow understanding this, I even tried to understand c++ syntax, but I struggle if this would even be helpful.

PS: this is my very first time asking for any sort of coding related help. I have searched possible solutions

From QWidgets I tried a QGraphicsSCene, but the video and image quality looks less good.

So I resorted to QML that this might be helpful, but the MediaPlayer requires a string pointing to a source file. I tried accessing the MediaPlayer directly by setting an objectName in QML and changing the playbackRate property directly, however the MediaPlayer object apparently gets destroyed when I try to access it.

 MediaPlayer {
        id: player
        source: "test_video_file.mp4"
        audioOutput: AudioOutput {}
        videoOutput: videoOutput
        objectName: "medplayer"
        playbackRate: 1.0
    }

    VideoOutput {
        id: videoOutput
        anchors.fill: parent
        anchors.margins: 20
    }
medplayer = engine.rootObjects()[0].findChild(QObject, "medplayer")
medplayer.setProperty('playbackRate', 1.5)

RuntimeError: Internal C++ object (PySide6.QtMultimedia.QMediaPlayer) already deleted.

petr.z
  • 1
  • 1

0 Answers0