Record as video instead of jpegs

Forum for questions and support relating to the 1.29.x releases only.
antares2001
Posts: 18
Joined: Fri Apr 08, 2016 9:29 am

Record as video instead of jpegs

Post by antares2001 »

Hello,

according to SteveGilvarry's recommendation at https://github.com/ZoneMinder/ZoneMinder/issues/39 I'm creating this forum thread to get some info about how to set up Zoneminder to record videos instead of JPEGs. My basic motivation for this is limited storage capacity I have and jpeg storage eats up my disk very fast (please don't open a discussion of the kind "just get another bigger hard drive").

I've freshly installed ZM 1.29.0 on Ubuntu 16.04 according to the setup guide (which works perfectly) and have my cameras up and running. I'm using ZMNinja on my mobile devices to look at the cams from remote.

I would be very thankful if somebody could actually help me with more information about how to get recording instead of jpeg storage working, so I can save diskspace and also have videos available rather than jpegs that I can quickly watch in VLC.

Thanks a lot in advance! Keep up with this great work. ZM has replaced my Synology Surveillance Station (though I owned licenses for it) as the much better solution. Just this storage format issue keeps me giving headaches at the moment.
SteveGilvarry
Posts: 494
Joined: Sun Jun 29, 2014 1:12 pm
Location: Melbourne, AU

Re: Record as video instead of jpegs

Post by SteveGilvarry »

So I ran this to create a package on Ubuntu or Debian, uses script in Zoneminder Utils folder from memory.
do_debian_package.sh `lsb_release -a 2>/dev/null | grep Codename | awk '{print $2}'` `date +%Y%m%d`01 local feature-h264-videostorage
And then however you want to install package, I did this as I have a desktop.
sudo gdebi-gtk zoneminder_1.29.1-xenial-2016041101_amd64.deb

This process combined with wiki on Ubuntu 16.04 should be enough to get up and running.

But no warranty given so maybe have a go in a VM before you swap main box over.

And before anyone asks I have no idea how to build on Centos, which needs 3rd party repos for ffmpeg. Or for that matter any rpm building process.
Production Zoneminder 1.37.x (Living dangerously)
Random Selection of Cameras (Dahua and Hikvision)
antares2001
Posts: 18
Joined: Fri Apr 08, 2016 9:29 am

Re: Record as video instead of jpegs

Post by antares2001 »

Hello Steve,

thanks for the info.

Sorry for asking, but I'm not sure I fully got all of the instructions and due to my job my time for experiments is unfortunately not that much any more as it was in student days. Quick question: if this creates a .deb package, wouldn't it be possible to share it to the community at some download location?

I'm running into following errors:

Code: Select all

mk-build-deps: Unable to install zoneminder-build-deps at /usr/bin/mk-build-deps line 402.
mk-build-deps: Unable to install all build-dep packages
 dpkg-buildpackage -rfakeroot -D -us -uc -i -b
dpkg-buildpackage: warning: using a gain-root-command while being root
dpkg-buildpackage: source package zoneminder
dpkg-buildpackage: source version 1.29.2-xenial-2016042601
dpkg-buildpackage: source distribution xenial
dpkg-buildpackage: source changed by root <root@homeserver01>
 dpkg-source -i --before-build zoneminder_1.29.2-xenial-2016042601.orig
dpkg-buildpackage: host architecture amd64
dpkg-checkbuilddeps: error: Unmet build dependencies: apache2-dev dh-linktree cmake libavcodec-ffmpeg-dev libavformat-ffmpeg-dev libswscale-ffmpeg-dev libavutil-ffmpeg-dev libavdevice-ffmpeg-dev libbz2-dev libgcrypt-dev libjpeg-dev libmysqlclient-dev libpcre3-dev libpolkit-gobject-1-dev libv4l-dev (>= 0.8.3) libvlc-dev libdate-manip-perl libdbd-mysql-perl libphp-serialization-perl libsys-mmap-perl libjs-mootools
dpkg-buildpackage: warning: build dependencies/conflicts unsatisfied; aborting
dpkg-buildpackage: warning: (Use -d flag to override.)
debuild: fatal error at line 1376:
dpkg-buildpackage -rfakeroot -D -us -uc -i -b failed
Do you want to keep the checked out version of Zoneminder (incase you want to modify it later) [y/N]
The checked out copy has been deleted
Done!
and when I try to install the dependencies manually, I get

Code: Select all

# apt-get install python-sphinx apache2-dev dh-linktree cmake libavcodec-ffmpeg-dev libavformat-ffmpeg-dev libswscale-ffmpeg-dev libavutil-ffmpeg-dev libavdevice-ffmpeg-dev libbz2-dev libgcrypt-dev libjpeg-dev libmysqlclient-dev libpcre3-dev libpolkit-gobject-1-dev libv4l-dev libvlc-dev libdate-manip-perl libdbd-mysql-perl libphp-serialization-perl libsys-mmap-perl libjs-jquery libjs-mootools
Reading package lists... Done
Building dependency tree
Reading state information... Done
Note, selecting 'libgcrypt20-dev' instead of 'libgcrypt-dev'
E: Unable to locate package libavcodec-ffmpeg-dev
E: Unable to locate package libavformat-ffmpeg-dev
E: Unable to locate package libswscale-ffmpeg-dev
E: Unable to locate package libavutil-ffmpeg-dev
E: Unable to locate package libavdevice-ffmpeg-dev
Thanks again for the help! Appreciate it!

Yet - provision of a Debian package would be perhaps the better way also from a security standpoint as this process involves the installation of many (necessary for build) packages that I wouldn't want on a production system.
Last edited by antares2001 on Wed Apr 27, 2016 3:40 pm, edited 1 time in total.
SteveGilvarry
Posts: 494
Joined: Sun Jun 29, 2014 1:12 pm
Location: Melbourne, AU

Re: Record as video instead of jpegs

Post by SteveGilvarry »

I did at one point try to get it into a PPA, but the whole time thing affects us all.
Trim ffmpeg out of all those package names in control file so libavcodec-dev etc, it is a difference between 1504 and 1604.
Will talk to PPA owner to see if we can enable branch builds automatically, but remember branches are experimental features so if you don't have the time then maybe you are better off waiting for it to be part of release.
Production Zoneminder 1.37.x (Living dangerously)
Random Selection of Cameras (Dahua and Hikvision)
antares2001
Posts: 18
Joined: Fri Apr 08, 2016 9:29 am

Re: Record as video instead of jpegs

Post by antares2001 »

Okay -- I removed from Ubuntu1504/control the ffmpeg but still get the following:

Code: Select all

./do_debian_package.sh `lsb_release -a 2>/dev/null | grep Codename | awk '{print $2}'` `date +%Y%m%d`01 local feature-h264-videostorage
Cloning into 'zoneminder_release'...
remote: Counting objects: 58411, done.
remote: Total 58411 (delta 0), reused 0 (delta 0), pack-reused 58411
Receiving objects: 100% (58411/58411), 48.22 MiB | 11.02 MiB/s, done.
Resolving deltas: 100% (42995/42995), done.
Checking connectivity... done.
Branch feature-h264-videostorage set up to track remote branch feature-h264-videostorage from origin.
Switched to a new branch 'feature-h264-videostorage'
Doing local release zoneminder_1.29.2-xenial-2016042601
Submodule 'web/api/app/Plugin/Crud' (https://github.com/FriendsOfCake/crud.git) registered for path 'web/api/app/Plugin/Crud'
Cloning into 'web/api/app/Plugin/Crud'...
remote: Counting objects: 45207, done.
remote: Compressing objects: 100% (85/85), done.
remote: Total 45207 (delta 62), reused 0 (delta 0), pack-reused 45117
Receiving objects: 100% (45207/45207), 10.22 MiB | 8.37 MiB/s, done.
Resolving deltas: 100% (33030/33030), done.
Checking connectivity... done.
Submodule path 'web/api/app/Plugin/Crud': checked out 'c3976f1478c681b0bbc132ec3a3e82c3984eeed5'
Reading package lists... Done
Building dependency tree
Reading state information... Done
devscripts is already the newest version (2.16.2ubuntu3).
equivs is already the newest version (2.0.9+nmu1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
dh_testdir
dh_testroot
dh_prep
dh_testdir
dh_testroot
dh_install
dh_installdocs
dh_installchangelogs
dh_compress
dh_fixperms
dh_installdeb
dh_gencontrol
dh_md5sums
dh_builddeb
dpkg-deb: building package 'zoneminder-build-deps' in '../zoneminder-build-deps_1.28.1+1-vivid-SNAPSHOT2015081701_amd64.deb'.

The package has been created.
Attention, the package has been created in the current directory,
not in ".." as indicated by the message above!
Selecting previously unselected package zoneminder-build-deps.
(Reading database ... 83126 files and directories currently installed.)
Preparing to unpack zoneminder-build-deps_1.28.1+1-vivid-SNAPSHOT2015081701_amd64.deb ...
Unpacking zoneminder-build-deps (1.28.1+1-vivid-SNAPSHOT2015081701) ...
Reading package lists... Done
Building dependency tree
Reading state information... Done
Correcting dependencies...Starting pkgProblemResolver with broken count: 1
Starting 2 pkgProblemResolver with broken count: 1
Investigating (0) zoneminder-build-deps [ amd64 ] < 1.28.1+1-vivid-SNAPSHOT2015081701 > ( devel )
Broken zoneminder-build-deps:amd64 Depends on libavcodec-ffmpeg-dev [ amd64 ] < none > ( none )
  Removing zoneminder-build-deps:amd64 because I can't find libavcodec-ffmpeg-dev:amd64
So it seems not to care about the control file. Or is it another control file than Ubuntu1504?

Thanks a lot for your effort.
Last edited by antares2001 on Wed Apr 27, 2016 3:40 pm, edited 1 time in total.
SteveGilvarry
Posts: 494
Joined: Sun Jun 29, 2014 1:12 pm
Location: Melbourne, AU

Re: Record as video instead of jpegs

Post by SteveGilvarry »

Something is not right it started out "Doing local release zoneminder_1.29.2-xenial-2016042601", then actually works on a 1.28.1 release
dpkg-deb: building package 'zoneminder-build-deps' in '../zoneminder-build-deps_1.28.1+1-vivid-SNAPSHOT2015081701_amd64.deb'.
Let me get the control file fixed.
Production Zoneminder 1.37.x (Living dangerously)
Random Selection of Cameras (Dahua and Hikvision)
SteveGilvarry
Posts: 494
Joined: Sun Jun 29, 2014 1:12 pm
Location: Melbourne, AU

Re: Record as video instead of jpegs

Post by SteveGilvarry »

Did you keep zoneminder_release and make the changes in there?
Production Zoneminder 1.37.x (Living dangerously)
Random Selection of Cameras (Dahua and Hikvision)
antares2001
Posts: 18
Joined: Fri Apr 08, 2016 9:29 am

Re: Record as video instead of jpegs

Post by antares2001 »

Ah - that's the fix. Didn't keep the directory and changed in the upper directory path.

Yup - the 1.28 actually also made me wonder a bit. Thanks for your help and the fix. It's currently building. Will let you know what the result is.
antares2001
Posts: 18
Joined: Fri Apr 08, 2016 9:29 am

Re: Record as video instead of jpegs

Post by antares2001 »

Okay -- compilation worked, but installation fails due to the fact that Ubuntu packages PHP7 instead of PHP5:

Code: Select all

Selecting previously unselected package zoneminder.
(Reading database ... 84660 files and directories currently installed.)
Preparing to unpack zoneminder_1.29.2-xenial-2016042601_amd64.deb ...
Unpacking zoneminder (1.29.2-xenial-2016042601) ...
dpkg: dependency problems prevent configuration of zoneminder:
 zoneminder depends on php5-mysql; however:
  Package php5-mysql is not installed.

dpkg: error processing package zoneminder (--install):
 dependency problems - leaving unconfigured
Processing triggers for man-db (2.7.5-1) ...
Processing triggers for ureadahead (0.100.0-19) ...
Processing triggers for systemd (229-4ubuntu4) ...
Errors were encountered while processing:
 zoneminder
Selecting previously unselected package zoneminder-dbg.
(Reading database ... 92906 files and directories currently installed.)
Preparing to unpack zoneminder-dbg_1.29.2-xenial-2016042601_amd64.deb ...
Unpacking zoneminder-dbg (1.29.2-xenial-2016042601) ...
dpkg: dependency problems prevent configuration of zoneminder-dbg:
 zoneminder-dbg depends on zoneminder (= 1.29.2-xenial-2016042601); however:
  Package zoneminder is not configured yet.

dpkg: error processing package zoneminder-dbg (--install):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 zoneminder-dbg
(Reading database ... 92922 files and directories currently installed.)
Preparing to unpack zoneminder-doc_1.29.2-xenial-2016042601_all.deb ...
Unpacking zoneminder-doc (1.29.2-xenial-2016042601) over (1.29.2-xenial-2016042601) ...
Setting up zoneminder-doc (1.29.2-xenial-2016042601) ...
and

Code: Select all

root@homeserver01:/tmp/ZoneMinder/utils# apt-get install php7.0-mysql
Reading package lists... Done
Building dependency tree
Reading state information... Done
php7.0-mysql is already the newest version (7.0.4-7ubuntu2).
php7.0-mysql set to manually installed.
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
 zoneminder : Depends: php5-mysql but it is not installable
              Recommends: libapache2-mod-php5 but it is not installable or
                          php5-fpm but it is not installable
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).
After changing the dependencies to PHP7.0 in the control file, it still makes some trouble with regards to mysql (which is not yet clear to me as this means the database needs set up before installation?!)

Code: Select all

Setting up zoneminder (1.29.2-xenial-2016042601) ...
DBI connect('database=zm;host=localhost','zmuser',...) failed: Unknown database 'zm' at /usr/share/perl5/ZoneMinder/Config.pm line 90.
Can't connect to db at /usr/share/perl5/ZoneMinder/Config.pm line 113.
BEGIN failed--compilation aborted at /usr/share/perl5/ZoneMinder/Config.pm line 113.
Compilation failed in require at /usr/bin/zmupdate.pl line 71.
BEGIN failed--compilation aborted at /usr/bin/zmupdate.pl line 71.
dpkg: error processing package zoneminder (--configure):
 subprocess installed post-installation script returned error exit status 255
dpkg: dependency problems prevent configuration of zoneminder-dbg:
 zoneminder-dbg depends on zoneminder (= 1.29.2-xenial-2016042601); however:
  Package zoneminder is not configured yet.

dpkg: error processing package zoneminder-dbg (--configure):
 dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup error from a previous failure.
                                                                                                          Setting up libpackage-stash-xs-perl (0.28-2build2) ...
Processing triggers for ureadahead (0.100.0-19) ...
Processing triggers for systemd (229-4ubuntu4) ...
Errors were encountered while processing:
 zoneminder
 zoneminder-dbg
E: Sub-process /usr/bin/dpkg returned an error code (1)
But getting closer ;-)
SteveGilvarry
Posts: 494
Joined: Sun Jun 29, 2014 1:12 pm
Location: Melbourne, AU

Re: Record as video instead of jpegs

Post by SteveGilvarry »

Should be able to follow this process mostly now, except for the apt-get install zoneminder bit.
https://wiki.zoneminder.com/Ubuntu_Serv ... e_easy_way
Production Zoneminder 1.37.x (Living dangerously)
Random Selection of Cameras (Dahua and Hikvision)
antares2001
Posts: 18
Joined: Fri Apr 08, 2016 9:29 am

Re: Record as video instead of jpegs

Post by antares2001 »

Thanks a lot, Steve!

Indeed it's necessary to execute the MariaDB install commands (the files are present in /usr/share/zoneminder) though the package wasn't properly installed. Subsequently another install of the package works and apt-get / dpkg are happy.

Yet, on a fresh Ubuntu 16.04 I'm facing an issue with the Systemd service, where it says:

Code: Select all

# service zoneminder start
Failed to start zoneminder.service: Unit zoneminder.service is masked.
and I must admit that since I'm totally new to Systemd I have no idea how to fix that, yet. Trying some Google but no success, yet. In /usr/lib/systemd and subdirectories there's no zoneminder.service.

EDIT:
It's as easy as

Code: Select all

systemctl unmask zoneminder
Thanks a lot once more for your support! Was able to get Zoneminder running in the browser. Now have to check whether API works and then set the cameras up and keep fingers crossed it records videos to disk :-)

