Need help, Video stuck - camera RTSP, ipcamera binding

I have a problem with the video getting stuck or working for a second and disappearing in habpanel
I use openhabian RPi4
I made an update to the system and to JAVA and also to ffmpeg

My internet is fine and through the camera app it looks fine
If I enter this address through the browser on the computer then the video does not hang and you see properly:
http: //192.168.1.**: *** / ipcamera.mjpeg

These are settings I have set up maybe someone can help me please:

no one can help me?

You seem to be setting up ffserver which is not needed and if it is running it will be drawing a LOT of cpu power. 32 frames a second with potentially 3 camera streams may be too much. You need to experiment to see what it can handle or get a more powerful server.

1 Like

I only have 2 cameras.
And if I delete ffserver will it help?

Give it a try. You can also see how much cpu is being used under Linux by typing in ‘htop’. Lower your frame rate and resolution in the cameras settings, get it working and then try to increase it to see what works.

You can also use the snapshots.mjpeg which depending on the camera uses far less cpu for displaying a thumbnail with.

The ffmpeg shows between 200 and 300. How do I delete the ffmpeg file? If I try through ftp software then it registers me a permissions issue

I have a laptop that I do not use, if I install linux on it and openhab on it then it will work better?

You have not given much detail.

  1. What camera?
  2. What resolution and framerate is the camera set to?
  3. What kind of laptop?

I can only assume it is high res and 32 frames per second and there is no hope of a PI4 doing that for 2 cameras, in fact I doubt an old laptop can either and you probably need to ask advice from people that do this.

You can do it on the PI4 if you lower the framerate and resolutiuon, if that is something you dont wish to do, then either buy a camera that has mjpeg on it by default, buy a big video server or use HLS streaming which wont need lots of CPU to create it. Lots of options, you just need to choose what is right for you.

  1. wyze cam v2
  2. Where do I choose the resolution?
  3. asus k54c

I lowered the frame to 10 and the problem was not resolved

Refer to your cameras manual, website and support. I doubt you changed the framerate in the correct place if you are asking this question. They will both be together and usually there is a web page you login with using the IP of the camera.

Did you try snapshots.mjpeg instead of ipcamera.mjpeg?

Also it is very strange that you wrote it works in a web browser but not in habpanel, possibly it may be another widget causing the page to refresh. May be worth putting the widget on its own page for testing.

I suspect that when the camera stops working you will see the CPU hit 100% usage with the htop command, that will confirm the cause or rule it out.

@razserv2010
Can you try setting this option in the binding please? I had a play tonight and this lowered CPU down and gave improvements.

FFMPEG_MJPEG_ARGUMENTS="-q:v 5 -r 2 -vf scale=480:-2 -update 1" 

If you setup the binding with paperUI, you need to click on show more? to see the advanced options.

thanks,
I changed what you wrote,
The quality has dropped a bit but the problem is still unresolved and the cpu stands at 200

Can you confirm that it works great when you enter http: //192.168.1.**: *** / ipcamera.mjpeg into your browser? So this is only when watching in Habpanel? Is that the same browser or is Habpanel running on a different device and browser to the working one?

The address directly in the browser works.
And I’m trying on the same browser, on PC 1

  • I restarted rpi4 and one camera seems to be working fine but when I add another camera in the same window in habpanel then still the same problem.

update**
It seems to me that the problem has been solved:
I deleted the second camera and redefined it
And in “FFMPEG_OUTPUT” I gave it a new path (different from the first camera)
But through HLS do not see anything, I tried to put in VLC also the address but I get a software error

That’s good mjpeg is now fixed/working. It does not create files like HLS does so that is a completely different case.

HLS needs a folder with correct permissions for the Openhab user to access plus the drive needs to be able to keep up. If your using a micro sd card to put the HLS files onto you should try a tmpfs folder as the readme outlines.

You can get feedback of any issues in DEBUG log output, you won’t see any issues that ffmpeg is reporting unless you enable debug.

Can you tell me please what’s wrong here in the log?

