0

So I created a video sink in C++ that is displayed in qml thanks to the following link : How to use QVideoSink in QML in Qt6

It works perfectly.

Now I'm trying to use the MediaRecorder to record those images and save it, but I have no idea what to do to make it work.

The qml before trying anything looks like this :

VideoOutput
    {
        id: cameraDisplay
        anchors.fill: parent
    }

Producer
{
    id:producer
    objectName: "producer"
    videoSink: cameraDisplay.videoSink
}

I create a simple button to control a recorder :

Button{

    text: ""

    Image {
        id: recordImage
        source: recorder.status == MediaRecorder.RecordingStatus ? "Images/Record.png" : "Images/Record.png"
        width: parent.width
        height: parent.height
    }

    onClicked: {
        if (recorder.status == MediaRecorder.RecordingStatus) {
            recorder.stop()
        } else {
            recorder.record()
        }
    }
}

and then added a MediaRecorder:

MediaRecorder {
    id: recorder
}

but I have no idea how to select the "source" of the MediaRecorder so that it selects the video Sink, as there is no source property.

Any idea how to do this? I would like to save it as a mp4 file to a particular location Thanks!

asdfasdf
  • 774
  • 11
  • 29
  • Did you check the [recorder example](https://code.qt.io/cgit/qt/qtmultimedia.git/tree/examples/multimedia/video/recorder?h=6.4)? – folibis Dec 18 '22 at 10:39
  • The problem with this example is that it only works with easily detectable camera. For my camera, I had to do what was suggested in this post to make it work : https://forum.qt.io/topic/132144/what-module-should-i-use-for-streaming-c-qimage-objects-into-qml/10 Which is why I don't have a Camera qml component, but a Producer component (which is defined in c++) – asdfasdf Dec 18 '22 at 17:48

0 Answers0