How to stream the video using VLC-QT wrapper or libvlc
-
I want to stream the video using
RTSP, HTTP and UDP
as they are supported byvlc
. I am usingQt5
and asQt
don't have that much good media libraries so I go for open source and now usinglibvlc
throughVLC-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 oneclass
namedVlcVideoStream
but I am not getting how to use that class to do the streaming. The link of the documentation of thisclass
is given belowhttps://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 belowclass 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 purelibvlc
streaming solution asVLC-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 assetOptions
but don't know how to use that for my work. -
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
-
hy @SGaist I tried that but in
VLC-QT
there is no option ofaddOptions
. It will be useful if you can provide any source forVlc-Qt
or eeven in purelibvlc
I just want to implement this streaming feature please help sir. -
@SGaist I also looked at
VlcMedia
library and see thatsetOption
is there but don't know how to use it. Even I am open to purelibvlc
solution to this problem as I find out thatVlc-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 tolibvlc
solution is not that much useful to me cause that solution is regardingC#
problem where they are using some wrapper class to thelibvlc
and is not purelibvlc
solution as theVlc-Qt
is not that much advanced wrapper, I can go withlibvlc
for c++ (Qt).Can you please share any example of streaming through
libvlc
which is usingc++
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.
-
Well, a quick search shows the official C++ wrapper which API looks pretty close to the C# code from StackOverflow.
-
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. -
-
@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. -
@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 ofVlc-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 mysetOption
function.