Mjpeg and oh-video

Does anybody know if the oh-video control supports mjpeg streams? With the following config I do not get a picture. Any idea?

component: oh-video-card
  playerType: videojs
  type: video/x-motion-jpeg

By this url the camera establishes an http keep-alive connection and streams data to the client.

Is that URL correct for the file extension?
I thought motion jpeg files ended in .mjpg or mjpeg at least on my cameras they do.
How else would it know it is a streamed series of jpegs and not 1 static image otherwise.

At least, this is what the vendor (Mobotix) says/thinks that this stream is an mjpeg-stream.

Ok so here are a few options out on stack overflow that look promising and you may be able to adapt to your needs.

This is how I have currently created my widget

- component: img

The problem is that after I close the popup containing this widget, the connection is still open as it is a keep-alive connection.
I was hoping to solve this issue with the oh-video control as it has a stop button.

I understand still goes back to what I said before if the current extension being presented is for a static image,(.jpg) then how does any player know it is a stream to render or even the action you take of closing the widget and when to tear down the connection?
short of embedding some type of wrapper that manages the tcp connection to your camera’s web server and tear it down when you close or collapse the widget basically send an ack/fin to close the connection like in a long overly simplified way your browser does when you close a web page.
I would bet if the jsplayer saw that url as a mjpg or mjpeg file extension it would treat it differently and render it however one of the challenges with a motion jpeg is there is no control stream so no real way to stop the flow of jpg’s the camera’s web server sends short of abandoning or sending a tear down ack/fin for the camera webserver to self terminate the conversation.
Only other way I can think of off the top of my head would be to convert it to a real video stream and embed a control stream that you then could click stop on to trigger a hang up of the conversation upon exit the widget

1 Like

Hit REFRESH button or pull down and let go on your phones browser to refresh AFTER you have navigated away from the widget and the stream stops.

The other option is to just use a JPG static snapshot and use a refresh on it via the oh-image componet, it stops when you navigate away.

1 Like

This is exactly my current setup which is very sluggish.

Unfortunately this is not my use case. I have a wall mounted device and the popup appears and disappears automatically triggered by the state of a specific item.

But by writing this reply and considering this comment from you matt

that guided me to the following solution which now closes the keep-alive connection:
Simply add the following line to the config section of the page:

key: =Math.random().toString() + @@'vPopupCam'

In my case vPopupCam is the item which automatically opens/closes the popup.
(Cudos go to Yannick for this idea.)


I took the URL for my Mobotix from here:
Which Cam you are using (i am just curious - not too much Mobotic users out there :wink: )?

The streams working for me:

I implemented the stream into my HabPanel using html (widget “template”) and this is working fine.
But you want to have it in a OH thing, did I get this right?

Hi Kai,
I am using Q25 cameras.
The problem is the following.
These two methods of getting video pictures in MainUI work:

  • oh-image, which loads record/current.jpg and set the refreshinInterval in the widget
  • oh-Webframe, which loads the cgi-bin/faststream.jpg

However, these two methods use a keep-alive connection which means even though my popup, which shows the video, is closed, the camera still sends the stream. Lots of GBs are being transferred without nobody seeing the video. Not a big deal but I simply do not like it.
I was hoping to solve it with the oh-video widget but faststream.jpg does not seem to be a true mjpeg filestream.
Another option is setting up an rtsp stream. But this creates almost 1 second of latency of the video.

In the end I solved it with an img control and faststream.jpg and a key parameter in the page which forces the page to be reloaded and the connection terminates.

1 Like

got it.
I solved it in HABPanel by including a refresh into my html code:

<meta http-equiv="refresh" content="900">  <--900=15Min -->
<script type="text/javascript">
   setInterval(refreshIframe, 900);
   function refreshIframe() {
       var frame = document.getElementById("Frame");
       frame.src = frame.src;

rtsp is not really suppported by HABpanel - I spent hours searching but was not able to add a rtsp stream to openHAB (yet).