Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Cropping a part of a Video in qml



  • Hi all,

    I am sending a Video stream from C++ side to Qml side. I am using QQuickImageProvider to achieve this. Here is my Qml side and working fine for streaming video on the interface.

    Rectangle {
            id: id_rectangle_img
            x: 200
            y: 175
            visible: true
            width: 960
            height: 540
            border.color: "black"
            clip: true
            Image {
                id: id_in1_image_img
                property bool counter: false
                width: 960
                height: 540
                visible: false
                asynchronous: false
                source: "image://live/image"
                anchors.centerIn: parent
                fillMode: Image.PreserveAspectFit
                cache: false
                function reload() {
                    counter = !counter
                    source = "image://live/image?id=" + counter
                }
            }        
        }
    

    I want to crop a specific part of this video and want to use it in another place of the interface. My question is that how I can crop(cut) that part and copy to another side of the interface?


  • Qt Champions 2018

    @Yunus said in Cropping a part of a Video in qml:

    I am sending a Video stream from C++ side to Qml side. I am using QQuickImageProvider to achieve this.

    That is not the correct solution. Use VideoOutput and a custom source to do that. See one of my previous post on how to do that : https://forum.qt.io/topic/25669/qml-optimal-way-to-stream-update-images-qt-5/3

    As for your actual question about duplicating and cropping an already displayed item, you can use ShaderEffectSource



  • I also tried VideoOutput but couldnt really see an advantage or difference with the imageprovider.


  • Qt Champions 2018

    I also tried VideoOutput but couldnt really see an advantage or difference with the imageprovider.

    Better performance and simpler QML code. ImageProvider is not meant for video.

    If you can also share the duplicated post, I ll appreciate. Thanks.

    ¿ Which duplicated post ?


Log in to reply