Switch a pkg installed ZM 1.30.0 to libjpeg-turbo

Forum for questions and support relating to the 1.30.x releases only.
Locked
User avatar
jacomoman
Posts: 23
Joined: Thu Jan 17, 2008 9:25 pm
Location: Silicon Valley, CA

Switch a pkg installed ZM 1.30.0 to libjpeg-turbo

Post by jacomoman »

Hi all,

I searched for this in 1.30.x board but didn't find any references to libjpeg-turbo issues. I have installed ZM 1.30.0 as per the "easy" installation instructions on Ubuntu 14.04, so using ppa:iconnor/zoneminder.

Everything is working as it should and I can see my monitors and events recorded, etc. The only thing is I noticed that the pkg'd ZM is using libjpeg and not libjpeg-turbo and with my HD 1280x720 camera in daylight conditions zmc and zma are reporting processing only 12 FPS. The camera is set to stream at 20 FPS and actually at night when its IR is on and it's all grayscale, it does it the full 20 FPS. But in daylight with full 24bit color libjpeg can only muster 12-14 FPS.

So to the question... Is there any way to switch from libjpeg to libjpeg-turbo in a pkg-installed ZM? I have a feeling the answer is "Nope, you gotta compile from sources", but I thought I'd ask anyways. If the answer is yes however, can you please point me to a step-by-step how-to?

Thanks,
Jac
User avatar
knight-of-ni
Posts: 2404
Joined: Thu Oct 18, 2007 1:55 pm
Location: Shiloh, IL

Re: Switch a pkg installed ZM 1.30.0 to libjpeg-turbo

Post by knight-of-ni »

The ppa package you are referring to has already been built against libjpeg-turbo. libjpeg-turbo has been the standard jpeg library for most popular distros, including Ubuntu, for a while now and every package automatically ends up using it.

To verify this, simply set your color space to 32bit under each monitor. 32bit colorspace requires libjpeg-turbo, and if your system is not using it, you get this warning in the logs: https://github.com/ZoneMinder/ZoneMinde ... e.cpp#L743
Visit my blog for ZoneMinder related projects using the Raspberry Pi, Orange Pi, Odroid, and the ESP8266
All of these can be found at https://zoneminder.blogspot.com/
User avatar
jacomoman
Posts: 23
Joined: Thu Jan 17, 2008 9:25 pm
Location: Silicon Valley, CA

Re: Switch a pkg installed ZM 1.30.0 to libjpeg-turbo

Post by jacomoman »

Thanks very much for your quick reply. Ok, I see. Well it certainly makes sense that libjpeg-turbo is now built-in. The reason I didn't think it was built in because when I examined the /procs/{pid}/maps for zmc it listed libjpeg:

Code: Select all

$ ps -ef | grep zmc
www-data 26211  5783 10 08:53 ?        00:01:11 /usr/bin/zmc -m 1

$ sudo cat /proc/26211/maps | grep libjpeg
7fedad783000-7fedad7c6000 r-xp 00000000 08:01 1055409                    /usr/lib/x86_64-linux-gnu/libjpeg.so.8.0.2
7fedad7c6000-7fedad9c6000 ---p 00043000 08:01 1055409                    /usr/lib/x86_64-linux-gnu/libjpeg.so.8.0.2
7fedad9c6000-7fedad9c7000 r--p 00043000 08:01 1055409                    /usr/lib/x86_64-linux-gnu/libjpeg.so.8.0.2
7fedad9c7000-7fedad9c8000 rw-p 00044000 08:01 1055409                    /usr/lib/x86_64-linux-gnu/libjpeg.so.8.0.2
So do I take it that libjpeg.so.8.0.2 is really libjpeg-turbo? If so, then do you have any guesses as to why zmc/zma reports significantly reduced FPS for this monitor, only during the day? At night, when the scene is all grayscale, it reports full FPS. But in daylight, only 12-14 FPS. Could it be the high res 1280x720? Just too much pixel data to capture/analyze?

If it really is because of high res, I'm wondering what I can do to my hardware to try and speed that up.

Thanks,
Jac
User avatar
knight-of-ni
Posts: 2404
Joined: Thu Oct 18, 2007 1:55 pm
Location: Shiloh, IL

Re: Switch a pkg installed ZM 1.30.0 to libjpeg-turbo

Post by knight-of-ni »

You stopped short of your search for libjpegturbo:

Code: Select all

abauer@ubuntu-dvr:~$ sudo apt-file update
...
abauer@ubuntu-dvr:~$ apt-file search /usr/lib/x86_64-linux-gnu/libjpeg.so.8.0.2
libjpeg-turbo8: /usr/lib/x86_64-linux-gnu/libjpeg.so.8.0.2
Visit my blog for ZoneMinder related projects using the Raspberry Pi, Orange Pi, Odroid, and the ESP8266
All of these can be found at https://zoneminder.blogspot.com/
User avatar
jacomoman
Posts: 23
Joined: Thu Jan 17, 2008 9:25 pm
Location: Silicon Valley, CA

