Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Get frames from qml videoOutput and send to TcpSocket.
Forum Updated to NodeBB v4.3 + New Features

Get frames from qml videoOutput and send to TcpSocket.

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
22 Posts 2 Posters 3.0k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sharath
    wrote on 31 Jan 2020, 14:35 last edited by aha_1980
    #1

    Hi all,

    i'm working on liveview sharing between two devices using TCPsocket. So in qml i have used Camera type and Videooutput.

                    Camera
                    {
                        id:camera
    
                        cameraState: Camera.ActiveState
                        deviceId: QtMultimedia.availableCameras[0].deviceId
                        //position: Camera.FrontFace
                        focus {
                            //focusMode: CameraFocus.FocusContinuous
                            focusPointMode: CameraFocus.FocusPointAuto
                            //focusMode: CameraFocus.FocusMacro
                        }
    
    
                    }
                    CFilter{
                        id:filter
                    }
    
                    VideoOutput
                    {
                        id: videoOutput
                        source: camera
    
                        //anchors.top: text1.bottom
                        //anchors.bottom: text2.top
                        //anchors.left: parent.left
                        //anchors.right: parent.right
                        anchors.fill: parent
                        //radius:parent.width*0.7
                        autoOrientation: true
                        fillMode: VideoOutput.Stretch
                        filters: [ filter ]
    
                     
                    }
    
    

    CFilter is my c++ class.

    class CFRunnable:public QVideoFilterRunnable
    {
    public:
        //explicit CFRunnable(QAbstractVideoFilter *filter);
       
        QVideoFrame run(QVideoFrame *input, const QVideoSurfaceFormat &surfaceFormat, RunFlags flags){
            if(input->isValid())
            {
                qDebug()<<"frames are coming..."<<input;
                //qDebug() << "GOT FRAME"<<imageFromVideoFrame(*input);
                QByteArray arr;
                QVideoFrame cloneFrame(*input);
                       cloneFrame.map(QAbstractVideoBuffer::ReadOnly);
                       const QImage image(cloneFrame.bits(),
                                          cloneFrame.width(),
                                          cloneFrame.height(),
                                          QVideoFrame::imageFormatFromPixelFormat(cloneFrame .pixelFormat()));
                       qDebug()<<" format...:-"<<QVideoFrame::imageFormatFromPixelFormat(cloneFrame .pixelFormat()); //i'm getting invalid format, how do i convert YUYV format 
                cloneFrame.unmap();
               
    
    
             
                if(count==1 )
                {
                    tcpserver.startServer();
                }
    
                
                    tcpserver.writeBytesToClient(arr);
                
    
            }
    
    
            return *input;
    
        }
    
    private:
        QAbstractVideoFilter* m_filter;
        QVideoFrame frame;
        TcpServer tcpserver;
        int count;
    
    };
    

    I need to convert QVideoFrame to Qimage and then to Qbytearray and send it to tcpsocket.

    Please help me to solve this problem.

    Thanks in advance

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 31 Jan 2020, 22:07 last edited by
      #2

      Hi,

      What OS are you on ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      S 1 Reply Last reply 1 Feb 2020, 16:36
      0
      • S SGaist
        31 Jan 2020, 22:07

        Hi,

        What OS are you on ?

        S Offline
        S Offline
        sharath
        wrote on 1 Feb 2020, 16:36 last edited by
        #3

        Hi @SGaist,
        Thanks for your reply.
        ubuntu 18.04.

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 1 Feb 2020, 16:50 last edited by
          #4

          Then what about using tools already made for that ?
          For example use GStreamer to stream your video and then your application just as a visualizer.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          S 1 Reply Last reply 1 Feb 2020, 17:09
          1
          • S SGaist
            1 Feb 2020, 16:50

            Then what about using tools already made for that ?
            For example use GStreamer to stream your video and then your application just as a visualizer.

            S Offline
            S Offline
            sharath
            wrote on 1 Feb 2020, 17:09 last edited by sharath 2 Jan 2020, 17:16
            #5

            @SGaist I don't have knowledge on gstreamer. How can I use it in Qt? I have to make it possible in my application.

            1 Reply Last reply
            0
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 1 Feb 2020, 21:24 last edited by
              #6

              Why is it constrained to your application only ?

              If you have a recent enough version of Qt, you might be able to use QMediaPlayer.

              Otherwise, you can also build the pipeline yourself use the GStreamer API.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              S 1 Reply Last reply 2 Feb 2020, 04:27
              4
              • S SGaist
                1 Feb 2020, 21:24

                Why is it constrained to your application only ?

                If you have a recent enough version of Qt, you might be able to use QMediaPlayer.

                Otherwise, you can also build the pipeline yourself use the GStreamer API.

                S Offline
                S Offline
                sharath
                wrote on 2 Feb 2020, 04:27 last edited by sharath 2 Feb 2020, 04:28
                #7

                @SGaist we have embedded device which has camera and GUI application and I want to view/control the liveview of that camera from my android/iOS application. So each video frames from my embedded device should transmit to mobile application.

                Qmediaplayer is only to play the media source if I'm not wrong.

                S 1 Reply Last reply 14 Feb 2020, 04:31
                0
                • S Offline
                  S Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on 2 Feb 2020, 20:43 last edited by
                  #8

                  The link I provided shows you how to create a custom GStreamer pipeline where you can try to use a pipe so you can both show the stream on your device and have it streamed on the network.

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  S 2 Replies Last reply 3 Feb 2020, 15:02
                  0
                  • S SGaist
                    2 Feb 2020, 20:43

                    The link I provided shows you how to create a custom GStreamer pipeline where you can try to use a pipe so you can both show the stream on your device and have it streamed on the network.

                    S Offline
                    S Offline
                    sharath
                    wrote on 3 Feb 2020, 15:02 last edited by sharath 2 Mar 2020, 17:11
                    #9

                    @SGaist thank you, I will look into it.

                    1 Reply Last reply
                    0
                    • S SGaist
                      2 Feb 2020, 20:43

                      The link I provided shows you how to create a custom GStreamer pipeline where you can try to use a pipe so you can both show the stream on your device and have it streamed on the network.

                      S Offline
                      S Offline
                      sharath
                      wrote on 6 Feb 2020, 10:51 last edited by
                      #10

                      @SGaist gst-pipeline supports only after Qt5.12?

                      1 Reply Last reply
                      0
                      • S Offline
                        S Offline
                        SGaist
                        Lifetime Qt Champion
                        wrote on 6 Feb 2020, 22:39 last edited by
                        #11

                        Custom pipeline building in QMediaPlayer came in 5.12.2 like explained in the documentation.

                        However nothing stops you from using other means to create the pipeline.

                        Interested in AI ? www.idiap.ch
                        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                        S 1 Reply Last reply 7 Feb 2020, 04:15
                        0
                        • S SGaist
                          6 Feb 2020, 22:39

                          Custom pipeline building in QMediaPlayer came in 5.12.2 like explained in the documentation.

                          However nothing stops you from using other means to create the pipeline.

                          S Offline
                          S Offline
                          sharath
                          wrote on 7 Feb 2020, 04:15 last edited by sharath 2 Jul 2020, 04:17
                          #12

                          @SGaist its very hard to understand GStreamer. How can i pass QML camera to Gstreamer? is there any example to stream live camera like sender and receiver? i know this is stupid question, but i'm not getting any input that from where to start.

                          1 Reply Last reply
                          0
                          • S Offline
                            S Offline
                            SGaist
                            Lifetime Qt Champion
                            wrote on 7 Feb 2020, 20:38 last edited by
                            #13

                            As I already wrote, don't do that in that order.

                            Stream your camera using a dedicated software that will generate a real video stream.

                            Even if it's not simple, GStreamer allows you to show the feed locally and send it over the network at the same time.

                            Interested in AI ? www.idiap.ch
                            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                            S 1 Reply Last reply 10 Feb 2020, 10:04
                            0
                            • S SGaist
                              7 Feb 2020, 20:38

                              As I already wrote, don't do that in that order.

                              Stream your camera using a dedicated software that will generate a real video stream.

                              Even if it's not simple, GStreamer allows you to show the feed locally and send it over the network at the same time.

                              S Offline
                              S Offline
                              sharath
                              wrote on 10 Feb 2020, 10:04 last edited by
                              #14

                              @SGaist If you provide some sample code that would really helpful.

                              1 Reply Last reply
                              0
                              • S Offline
                                S Offline
                                SGaist
                                Lifetime Qt Champion
                                wrote on 10 Feb 2020, 20:32 last edited by
                                #15

                                Sample code of what ?

                                You do not even say what solution you want to implement.

                                Interested in AI ? www.idiap.ch
                                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                1 Reply Last reply
                                1
                                • S sharath
                                  2 Feb 2020, 04:27

                                  @SGaist we have embedded device which has camera and GUI application and I want to view/control the liveview of that camera from my android/iOS application. So each video frames from my embedded device should transmit to mobile application.

                                  Qmediaplayer is only to play the media source if I'm not wrong.

                                  S Offline
                                  S Offline
                                  sharath
                                  wrote on 14 Feb 2020, 04:31 last edited by
                                  #16

                                  @sharath said in Get frames from qml videoOutput and send to TcpSocket.:

                                  we have embedded device which has camera and GUI application and I want to view/control the liveview of that camera from my android/iOS application. So each video frames from my embedded device should transmit to mobile application.

                                  i want to use Gstreamer to stream the video over network(TCP). give some example code so that i can start.

                                  1 Reply Last reply
                                  0
                                  • S Offline
                                    S Offline
                                    SGaist
                                    Lifetime Qt Champion
                                    wrote on 14 Feb 2020, 22:21 last edited by
                                    #17

                                    Here you have an example using the command line to stream a video feed from a RaspberryPi. The streaming part will work the same on a computer.

                                    Interested in AI ? www.idiap.ch
                                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                    S 2 Replies Last reply 17 Feb 2020, 05:15
                                    2
                                    • S SGaist
                                      14 Feb 2020, 22:21

                                      Here you have an example using the command line to stream a video feed from a RaspberryPi. The streaming part will work the same on a computer.

                                      S Offline
                                      S Offline
                                      sharath
                                      wrote on 17 Feb 2020, 05:15 last edited by
                                      #18

                                      @SGaist Thank you. i will go through it

                                      1 Reply Last reply
                                      0
                                      • S SGaist
                                        14 Feb 2020, 22:21

                                        Here you have an example using the command line to stream a video feed from a RaspberryPi. The streaming part will work the same on a computer.

                                        S Offline
                                        S Offline
                                        sharath
                                        wrote on 17 Feb 2020, 07:25 last edited by
                                        #19

                                        Hello @SGaist, i just running the following commands to undertand Gstreamer on command line.
                                        To send current screen to network:

                                        gst-launch-1.0 -v ximagesrc use-damage=false xname=/usr/lib/torcs/torcs-bin ! videoconvert ! videoscale ! video/x-raw,format=I420,width=800,height=600,framerate=25/1 ! jpegenc ! rtpjpegpay ! udpsink host=127.0.0.1 port=5000
                                        

                                        To receive:

                                        gst-launch-1.0 udpsrc port=5000 ! application/x-rtp,encoding-name=JPEG,payload=26 ! rtpjpegdepay ! jpegdec ! autovideosink
                                        

                                        here its sharing my current screen using ximagesrc to network.
                                        So how can i send only current camera live view through Gstreamer. whats the command for that?

                                        1 Reply Last reply
                                        0
                                        • S Offline
                                          S Offline
                                          SGaist
                                          Lifetime Qt Champion
                                          wrote on 17 Feb 2020, 21:08 last edited by
                                          #20

                                          Did you even try to search for "GStreamer camera source" ?

                                          Interested in AI ? www.idiap.ch
                                          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                          S 1 Reply Last reply 18 Feb 2020, 06:54
                                          0

                                          1/22

                                          31 Jan 2020, 14:35

                                          • Login

                                          • Login or register to search.
                                          1 out of 22
                                          • First post
                                            1/22
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • Users
                                          • Groups
                                          • Search
                                          • Get Qt Extensions
                                          • Unsolved