Saving h264 using feature-h264-videostorage

If you've made a patch to quick fix a bug or to add a new feature not yet in the main tree then post it here so others can try it out.
Vaso
Posts: 6
Joined: Mon Sep 19, 2016 6:31 am

Re: Saving h264 using feature-h264-videostorage

Post by Vaso »

Code: Select all

SQL-ERR 'SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'LinkedMonitors' cannot be null'
-- the same error with mariadb-server-10.0.

zoneminder 1.30.7-xenial-20160915
and
mariadb-server 10.0.25-0ubuntu0.16.04.1
have being removed totally with --purge and installed again.
User avatar
iconnor
Posts: 2880
Joined: Fri Oct 29, 2010 1:43 am
Location: Toronto
Contact:

Re: Saving h264 using feature-h264-videostorage

Post by iconnor »

To anyone having the LinkedMonitors cannot be NULL problem:

Your db has not been updated.

try zmupdate.pl
then zmupdate.pl -f

If that doesn't fix it, you may have to manually apply the updates in /usr/share/zoneminder/db/zm_update-1.30.*.sql

Specifically zm_update-1.30.4.sql allows various columns to be NULL.
abi
Posts: 61
Joined: Fri Oct 23, 2015 11:25 am

Re: Saving h264 using feature-h264-videostorage

Post by abi »

Should I write my issue with mp4 containers to github? It looks not like configuration problem.
SteveGilvarry
Posts: 494
Joined: Sun Jun 29, 2014 1:12 pm
Location: Melbourne, AU

Re: Saving h264 using feature-h264-videostorage

Post by SteveGilvarry »

Abi from the error it is complaining about pixel format, not sure what would be causing that. If this is on FreeBSD can you try Ubuntu. No idea if that is the cause, but seems to me a major difference that might be impacting based on your history of working on FreeBSD. There is a function in there to convert to correct format for h264, maybe something there going wrong. You are right there is not much debugging code in zm_video, but I have not been working on that side just integrated someone else's branch to bring support for both options together.

Free free to add some debugging to see if you can work out what is going wrong on the encode step. I am personally aware of 2 others besides myself that encoding does work for so, could be camera specific. You can also run passthrough and still get analysis JPEGS.
Production Zoneminder 1.37.x (Living dangerously)
Random Selection of Cameras (Dahua and Hikvision)
Vaso
Posts: 6
Joined: Mon Sep 19, 2016 6:31 am

Re: Saving h264 using feature-h264-videostorage

Post by Vaso »

iconnor wrote:To anyone having the LinkedMonitors cannot be NULL problem:

Your db has not been updated.
I've drop db before reinstalling Zoneminder and create it again in this way:

Code: Select all

mysql -uroot -p < /usr/share/zoneminder/db/zm_create.sql
and get the "NULL" issue.

Something wrong with zm_create.sql?

However, I roll back to 1.30 [iconnor/zoneminder], add monitors and then upgrade to 1.30.7 [iconnor/zoneminder-storageareas], and now I able to add new monitors.

I see mp4 files in /events directory and can play events in browser, but do not see any picture in montage:

Code: Select all

ERR [Attempt to fetch boolean value for ZM_WEB_CONSOLE_BANNER, actual type is string. Try running 'zmupdate.pl -f' to reload config.]
zmupdate.pl -f -- does nothing.

Also I have a hundred repeating errors in syslog such as:

Code: Select all

zmdc[*]: ERR ['zma -m 1' exited abnormally, exit status 255]
and

Code: Select all

web_php[*]: ERR [socket_sendto( /var/run/zm/zms-*s.sock ) failed: No such file or directory]
Vaso
Posts: 6
Joined: Mon Sep 19, 2016 6:31 am

Re: Saving h264 using feature-h264-videostorage

Post by Vaso »