Re: Switch a pkg installed ZM 1.30.0 to libjpeg-turbo

Post by jacomoman »

BTW, I didn't mention that I did up the RGB setting for the monitor to 32 and I didn't get that error message in the log and the monitor continued to display just fine, so that's confirmation that the ZM pkg I have is compiled against libjpeg-turbo.

I also did one other experiment... I reduced the camera's resolution to 640x360 (and same change in the monitor width/height) and sure enough, zmc/zma started processing at full 20 FPS.

So it's now pretty clear that my low FPS issue has everything to do with the high res 1280x720 camera setting being too much for the HW I'm running on. It's a surprise to me because the server I'm running this on is a pretty hefty Logic Supply industrial PC with a Intel i7-6700TE (Skylake) 2.4 GHz CPU (http://www.logicsupply.com/ml600g-52).

I'm wondering, are there hardware JPEG decoder boards that would help with this issue? I mean this is just one camera. I'd like to connect up 4, 6, or 8 high res 1280x720 cameras all around my house and have them all be streaming at 20+ FPS and do something so zmc/zma can capture & analyze at the same rate as well.

If you have any pointers or suggestions as to where to turn on getting this done I'd very much appreciated.

Thanks,
Jac
User avatar
knight-of-ni
Posts: 2404
Joined: Thu Oct 18, 2007 1:55 pm
Location: Shiloh, IL

Re: Switch a pkg installed ZM 1.30.0 to libjpeg-turbo

Post by knight-of-ni »

A typical video surveillance system can run at a high resolution, but the industry standard is to use a low frame rate. Even when you've got sufficient hardware, high frame rates just waste storage space you could otherwise use to get many more days of storage. There are some very specific cases which can benefit from a higher frame rate, but those cases are very rare, especially in a home environment.

So, instead of reducing the resolution of your camera, reduce the frame rate down to 5 fps. I can assure you that it is plenty for general surveillance.

The old video capture cards intended for surveillance have all gone the way of the 8 track player. They only work with 480i ntsc/pal video and rely on Linux drivers which are no longer maintained, so you don't want to buy one of those for a new system.

Eventually we hope to get ZoneMinder to record to a video container, rather than jpeg's, but those working on that feature are doing it in their spare time. This would definitely lessen the hardware requirements to do high frame rate, but we do not have an eta.
Visit my blog for ZoneMinder related projects using the Raspberry Pi, Orange Pi, Odroid, and the ESP8266
All of these can be found at https://zoneminder.blogspot.com/
User avatar
jacomoman
Posts: 23
Joined: Thu Jan 17, 2008 9:25 pm
Location: Silicon Valley, CA

Re: Switch a pkg installed ZM 1.30.0 to libjpeg-turbo

Post by jacomoman »

You have a good point about the HW decoding cards all but gone. But setting to a really low FPS like 5 you can really miss faster motion events, like someone walking really fast or running across the scene. zma might not even detect the motion, or even if it did it might only capture 2 or a few frames of the event. But I get your point.

Interestingly enough, the load# in ZM is approx. 1.10. When I look at top, zmc is around 9.5, zma 6.3, and total CPU:

Code: Select all

%Cpu(s):  2.5 us, 12.5 sy,  0.0 ni, 85.0 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
And my other monitor, connected to a 720x480 camera is always capturing/analyzing at 20 FPS. So it doesn't seem like the server is under heavy stress load. It doesn't even appear to be breaking a sweat. Just zmc/zma for this one camera. I'm receiving another high res camera today. I'm going to add it to this same server with the same high res settings to see if it affects the zmc/zma FPS of the other monitors.

Thanks again for all your very helpful responses.

Cheers,
Jac
User avatar
knight-of-ni
Posts: 2404
Joined: Thu Oct 18, 2007 1:55 pm
Location: Shiloh, IL

Re: Switch a pkg installed ZM 1.30.0 to libjpeg-turbo

Post by knight-of-ni »

No, that simply isn't true. A frame rate of 5 fps, is sufficient for general surveillance, without missing any part of any event.
Like a lot of surveillance softwares, ZoneMinder has pre and post buffers so you won't miss anything at all, even if someone runs (or a car drives) through the view. ZoneMinder will record the whole event, as long as you've got your motion detection tuned properly, which you need to do regardless of the frame rate.
Visit my blog for ZoneMinder related projects using the Raspberry Pi, Orange Pi, Odroid, and the ESP8266
All of these can be found at https://zoneminder.blogspot.com/
Locked