Page 1 of 1

LibVlcSharp: How to stream a dynamic frame sequence with RTSP (Dynamic StreamMediaInput)?

Posted: 30 Aug 2021 15:02
by clBigWiener1
I'm working on a project that takes individual images from an RTSP-Stream and manipulates them (drawing bounding boxes). Those images should be restreamed (h264 encoded) on a separate RTSP-stream on an other address and shouldn't be saved on the local disk.

My current code so far is:

Code: Select all

{ // OpenCV VideoCapture: Sample RTSP-Stream var capture = new VideoCapture("rtsp://195.200.199.8/mpeg4/media.amp"); capture.Set(VideoCaptureProperties.FourCC, FourCC.FromFourChars('M', 'P', 'G', '4')); var mat = new Mat(); // LibVlcSharpStreamer Core.Initialize(); var libvlc = new LibVLC(); var player = new MediaPlayer(libvlc); player.Play(); while (true) { if (capture.Grab()) { mat = capture.RetrieveMat(); // Do some manipulation in here var media = new Media(libvlc, new StreamMediaInput(mat.ToMemoryStream(".jpg"))); media.AddOption(":no-audio"); media.AddOption(":sout=#transcode{vcodec=h264,fps=10,vb=1024,acodec=none}:rtp{mux=ts,sdp=rtsp://192.168.xxx.xxx:554/video}"); media.AddOption(":sout-keep"); player.Media = media; // Display screen Cv2.ImShow("image", mat); Cv2.WaitKey(1); } } }
It is a little bit messy, because of testing purposes, but it works if I just use the given RTSP-Stream as the Media instead of the fetched images. I have some success with piping the images (as bytes) into the cvlc command line (

Code: Select all

python get_images.py | cvlc -v --demux=rawvideo --rawvid-fps=25 --rawvid-chroma=RV24 --sout '#transcode{vcodec=h264,fps=25,vb=1024,acodec=none}:rtp{sdp="rtsp://:554/video"}'
), but it should be integrated in c#. get_images.py just reads images in a while-loop, writes a string on it and forwards them into std-out.

My thoughts on solving this problem is, to input the images via the StreamMediaInput-class and to dynamically change the media, if a new image has been retrieved. But it doesn't work, nothing can be seen with VLC or FFPlay.

Does someone has faced a similar Problem? How can the StreamMediaInput-Object can be changed dynamically, such that new images are broadcastet correctly?

Thank you for taking the time to read this post. Have a nice day!

Re: LibVlcSharp: How to stream a dynamic frame sequence with RTSP (Dynamic StreamMediaInput)?

Posted: 30 Aug 2021 15:38
by RĂ©mi Denis-Courmont
There is no support for streaming output with LibVLC at this time. This feature is being considered maybe for version 4.0.

Re: LibVlcSharp: How to stream a dynamic frame sequence with RTSP (Dynamic StreamMediaInput)?

Posted: 30 Aug 2021 17:17
by clBigWiener1
There is no support for streaming output with LibVLC at this time. This feature is being considered maybe for version 4.0.
Hey, thank you for your quick answer. So it is not possible to boradcast single images, Jpegs etc. on localhost via RTSP? Do you maybe have any other recommendation/Framework or alternative, which works? Thanks again very much