Meanwhile, zmNinja on my android shows all monitors, but events, from monitors with enabled 'videostorage' option, doesn’t.
Vaso
Posts: 6
Joined: Mon Sep 19, 2016 6:31 am

Re: Saving h264 using feature-h264-videostorage

Post by Vaso »

I found that more than a half of mp4 records are broken:

Code: Select all

> cvlc ./2376-video.mp4
VLC media player 2.2.2 Weatherwax (revision 2.2.2-0-g6259d80)
[0000000000c0f198] dummy interface: using the dummy interface module...
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7f2db4c38ee0] moov atom not found
[00007f2db4c01788] avformat demux error: Could not open ./2376-video.mp4: Unknown error 1094995529
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7f2dc4c15aa0] moov atom not found
[mpeg2video @ 0x7f2db4cb6620] sequence header damaged
[mpeg2video @ 0x7f2db4ce7e60] aspect ratio has forbidden 0 value
[mpeg2video @ 0x7f2db4ce7e60] matrix damaged
[mpeg2video @ 0x7f2db4ce7e60] sequence header damaged
I managed to repair them by this tool:

Code: Select all

untrunc working-video.mp4 broken-video.mp4
from https://github.com/ponchio/untrunc

Hope this helps.
abi
Posts: 61
Joined: Fri Oct 23, 2015 11:25 am

Re: Saving h264 using feature-h264-videostorage

Post by abi »

SteveGilvarry wrote:Abi from the error it is complaining about pixel format, not sure what would be causing that. If this is on FreeBSD can you try Ubuntu. No idea if that is the cause, but seems to me a major difference that might be impacting based on your history of working on FreeBSD. There is a function in there to convert to correct format for h264, maybe something there going wrong. You are right there is not much debugging code in zm_video, but I have not been working on that side just integrated someone else's branch to bring support for both options together.

Free free to add some debugging to see if you can work out what is going wrong on the encode step. I am personally aware of 2 others besides myself that encoding does work for so, could be camera specific. You can also run passthrough and still get analysis JPEGS.
I don't think that this is the root of the problem, it's just indication that the track is empty - it doesn't contain anything, so no pixel format as well. Ubunty is not the option as I'm maintaining ZoneMinder port for FreeBSD, so I'm interested to get things working on that platform :) However, sometimes I have a feeling that I'm the only person who use this port :roll:

I switched one camera in ffmpeg/h.264 mode and I can tell that passthrough is working. However, is this mode suitable for mocord usage, is detection still possible? I thought ZM works like source -> jpeg -> analisys -> log, so it has nothing to analyze if we make dumb passthrough.
1. h264 Passthrough - Passes FFmpeg cameras h264 packets direct to an mp4 container. Best used in Record mode.
Or reference to Record mode means record and mocord, but not modect?

I found some php code that can generate frames from mp4, but it's very broken, not sure if it used.
https://github.com/ZoneMinder/ZoneMinde ... s.php#L962
1. $Event is undefined
2. system() uses 2 parameters, not 3
Last edited by abi on Sun Sep 25, 2016 10:58 am, edited 1 time in total.
abi
Posts: 61
Joined: Fri Oct 23, 2015 11:25 am

Re: Saving h264 using feature-h264-videostorage

Post by abi »

I re-read the first post and noticed
If you have some non h264 capable cameras and want to use the h264 encode function you need to install libx264-dev and libmp4v2-dev or whatever are your distro equivalents.
Is -dev indicating that developers versions are needed ?
Currently we have:
http://www.freshports.org/multimedia/mp4v2/ and http://www.freshports.org/multimedia/libx264/ Is Linux uses more recent library versions?
Looks like mp4v2 project is dead, I can't find source code as it was hosted on google code.
janisii
Posts: 8
Joined: Tue Oct 18, 2016 12:30 pm

Re: Saving h264 using feature-h264-videostorage

Post by janisii »

Hi, looking for help. Thanks :)