Many thanks and keep this great work going!
antares2001
Posts: 18
Joined: Fri Apr 08, 2016 9:29 am

Re: Record as video instead of jpegs

Post by antares2001 »

Okay - unfortunately it's not yet working. I don't see a picture of the cameras in monitor mode (just a symbol of broken image) and the logs report errors like these:

Code: Select all

2016-04-27 11:20:31.971146	zmc_m2		4861	FAT	Error occurred when writing output file header to events/2/16/04/27/11/20/01/7-video.mp4: Invalid argument	zm_videostore.cpp	140
2016-04-27 11:20:31.970076	zmc_m2		4861	INF	Opening video storage stream events/2/16/04/27/11/20/01/7-video.mp4 format: -394720175
2016-04-27 11:13:45.970943	zmc_m2		3198	WAR	Unable to parse ffmpeg option 0 '', expecting key=value	zm_ffmpeg_camera.cpp	273
Is there any dependency missing? I have ffmpeg installed and am clueless at the moment.
aljabr
Posts: 19
Joined: Wed Apr 27, 2016 8:07 am

Re: Record as video instead of jpegs

Post by aljabr »

i don't know any thing :) but a remainder did you check the path of ffmpeg ?
antares2001
Posts: 18
Joined: Fri Apr 08, 2016 9:29 am

Re: Record as video instead of jpegs

Post by antares2001 »

Yup - ffmpeg is installed and the path is set correctly. And there is no parameter for ffmpeg defined on the web ui (so I don't get the meaning of ffmpeg option 0 '' part).
antares2001
Posts: 18
Joined: Fri Apr 08, 2016 9:29 am

Re: Record as video instead of jpegs

Post by antares2001 »

When choosing encoding instead of passthrough, it says in the logs:

Code: Select all

2016-04-27 11:59:18.563791	zma_m2		9697	ERR	ZoneMinder was not compiled with the X264 MP4 video writer, check dependencies (x264 and mp4v2)	zm_event.cpp	195
Any clue how to get that working? On building deb package I didn't see where to specify that compile option.

Interestingly - though I don't see neither a live nor record picture - it seems to capture events (shown in event list).
Locked