RTC Forums

Subscription => Support => Topic started by: andreag0 on December 10, 2019, 01:12:51 PM



Title: WebServer stream mjpeg from Webcam
Post by: andreag0 on December 10, 2019, 01:12:51 PM
Hello,
I manage to send jpeg image from webcam but I wish to stream the
realtime video in mjpeg format.
Does anyone know how to do?

Thank you.

Andrea


Title: Re: WebServer stream mjpeg from Webcam
Post by: D.Tkalcec (RTC) on December 11, 2019, 09:07:25 AM
I've never done this, so my answer is purely theoretical (don't ask for details).

Since MJPEG is basically a sequence of stand-alone JPEG images, one way of doing it (once you have the Server-side code that sends a static JPEG from a Webcam) would be to use JavaScript with HTML to implement an event loop inside a Browser, which would keep loading that JPEG from the Server, then painting it on the HTML canvas, or replacing the contents of an image element.

If you need help with HTML and JavaScript, try searching for "MJPEG JavaScript" with www.google.com or www.duckduckgo.com or any another search engine of your choice.

Best Regards,
Danijel Tkalcec


Title: Re: WebServer stream mjpeg from Webcam
Post by: andreag0 on December 11, 2019, 10:03:43 AM
Thank you Danijel for support.
About sending image, there is any example how to do in proper way?
I am sending image and in browser I can see correctly but browser is still waiting for some data,
what I am missing except ContentType and ContentLength?

Best Regards
Andrea


Title: Re: WebServer stream mjpeg from Webcam
Post by: D.Tkalcec (RTC) on December 11, 2019, 10:11:27 AM
If Content-Type and Content-Length are both set correctly, you just need to send the image content. That's all.

If the Browser keeps waiting for more data, but the image looks OK, maybe the Content-Length is not correct. Make sure that Content-Length is set to the exact size of the JPEG image you are sending (in bytes).

Best Regards,
Danijel Tkalcec