viewtopic.php?f=36&t=25383
XabiX
Posts: 13
Joined: Thu Feb 02, 2017 4:31 pm

Re: Saving h264 using feature-h264-videostorage

Post by XabiX »

Hello,

This seems what I am looking for. I have currently 4 Hikvision cameras in h264 1920*1080p 25fps and this drives my CPU crazy therefore if the video could be displayed without being treated as jpg that would be awesome. I use ZM to combine the views on a PC, recording is done directly from the cameras into a shared NAS.

Why not merging this feature in the main branch and potentially just mark this option as experimental so people can test/evaluate it. I do believe more and more cameras will benefit for this as camera do get a lot of pixels nowadays.

Merci

Code: Select all

  1  [#######################################################################**********               78.9%]   Tasks: 200, 758 thr; 14 running
  2  [#########################################################################*********              80.7%]   Load average: 7.11 3.80 4.25  
  3  [############################################################***************                     73.3%]   Uptime: 18 days, 13:53:47
  4  [|##########################################################################*******              80.4%]
  5  [#########################################################################*********              80.5%]
  6  [######################################################################*********                 77.5%]
  7  [###############################################################################################100.0%]
  8  [#########################################################################*********              79.3%]
  Mem[|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||#13.6G/15.5G]
  Swp[||||||||||||||||||||                                                                      1.51G/7.88G]

  PID USER      PRI  NI  VIRT   RES   SHR S CPU% MEM%   TIME+  Command                                                                                                                                                        
 9383 xabix      20   0 1441M  619M  567M S 118.  3.9  8h02:55 /opt/google/chrome/chrome --type=renderer --field-trial-handle=1 --primordial-pipe-token=5CFBD5B6B4662D2259DA561119E7D6AD --lang=en-US --enable-offline-auto-re
 2190 xabix      20   0 8407M 7809M  5924 R 101. 49.1  6h11:31 /usr/lib/x86_64-linux-gnu/hud/hud-service
  660 www-data   20   0 1344M  394M  313M S 62.6  2.5  0:48.92 /usr/bin/zmc -m 7
  654 www-data   20   0 1342M  389M  313M S 58.0  2.4  0:44.35 /usr/bin/zmc -m 6
10141 xabix      20   0  511M  109M 88548 R 43.3  0.7  2h32:36 /opt/google/chrome/chrome --type=gpu-process --field-trial-handle=1 --supports-dual-gpus=false --gpu-driver-bug-workarounds=1,7,8,10,23,28,61,74,97 --disable-g
  649 www-data   20   0 1343M  393M  313M S 37.3  2.5  0:30.42 /usr/bin/zmc -m 5
  830 www-data   20   0  693M  322M  310M R 33.3  2.0  0:13.98 /usr/lib/zoneminder/cgi-bin/nph-zms
  669 www-data   20   0 1344M  396M  313M R 32.6  2.5  0:24.94 /usr/bin/zmc -m 8                  
  831 www-data   20   0  693M  322M  310M R 32.0  2.0  0:13.75 /usr/lib/zoneminder/cgi-bin/nph-zms
  833 www-data   20   0  693M  322M  310M S 30.0  2.0  0:12.93 /usr/lib/zoneminder/cgi-bin/nph-zms
  832 www-data   20   0  693M  322M  310M R 29.3  2.0  0:13.68 /usr/lib/zoneminder/cgi-bin/nph-zms
10066 xabix      20   0 1798M  176M 60996 S 26.0  1.1  2h16:44 /opt/google/chrome/chrome
 9391 xabix      20   0 1441M  619M  567M S 24.0  3.9  1h28:27 /opt/google/chrome/chrome --type=renderer --field-trial-handle=1 --primordial-pipe-token=5CFBD5B6B4662D2259DA561119E7D6AD --lang=en-US --enable-offline-auto-re
 9392 xabix      20   0 1441M  619M  567M R 23.3  3.9  1h28:22 /opt/google/chrome/chrome --type=renderer --field-trial-handle=1 --primordial-pipe-token=5CFBD5B6B4662D2259DA561119E7D6AD --lang=en-US --enable-offline-auto-re
 9390 xabix      20   0 1441M  619M  567M S 22.0  3.9  1h28:41 /opt/google/chrome/chrome --type=renderer --field-trial-handle=1 --primordial-pipe-token=5CFBD5B6B4662D2259DA561119E7D6AD --lang=en-US --enable-offline-auto-re
 9389 xabix      20   0 1441M  619M  567M S 21.3  3.9  1h28:23 /opt/google/chrome/chrome --type=renderer --field-trial-handle=1 --primordial-pipe-token=5CFBD5B6B4662D2259DA561119E7D6AD --lang=en-US --enable-offline-auto-re
10107 xabix      20   0 1802M  176M 61000 R 18.0  1.1  1h15:47 /opt/google/chrome/chrome     
 1289 root       20   0  566M 90948 69336 S  9.3  0.6  2h13:02 /usr/lib/xorg/Xorg -core :0 -seat seat0 -auth /var/run/lightdm/root/:0 -nolisten tcp vt7 -novtswitch               
 9387 xabix      20   0 1441M  619M  567M S  9.3  3.9 33:15.35 /opt/google/chrome/chrome --type=renderer --field-trial-handle=1 --primordial-pipe-token=5CFBD5B6B4662D2259DA561119E7D6AD --lang=en-US --enable-offline-auto-re
 9385 xabix      20   0 1441M  619M  567M R  6.7  3.9 26:17.11 /opt/google/chrome/chrome --type=renderer --field-trial-handle=1 --primordial-pipe-token=5CFBD5B6B4662D2259DA561119E7D6AD --lang=en-US --enable-offline-auto-re
  697 www-data   20   0 1342M  389M  313M S  6.7  2.4  0:03.60 /usr/bin/zmc -m 6 
  714 www-data   20   0 1344M  394M  313M S  6.0  2.5  0:04.09 /usr/bin/zmc -m 7 
  720 www-data   20   0 1344M  394M  313M S  6.0  2.5  0:04.10 /usr/bin/zmc -m 7 
  721 www-data   20   0 1344M  394M  313M S  6.0  2.5  0:04.19 /usr/bin/zmc -m 7 
  717 www-data   20   0 1344M  394M  313M S  5.3  2.5  0:04.10 /usr/bin/zmc -m 7 
  716 www-data   20   0 1344M  394M  313M S  5.3  2.5  0:04.11 /usr/bin/zmc -m 7 
  715 www-data   20   0 1344M  394M  313M S  5.3  2.5  0:04.15 /usr/bin/zmc -m 7 
  722 www-data   20   0 1344M  394M  313M S  5.3  2.5  0:04.11 /usr/bin/zmc -m 7 
  696 www-data   20   0 1342M  389M  313M S  5.3  2.4  0:03.64 /usr/bin/zmc -m 6 
  698 www-data   20   0 1342M  389M  313M S  5.3  2.4  0:03.65 /usr/bin/zmc -m 6 
  699 www-data   20   0 1342M  389M  313M S  5.3  2.4  0:03.61 /usr/bin/zmc -m 6 
  718 www-data   20   0 1344M  394M  313M S  4.7  2.5  0:04.13 /usr/bin/zmc -m 7 
  701 www-data   20   0 1342M  389M  313M S  4.7  2.4  0:03.64 /usr/bin/zmc -m 6 
  704 www-data   20   0 1342M  389M  313M S  4.7  2.4  0:03.62 /usr/bin/zmc -m 6 
10146 xabix      20   0  511M  109M 88548 S  4.7  0.7 15:10.11 /opt/google/chrome/chrome --type=gpu-process --field-trial-handle=1 --supports-dual-gpus=false --gpu-driver-bug-workarounds=1,7,8,10,23,28,61,74,97 --disable-g
  719 www-data   20   0 1344M  394M  313M S  4.0  2.5  0:04.11 /usr/bin/zmc -m 7 
  706 www-data   20   0 1342M  389M  313M S  4.0  2.4  0:03.61 /usr/bin/zmc -m 6 
  702 www-data   20   0 1342M  389M  313M S  4.0  2.4  0:03.61 /usr/bin/zmc -m 6 
  700 www-data   20   0 1342M  389M  313M S  4.0  2.4  0:03.60 /usr/bin/zmc -m 6 
  713 www-data   20   0 1343M  393M  313M S  3.3  2.5  0:02.14 /usr/bin/zmc -m 5 
  712 www-data   20   0 1343M  393M  313M S  3.3  2.5  0:02.15 /usr/bin/zmc -m 5 
  703 www-data   20   0 1343M  393M  313M S  3.3  2.5  0:02.10 /usr/bin/zmc -m 5 
  710 www-data   20   0 1343M  393M  313M S  2.7  2.5  0:02.14 /usr/bin/zmc -m 5 
  705 www-data   20   0 1343M  393M  313M S  2.7  2.5  0:02.12 /usr/bin/zmc -m 5 
  736 www-data   20   0 1344M  396M  313M S  2.7  2.5  0:01.59 /usr/bin/zmc -m 8 
  744 www-data   20   0 1344M  396M  313M S  2.7  2.5  0:01.58 /usr/bin/zmc -m 8 
  707 www-data   20   0 1343M  393M  313M S  2.7  2.5  0:02.15 /usr/bin/zmc -m 5 
  711 www-data   20   0 1343M  393M  313M S  2.7  2.5  0:02.11 /usr/bin/zmc -m 5 
  737 www-data   20   0 1344M  396M  313M S  2.7  2.5  0:01.57 /usr/bin/zmc -m 8              
  738 www-data   20   0 1344M  396M  313M S  2.7  2.5  0:01.57 /usr/bin/zmc -m 8 
  741 www-data   20   0 1344M  396M  313M S  2.7  2.5  0:01.59 /usr/bin/zmc -m 8 
  709 www-data   20   0 1343M  393M  313M S  2.0  2.5  0:02.19 /usr/bin/zmc -m 5         
User avatar
zd59
Posts: 102
Joined: Wed Jan 18, 2017 1:39 pm
Location: EU - Slovenia

Re: Saving h264 using feature-h264-videostorage

Post by zd59 »

Hi!

Now master branch git includes the feature described in the first post (storage tab in monitor configuration), so I post here.

git source from today, last Commit from today, knnniggett https://github.com/ZoneMinder/ZoneMinde ... e029dacc2f
Compiled on Slackware64-14.2
ffmpeg version 3.3.2 Copyright (c) 2000-2017 the FFmpeg developers
built with gcc 5.3.0 (GCC)
PATH_FFMPEG=/usr/bin/ffmpeg
FFMPEG_OUTPUT_OPTIONS=-r 10

Click on event number to watch its video, endlessly repeats video (loop). Click on pause detect it (shortly icon change) but do not stop looping.
Can not create video from event (any format):
2017-06-15 13:01:59.292427 web_php 7308 ERR Video Generation Failed /var/www/htdocs/zm/includes/functions.php 2095

Also have suggestions:
All modern IP cameras have at least 2 streams. So, to optimize server load, it would be nice, to be possible to:
modect low resolution (PAL, VGA..) on jpeg/h264 stream, as is curently on ZM.
nodect high resolution stream linked to modect, recording in passthrough mode (record original stream from camera, regardless of format - jpeg, h264, h265 etc.)
This way, no video transformation is needed or h264 --> jpeg on low stream, that would significantly reduce system load.

As all computers this days use some kind of GPUs with hardware video acceleration, how to exploit it, as ffmpeg is capable of that?

Regards
Post Reply