Publish h264/webRTC from MJPEG stream

Hi,

I have a camera which is only able to send raw bitmaps by ethernet. I have a C# web application which receives such frames in a buffer and works with them. I’m able to create a MJEPG stream from such frames, while I need a h264/webRTC stream playable in browser.

I think the easier way to do this is to have my C# application publish the MJPEG stream at a given endpoint, e.g. http:// server-address:server-port/my-mjpeg-stream, and to have openVidu trasnscode it to h264 and publish it by means of webRTC.

So, let’s assume I have the following entities

  1. openVidu deployment
  2. c# web application producing MJPEG stream
  3. Java application instructing openVidu to create a connection and to parse the given MJPEG stream and publish a h264/webRTC stream from it
  4. Browser playing the video stream in a html/javascript page.

I’ve checked the openvidu-ipcameras example but I don’t see a way of taking camera input stream from MJPEG. In particular I see that ConnectionProperties.Builder, has a rtspUri method while it has no mjpegURI or something like that.

Is there a way of feeding openVidu with a MJPEG stream?

Thanks,
Alessandro

Hi,

This would be possible if you could transform your mjpeg stream into an RTSP stream. Maybe with a GStreamer plugin or even with VLC: Streaming MJPG from webcam to RTSP using VLC | by Pete Houston | Medium
But at least for now, unfortunately this is out of the scope of OpenVidu.

Best regards.

Hi,

if you are just really trying to stream this video into a browser, and not necessarily routing it through OpenVidu, I believe you should just be able to do it directly, as web browsers do have support for MJPEG: Include a MJPEG in a html-Site

You might even be able to skip your C# application; depending on how the camera works, by using the Fetch API to stream directly from the browser.

Thanks for the answer,
I’m afraid that would introduce too many steps (images > MJPEG > RTSP > openvidu) and I fear that would affect latency, which is important for me to stay as low as possible.

Thanks for the answer,
Yep I’m aware I can play MJPEG directly into the browser, that’s what I’m currently doing actually, but I want to avoid it since if I want a decent quality, the bandwitdh used is too much even for a local network deployment.

Good news for you! We have been doing some research, and we have in fact confirmed that Kurento natively supports mjpeg. The only necessary change is allowing the rtspUri parameter when publishing an IP camera to start with http or https. This small commit does precisely that: openvidu-java-client: allow http and https URI protocols on rtspUri p… · OpenVidu/openvidu@4e299f1 · GitHub

So in the main branch of OpenVidu/openvidu right now it is possible to publish IP cameras which URI starts with http/https protocols.

Very good new indeed! I’ll definitely give it a try.

Thanks.

Hi,
not sure if I should be posting here or opening another thread.

I’ve tried using the REST API to public an IP_CAMERA stream like this (please note I’m using openvidu 2.23.0 inside a Docker by means of wsl)
POST http://localhost:4443/openvidu/api/sessions/CUSTOM_SESSION_ID/connection

with body

{
   "type": "IPCAM",
   "data": "Office security camera",
   "record": false,
   "rtspUri": "http://92.110.185.114:8080/mjpg/video.mjpg",
   "adaptativeBitrate": true,
   "onlyPlayWithSubscribers": true,
   "networkCache": 1000
}

And I got as result

{
    "timestamp": 1666607316719,
    "status": 400,
    "error": "Bad Request",
    "message": "Error in parameter 'rtspUri': RTSP URI does not contain a valid protocol [file, rtsp, rtsps]",
    "path": "/openvidu/api/sessions/CUSTOM_SESSION_ID/connection"
}

For the previous commit, I thought just the java client needed to be updated. Since the java client is just a wrapper around the REST API, I thought the REST API would work, but it doesn’t. Could you please help me out?

Hi,

RTSP URIS with http and mjpg protocols will be supported in release 2.24.0.

This is already implemented in the master branch of OpenVidu/openvidu repository, if you want to build it and test it right now: Developing OpenVidu - OpenVidu Docs