> 2020-08-19 00:43:10.919 [DEBUG] [pcamera.internal.StreamServerHandler] - Stream Server recieved request 	GET:/ipcamera.mjpeg
> 
> 2020-08-19 00:43:10.919 [DEBUG] [pcamera.internal.StreamServerHandler] - Stream Server recieved request 	GET:/ipcamera.mjpeg
> 
> 2020-08-19 00:43:10.921 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] - Starting ffmpeg with this command now:/usr/bin/ffmpeg -rtsp_transport tcp -hide_banner -loglevel warning -i rtsp://****:*****@192.168.1.31/live -q:v 5 -r 3 -vf scale=360:-2 -update 1 http://127.0.0.1:8888/ipcamera.jpg
> 
> 2020-08-19 00:43:10.923 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] - Starting ffmpeg with this command now:/usr/bin/ffmpeg -rtsp_transport tcp -hide_banner -loglevel warning -i rtsp://****:*****@192.168.1.49/live -q:v 5 -r 3 -vf scale=360:-2 -update 1 http://127.0.0.1:8889/ipcamera.jpg
> 
> 2020-08-19 00:43:13.222 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] - Guessed Channel Layout for Input Stream #0.1 : mono
> 
> 2020-08-19 00:43:13.332 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] - [swscaler @ 0x8f2d50] deprecated pixel format used, make sure you did set range correctly
> 
> 2020-08-19 00:43:15.088 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] - Guessed Channel Layout for Input Stream #0.1 : mono
> 
> 2020-08-19 00:43:15.317 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] - [swscaler @ 0x89da90] deprecated pixel format used, make sure you did set range correctly
> 
> 2020-08-19 00:43:17.873 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] - More than 1000 frames duplicated
> 
> 2020-08-19 00:43:32.918 [TRACE] [pcamera.internal.StreamServerHandler] - Connection reset by peer.
> 
> 2020-08-19 00:43:32.921 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - All Mjpeg streams have stopped, cleaning up now
> 
> 2020-08-19 00:43:32.924 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] - Stopping ffmpeg MJPEG now
> 
> 2020-08-19 00:43:33.319 [TRACE] [pcamera.internal.StreamServerHandler] - Connection reset by peer.
> 
> 2020-08-19 00:43:33.320 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - All Mjpeg streams have stopped, cleaning up now
> 
> 2020-08-19 00:43:33.321 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] - Stopping ffmpeg MJPEG now
> 
> 2020-08-19 00:43:33.328 [DEBUG] [pcamera.internal.StreamServerHandler] - Stream Server recieved request 	GET:/ipcamera.mjpeg
> 
> 2020-08-19 00:43:33.329 [DEBUG] [pcamera.internal.StreamServerHandler] - Stream Server recieved request 	GET:/ipcamera.mjpeg
> 
> 2020-08-19 00:43:33.331 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] - Starting ffmpeg with this command now:/usr/bin/ffmpeg -rtsp_transport tcp -hide_banner -loglevel warning -i rtsp://****:*****@192.168.1.31/live -q:v 5 -r 3 -vf scale=360:-2 -update 1 http://127.0.0.1:8888/ipcamera.jpg
> 
> ==> /var/log/openhab2/events.log <==
> 
> 2020-08-19 00:43:35.596 [vent.ItemStateChangedEvent] - shelly_shelly1_500291f09324_device_wifiSignal changed from 3 to 2
> 
> ==> /var/log/openhab2/openhab.log <==
> 
> 2020-08-19 00:43:35.916 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] - Guessed Channel Layout for Input Stream #0.1 : mono
> 
> 2020-08-19 00:43:36.083 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] - [swscaler @ 0x73c3a0] deprecated pixel format used, make sure you did set range correctly
> 
> ==> /var/log/openhab2/events.log <==
> 
> 
> 2020-08-19 00:43:58.331 [DEBUG] [pcamera.internal.StreamServerHandler] - Stream server is going to close an idle channel.
> 
> 2020-08-19 00:43:58.334 [DEBUG] [ing.ipcamera.handler.IpCameraHandler] - All Mjpeg streams have stopped, cleaning up now

Try adding -an as an option for ffmpeg as it is looking at the audio track which mjpeg can not use. Something is closing the http connection before it should and it may be The audio track causing it or totally unrelated. You mentioned that is was working so what has changed? Any settings different in the camera?

It also may be the web browser not wanting to wait patiently for the requested stream if ffmpeg is taking too long to create it. Try a different browser for testing.

I did not make any changes to the camera but today the video disappeared after a second it appears so I went into the log and saw it

It may be related to opening two streams that ffmpeg has to create both at the same time. Could be hitting 100% cpu or it may be the browser is not waiting long enough for the stream as ffmpeg takes too long to produce it. Try with only one opening and if that fixes it you need to make a call which way you want to handle it. Personally I use the autofps.mjpeg stream for the thumbnails and it only opens up the full stream if I click on the thumbnail.

From your previous posts your opening the full stream from two cameras the moment the page opens for the thumbnail views.

Edit:
Did you push refresh on the browser at that point in time or have something doing an auto refresh?

It’s I did a refresh.
And where exactly do I add the -an?