Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to stream the video using VLC-QT wrapper or libvlc
QtWS25 Last Chance

How to stream the video using VLC-QT wrapper or libvlc

Scheduled Pinned Locked Moved Solved General and Desktop
10 Posts 3 Posters 4.4k Views
  • 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.
  • D Offline
    D Offline
    devillIsHeree
    wrote on last edited by devillIsHeree
    #1

    I want to stream the video using RTSP, HTTP and UDP as they are supported by vlc. I am using Qt5 and as Qt don't have that much good media libraries so I go for open source and now using libvlc through VLC-Qt wrapper.

    I am able to receive the stream videos in my program, The source code for receiving the streaming video is given below

    void player::on_actionNETWORK_STREAM_triggered()
    {
        QString url= QInputDialog::getText(this,tr("Open Url"),tr("Enter the URL you want to play"));
    
        if(url.isEmpty())
            return;
        else
        {
            m_media=new VlcMedia(url,m_instance);
            playlist.append(url);
            m_mediaList->addMedia(m_media);
            m_player->open(m_media);
        }
    }
    

    To receive the streaming video I just put the url of that video into the new VlcMedia instance but don't know how to stream a video.

    While reading the documentation of the VLC-QT wrapper I read that it have one class named VlcVideoStream but I am not getting how to use that class to do the streaming. The link of the documentation of this class is given below

    https://vlc-qt.tano.si/reference/1.1/classvlcvideostream

    EDIT 1

    I searched on the internet more about this thing then I found some discussion of how to use VlcVideoStream and I have implemented the code for that. The source code is given below

    class VideoStreaming : public VlcVideoStream
    {
        Q_OBJECT
    public:
        explicit VideoStreaming(QObject *parent = nullptr);
    
        void frameUpdated();
    };
    
    void VideoStreaming::frameUpdated()
    {
        int rows,cols;
        
        std::shared_ptr<const VlcAbstractVideoFrame>  frame=  renderFrame();
        
        if (!frame)
            return; // LCOV_EXCL_LINE
    
        
        rows = frame->height + frame->height/2;
        cols = frame->width;
        
        qDebug()<<"Frame updated gets called";
    }
    

    and instantiate it with the following line

        m_video_stream= new VideoStreaming(ui->m_video);
        m_video_stream->init(m_player);
    

    Now I am able to receive the YUV frames of the video but don't know how to stream the video till now. Any help is appreciated. Even I am open to the pure libvlc streaming solution as VLC-QT wrapper is not that much good wrapper to support video streaming.

    I have also checked the VlcMedia class and find out that there exist one option as setOptions but don't know how to use that for my work.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      From a quick search (not tested) it seems that you need to add options to your media that contains the output parameters.

      See this StackOverflow answer.

      Hope it helps

      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
      • D Offline
        D Offline
        devillIsHeree
        wrote on last edited by
        #3

        hy @SGaist I tried that but in VLC-QT there is no option of addOptions. It will be useful if you can provide any source for Vlc-Qt or eeven in pure libvlc I just want to implement this streaming feature please help sir.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          From a quick look at VlcMedia sources I found setOption which might be what you need.

          As for a libVLC solution, the StackOverflow answer I linked uses just libVLC.

          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
          • D Offline
            D Offline
            devillIsHeree
            wrote on last edited by
            #5

            @SGaist I also looked at VlcMedia library and see that setOption is there but don't know how to use it. Even I am open to pure libvlc solution to this problem as I find out that Vlc-Qt wrapper is not that much advanced to do the streaming even it has many bugs also. The link which you have shared for the reference to libvlc solution is not that much useful to me cause that solution is regarding C# problem where they are using some wrapper class to the libvlc and is not pure libvlc solution as the Vlc-Qt is not that much advanced wrapper, I can go with libvlc for c++ (Qt).

            Can you please share any example of streaming through libvlc which is using c++ not other language. Please help me if I didn't complete this , I will not get my pay and I needed this urgently to pay my college fees sir. Please help me. It took me whole day surfing on net still I didn't get anything useful to me.

            I am updating my question so you can see what i have done till now to this problem.

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Well, a quick search shows the official C++ wrapper which API looks pretty close to the C# code from StackOverflow.

              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
              0
              • B Offline
                B Offline
                Bonnie
                wrote on last edited by Bonnie
                #7

                From @SGaist 's replies, you should see that here is not the right place to ask libvlc / VLC-QT questions (you are like the only one using it), especially your questions are not Qt-related but about how to use vlc-APIs.
                I think you should either ask on SO or find a vlc-related forum.

                1 Reply Last reply
                1
                • D Offline
                  D Offline
                  devillIsHeree
                  wrote on last edited by
                  #8

                  @SGaist ok sir i will check it out. @Bonnie It is related to Qt sir and I am not the only one who are using it. Please search in this forum and you will get thousand of question related to Vlc-Qt in this forum.

                  @SGaist I will check this wrapper and will let you know.

                  B 1 Reply Last reply
                  1
                  • D devillIsHeree

                    @SGaist ok sir i will check it out. @Bonnie It is related to Qt sir and I am not the only one who are using it. Please search in this forum and you will get thousand of question related to Vlc-Qt in this forum.

                    @SGaist I will check this wrapper and will let you know.

                    B Offline
                    B Offline
                    Bonnie
                    wrote on last edited by Bonnie
                    #9

                    @devillIsHeree
                    I just hope that you can get more effective help.
                    As I can see, there's no others using libvlc / VLC-QT replying you.
                    (Also libvlc is totally not Qt-related. And a third-party project is using Qt doesn't mean any question related to it is Qt-related...
                    Actually this forum has a lot of not Qt-related posts. So I'm not saying you can't post here, I just suggest you to also find somewhere else to ask.)
                    Most of us can only google for you, like @SGaist did, but I don't think that is something you should need others to help.

                    1 Reply Last reply
                    1
                    • D Offline
                      D Offline
                      devillIsHeree
                      wrote on last edited by
                      #10

                      @SGaist Thanks sir, Finally I am able to do the streaming. I have used the method from your 1st link and just use the setOption feature of Vlc-qt still I am not getting how it works and just trying to learn more about it but Yeah streaming is working now.

                      Here is the code if anyone wants to learn, how setoption should be used.

                          m_media = new VlcMedia("file:///home/vinay/Media Library/lion-sample.webm",m_instance);
                          m_media->setOption(":sout=#transcode{vcodec=h264,acodec=mpga,ab=128,channels=2,samplerate=44100,scodec=none}:udp{dst=127.0.0.1:1234}");
                          m_media->setOption(":no-sout-all");
                          m_media->setOption(":sout-keep");
                      

                      The string parameters here are taken from the vlc media player when we stream a video through vlc media player in the last screen it show these parameters which i just passed through my setOption function.

                      1 Reply Last reply
                      1

                      • Login

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