3

I have a JavaFX Application that uses OpenCV to get the frames from the camera.

I would like to send this stream to nginx-rtmp.

I must be missing something (or the whole loginc of RTMP) but I can't seem to find a simple way to make the stream

I already tested the nginx-rtmp with OBS Studio, and I have the frames, I'm missing the link to get the frames through the RTMP link.

Already found a couple of libraries (xuggler, gstreamer,humble-video...) but none of them seems to work or didn't find a way to implement them correctly

Dany Y
  • 6,833
  • 6
  • 46
  • 83
  • Did you check out `FFmpeg`? check out https://stackoverflow.com/questions/5825173/pipe-raw-opencv-images-to-ffmpeg and https://answers.opencv.org/question/94552/how-to-send-opencv-videos-to-ffmpeg/ – Jawad Al Shaikh Jul 13 '20 at 15:46
  • Actually I am not able to understand the question, do you have RTMP camera stream that you want to access with OpenCV? or you want to stream the frames you got from OpenCV as RTMP protocol? – Jawad Al Shaikh Jul 13 '20 at 15:48
  • Yes i'm already capturing the frames from the camera and displaying them on the screen, now I need to send them through rtmp, I've seen ffmpeg many places, but I understood ffmpeg is for the encoding, how should the sending be (I'm imagining smthg similar to an http request but as an open stream, maybe like a websocket) – Dany Y Jul 13 '20 at 18:00
  • FFmpeg is the Swiss army knife for all sort of video processing and streaming. About the frames you see on the screen, check the 2 links I shared in 1st comment, in case you want the camera stream to be re-streamed as RTMP regardless what's you doing in OpenCV then that's also possible. If that's the case then please share the camera stream protocol or just google `FFmpeg source-protocol dest-protocol` – Jawad Al Shaikh Jul 13 '20 at 18:08
  • thanks googling `FFmpeg source-protocol dest-protocol` got me on the right track, still have to find the java version, but i think now i'm understanding how it happens. Yes actually the main thing i want to do is stream these frames regardless of OpenCV, OpenCV was just to get the frames as a first step. Thanks a lot – Dany Y Jul 13 '20 at 19:15

1 Answers1

1

Based on the discussion we had at the comments section, this is the summary:

FFmpeg is the Swiss army knife for all sort of video processing and streaming. In case you want the camera stream to be re-streamed as RTMP regardless what's you doing in OpenCV then that's also possible.

If that's the case then just google FFmpeg source-protocol dest-protocol.

Regarding the Java version, you can invoke FFmpeg as command line from your Java code, otherwise its API support JAVA beside many other languages.

Jawad Al Shaikh
  • 2,475
  • 2
  • 28
  • 41
  • can you share a small code snippet or something on how to re-stream frames to rtmp via ffmpeg? I am also looking at the same problem but cant figure out – mifol68042 Mar 19 '21 at 07:58
  • @mifol68042 you can ask your own question and provide what did you tried so far. If you didn't try anything yet, then please download ffmpeg and start walking through the basic examples till you figure it out or just ask a question if stuck. – Jawad Al Shaikh Mar 20 '21 at 16:21