motion icon indicating copy to clipboard operation
motion copied to clipboard

RSTP/RTSP broken in current master

Open drewzh opened this issue 11 years ago • 7 comments

Motions records perfectly for a good hour, producing great videos, performance is miles better than using HTTP for me with my cheap chinese IP cam, then, all of a sudden, errors start pouring in and my system becomes slower and slower until it eventually dies a horrible SSH unreachable death.

Network camera is perfectly reachable whilst these errors are occuring, I can start multiple streams fine, even from the same box motion is running on (raspberrypi running Arch Linux). It takes around 2 hours for the system to become completely unresponsive and motion stops recording entirely.

I've gone back to http method in the meantime but I'm eagerly awaiting working RTSP support as I get a massive performance increase.

The logs looks like so..

Jun 09 20:30:51 alarmpi motion[325]: [1] [ERR] [NET] netcam_handler_loop: Error getting jpeg image Jun 09 20:30:51 alarmpi motion[325]: [1] [ERR] [NET] netcam_read_rtsp_image: invalid frame!: Broken pipe Jun 09 20:30:51 alarmpi motion[325]: [1] [ERR] [NET] netcam_handler_loop: Error getting jpeg image Jun 09 20:30:51 alarmpi motion[325]: [1] [ERR] [NET] netcam_read_rtsp_image: invalid frame!: Broken pipe Jun 09 20:30:51 alarmpi motion[325]: [1] [ERR] [NET] netcam_handler_loop: Error getting jpeg image Jun 09 20:30:51 alarmpi motion[325]: [1] [ERR] [NET] netcam_read_rtsp_image: invalid frame!: Broken pipe Jun 09 20:30:51 alarmpi motion[325]: [1] [ERR] [NET] netcam_handler_loop: Error getting jpeg image Jun 09 20:30:51 alarmpi motion[325]: [1] [ERR] [NET] netcam_read_rtsp_image: invalid frame!: Broken pipe Jun 09 20:30:52 alarmpi motion[325]: [1] [ERR] [NET] netcam_handler_loop: Error getting jpeg image Jun 09 20:30:53 alarmpi motion[325]: [1] [ERR] [NET] netcam_read_rtsp_image: invalid frame!: Broken pipe Jun 09 20:30:53 alarmpi motion[325]: [1] [ERR] [NET] netcam_handler_loop: Error getting jpeg image Jun 09 20:30:54 alarmpi motion[325]: [1] [ERR] [NET] netcam_read_rtsp_image: invalid frame!: Broken pipe Jun 09 20:30:55 alarmpi motion[325]: [1] [ERR] [NET] netcam_handler_loop: Error getting jpeg image Jun 09 20:30:55 alarmpi motion[325]: [1] [ERR] [NET] netcam_read_rtsp_image: invalid frame!: Broken pipe Jun 09 20:30:55 alarmpi motion[325]: [1] [ERR] [NET] netcam_handler_loop: Error getting jpeg image Jun 09 20:30:56 alarmpi motion[325]: [1] [ERR] [NET] netcam_read_rtsp_image: invalid frame!: Broken pipe Jun 09 20:30:56 alarmpi motion[325]: [1] [ERR] [NET] netcam_handler_loop: Error getting jpeg image Jun 09 20:30:57 alarmpi motion[325]: [1] [ERR] [NET] netcam_read_rtsp_image: invalid frame!: Broken pipe Jun 09 20:30:57 alarmpi motion[325]: [1] [ERR] [NET] netcam_handler_loop: Error getting jpeg image Jun 09 20:30:58 alarmpi motion[325]: [1] [ERR] [NET] netcam_read_rtsp_image: invalid frame!: Broken pipe

drewzh avatar Jun 10 '14 21:06 drewzh

I'd invite testers to try my fork for RTSP fixes. If functional, I can see if I can figure out how to create a pull request for the trunk.

Mr-Dave avatar Jun 14 '14 05:06 Mr-Dave

@drewzh , yes, similar issues have been discussed in mail list: http://sourceforge.net/p/motion/mailman/message/32337736/. Looks like we need "rtsp reconnect" functionality to restore disconnected stream. I tried, but unsuccessfully. Wish someone with ffmpeg+RTSP knowledge can sort this out

@Mr-Dave , I'm happy to do the tests. However, I tried to go through your code changes and so far there is a lot of noise, like space/tab indentions, which makes it hard to understand - what significant changes have been done? But I will try to build your fork to see if makes any improvement for RTSP

tosiara avatar Jun 14 '14 08:06 tosiara

@Mr-Dave I've actually compiled and I'm currently running your branch. The errors indicated in this ticket seem to have subsided with your code and I've found no issues when it's working.

Unfortunately the resource issue still exists, I'm going to revert to HTTP and see if it still exists. Unfortunately it's difficult to track down as I have to monitor it for hours. I can't get valgrind to run on the raspberry pi to detect memory leaks.

Anybody have a suggestion?

drewzh avatar Jun 14 '14 09:06 drewzh

Sorry about the noise. My code editor thinks it knows better and my first time with git. Issues addressed in my branch are added RTSP basic authentication, RTSP reconnect, new configure and compiler flags for identification of ffmpeg. Regarding resources, try to INCREASE your frame rate in your config. The motion sleep function currently implemented is very precise but also very CPU intensive.

Mr-Dave avatar Jun 14 '14 15:06 Mr-Dave

My pi runs steady at around 50-60% CPU at 640x320@5fps , at the moment I'm thinking it's probably a memory issue but haven't yet found the time to test again. I have seen it climb to 80% memory usage (used by motion) and shortly after i was unable to get a response. I'm going to have another play tomorrow, but thanks for the tip about the sleep function affecting CPU usage.

drewzh avatar Jun 14 '14 17:06 drewzh

@Mr-Dave your latest master fixes this issue, thanks very much for your contribution; you've made my home security work again! :+1:

drewzh avatar Jun 19 '14 08:06 drewzh

@drewzh cool, thanks for testing. I'm going also review functional changes (so far only related to netcam and rtsp) and create experimental branch @Mr-Dave keep coding! :)

tosiara avatar Jun 23 '14 15:06 tosiara