In OpenCV how to write frame/images/Mat to RTMP/RTSP stream, to display the result from the server to client (HTML/Webpage)

asked 2017-11-01 01:00:37 -0600

BAHRAMUDIN ADIL gravatar image

I want to know if it is possible to write the frames/images/Mat to an RTMP/RTSP (from my server which is processing the video stream, sends the frame to the browser/other pc for displaying the result)? I used VideoWriterclass, but I don't know if it is doing the same thing. If it is possible, then how I can do this by using OpenCV/FFMPEG.

And also if the above one was not possible with OpenCV, then how we can use GStreamer with OpenCV to achieve the problem?

edit retag flag offensive close merge delete

Comments

you did not research this well.

even if you get successful with gstreamer & videowriter, you'd still need a seperate webserver for the html, and a seperate player software to show it -- all of it off-topic here.

also, please close your issue here , you're not reporting a bug, and you're only wasting anyone's time there.

berak gravatar imageberak ( 2017-11-01 02:14:19 -0600 )edit

Hmm maybe it is a wasting time for you, but it a big problem for me, it for two weeks that I am searching, I there must be an end side server, but the problem is I cannot successfully open the output stream pipeline. I have tried this , but I also not able to correctly open the stream, my question is very clear (If it is possible then say 'yes', if not, then say 'no' and show how it can be possible?

BAHRAMUDIN ADIL gravatar imageBAHRAMUDIN ADIL ( 2017-11-01 02:51:39 -0600 )edit

Becuase opencv supports GStreamer, but there is no any documentation to show how to use, so IT IS A BIG and BIG and BIG ..... BUG BUG BUG.

BAHRAMUDIN ADIL gravatar imageBAHRAMUDIN ADIL ( 2017-11-01 02:53:09 -0600 )edit

well, if you tried anything - why don't you show that in your question ?

and maybe looking at something like this might give you an idea of the complexity you're facing

there's also #gstreamer on irc (they're usually quite helpful)

(also, when working with sockets, tools like wireshark might be helpful, to see, if any packets come out at all)

last, you could "reverse" your problem, and make your opencv code run inside gstreamer as a plugin

berak gravatar imageberak ( 2017-11-01 02:55:57 -0600 )edit

I have tried lot of ways, in my google search all the links about opencv and video stream, and opencv with gstreamer are in purple color, because I have already clicked them many and many times. One way that I think will work, is this:

String outUrl =
                "gst-launch-1.0 -v v4l2src " +//
                        "! video/x-raw,format=YUY2,width=640,height=480 " +//
                        "! jpegenc " +//
                        "! rtpjpegpay " +//
                        "! udpsink host=127.0.0.1 port=5000";
writer.open(outUrl, CAP_GSTREAMER, 0, 15, new Size(640, 480));
if (!writer.isOpened()) {
      System.out.println("writer error");
       return;
 }
BAHRAMUDIN ADIL gravatar imageBAHRAMUDIN ADIL ( 2017-11-01 03:46:05 -0600 )edit

https://gstreamer.freedesktop.org/doc...

btw, gst-launch-1.0 is a cmdline tool, and -v an argument for that, none of that should go into your pipeline

berak gravatar imageberak ( 2017-11-01 03:58:26 -0600 )edit