# EmguCv stream Mat frames as RTSP pipeline

**URL:** <https://forum.opencv.org/t/emgucv-stream-mat-frames-as-rtsp-pipeline/16882>\
**Category:** Uncategorized\
**Tags:** rtsp, video, emgu, csharp\
**Created:** [March 19, 2024, 10:20pm UTC](https://forum.opencv.org/t/emgucv-stream-mat-frames-as-rtsp-pipeline/16882 "2024-03-19T22:20:10Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![juan1](https://avatars.discourse-cdn.com/v4/letter/j/bc79bd/32.png) [@juan1](https://forum.opencv.org/u/juan1)\
**Post date:** [March 19, 2024, 10:20pm UTC](https://forum.opencv.org/t/emgucv-stream-mat-frames-as-rtsp-pipeline/16882/1 "2024-03-19T22:20:10Z")

</div>

Hi,  
I’m doing a `C#` application with some image processing from `RealSense` camera using `EmguCv` and I want to stream images to RTSP pipeline to allow other (multiple) clients to view RTSP stream.

At the moment I have frames as `Mat` objects. I know that it’s possible to create an RTSP server using LibVlc or GStreamer but I don’t know what is the best way and how to convert `Mat` frames into a video streaming.  
Platform: Windows 10.

**In LibVlc**

How can I write Mat objets to MemoryStream?  
Also this constructor o LibVLC doesn’t seems to work and running `RTSP` server.

```auto
var ms = new MemoryStream()
var libVlc = new LibVLC("--sout-rtp-dst=rtsp://:8553/rtsp", "--sout-keep");
var media = new Media(libVlc, new StreamMediaInput(ms));
var player = new MediaPlayer(media);

```

I have also try to write `Mat` objects to `VideoWriter` and I can’t create `VideoWriter` because I don’t know which codec I have to use. I have try with MJPG, H264, XVID, DIVX … no one seems to work on my platform.

Maybe it’s possible to use GStreamer instead of LibVlc?  
Do you have any example of that?  
Thanks for your help.

---

<div class="post-metadata">

**Author:** ![berak](https://avatars.discourse-cdn.com/v4/letter/b/85f322/32.png) [@berak](https://forum.opencv.org/u/berak)\
**Post date:** [March 20, 2024, 4:03am UTC](https://forum.opencv.org/t/emgucv-stream-mat-frames-as-rtsp-pipeline/16882/2 "2024-03-20T04:03:59Z")

</div>

> [@juan1](#):
>
> Maybe it’s possible to use GStreamer instead of LibVlc?

we can’t help with EMGU at all, however, IF you want to use opencv’s VideoWriter for this, – the GStreamer backend is your only option

---

<div class="post-metadata">

**Author:** ![juan1](https://avatars.discourse-cdn.com/v4/letter/j/bc79bd/32.png) [@juan1](https://forum.opencv.org/u/juan1)\
**Post date:** [March 20, 2024, 6:57am UTC](https://forum.opencv.org/t/emgucv-stream-mat-frames-as-rtsp-pipeline/16882/3 "2024-03-20T06:57:36Z")

</div>

Hi,  
Thanks for your reply.  
I’m using EmguCv but I supose that is so similar to OpenCv because it’s a wrapper.  
Do you have an example with GsStreamer and Emgu or OpenCv? I’m not very familiar with GsStreamer.

But also I think I’m having a problem with VideoWriter because it seems never find codec in VideoWriter constructor.  
It’s necessary to install some codec pack in Windows platform or something like that?  
Thanks for your help.

---

<div class="post-metadata">

**Author:** ![berak](https://avatars.discourse-cdn.com/v4/letter/b/85f322/32.png) [@berak](https://forum.opencv.org/u/berak)\
**Post date:** [March 20, 2024, 8:08am UTC](https://forum.opencv.org/t/emgucv-stream-mat-frames-as-rtsp-pipeline/16882/4 "2024-03-20T08:08:41Z")

</div>

> [@juan1](#):
>
> It’s necessary to install some codec pack in Windows platform or something like that?

afaik, prebuilt opencv on windows comes only with ffmpeg support, so you’d have to 1) get a dev gstreamer install on your box 2) rebuild opencv libs with gstreamer videocapture backend 3) try out with your c# wrapper

---

<div class="post-metadata">

**Author:** ![crackwitz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/crackwitz/32/14_2.png) [@crackwitz](https://forum.opencv.org/u/crackwitz)\
**Post date:** [March 20, 2024, 8:45am UTC](https://forum.opencv.org/t/emgucv-stream-mat-frames-as-rtsp-pipeline/16882/5 "2024-03-20T08:45:36Z")

</div>

> [@juan1](#):
>
> `MemoryStream`

If you can explain that thing, maybe we can help. _however_, Emgu really isn’t _just_ a wrapper. personally, I have no experience with C#, so I can only speculate. You should browse Emgu docs for all the ways to get at the `data` pointer in the Mat (e.g. `ptr()` method in C++).
