diff --git a/README.md b/README.md index ad95d60..aa710df 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,9 @@ # ZM_rpi3_HWACCEL_Testing -Testing the hardware video decoding peripheral of the rpi 3 in ZM, with Devuan Stretch and 1.31.44. \ No newline at end of file +Testing the hardware video decoding peripheral of the rpi 3 in ZM, with Devuan Stretch and 1.31.44. + +This incidentally shows how to build ZM from source using the docker script (not recommended but sort of works) + +The results are that, ZM 1.31.44 has comparable resource usage for a 3.5 FPS 640x480 camera +in RTSP and MJPEG mode. They both use about the same amount of CPU. Note that there is a limit +on how much mmal HWACCEL you can use, so it may not scale to more than say 3 or 4 cameras (testing soon). diff --git a/docs/testing_notes b/docs/testing_notes new file mode 100644 index 0000000..e8b1d10 --- /dev/null +++ b/docs/testing_notes @@ -0,0 +1,250 @@ +setting up zm on raspberry pi + +installed raspbian, + +installed zm per docker steps + +using entrypoint.sh in docker utils +zm wouldn't start, because zmsystemctl is not working via this docker script + +i migrated to devuan +(change apt repos, then apt-get install sysvinit-core, then reboot) + +and it now doesn't try to run zmsystemctl and it actually works + + +next error: +failed to open vchiq instance + +this reportedly has to do with www-user not having permissions to video group +let's change that... +usermod -a -G video www-data +usermod -a -G wheel www-data + +edit: that was not it. dead end. +let's try +https://raspberrypi.stackexchange.com/questions/19436/how-can-i-permanently-fix-dev-vchiq-permission-errors + +chmod 777 on /dev/vchiq worked. +NOTE: it looks like a reboot would've worked for the video group as well. +need to log out and back in the www-data user... + +but i 777'd it. + + + +Now, on to testing the RTSP path for H264, and use passthrough. + +I tested the path in Mplayer and it does work from my laptop, so the path +is correct. ZM doesn't seem to work. Something with ZM is broken... + +i tried to run the onvif probe... +seems there are a couple dependencies not installed on +this install for onvif probe +i'm giving up for now on configuring onvif probe. +This is no doubt due to it being a docker script. + + + rtsp://admin:@192.168.1.138:88/videoMain +this path works in mplayer but not in zm ffmpeg. +let's try changing to tcp or udp or something else... +OK +this time it seems to work sorta +except +[zmc_m1] [Monitor dimensions are 1280x720 but camera is sending 320x240] + + +7]: INF [zmc_m1] [Got signal 15 (Terminated), exiting] +Aug 11 03:44:00 raspberrypi zmc_m1[2657]: INF [zmc_m1] [Unable to read packet from stream 0: error -541478725 "End of file".] +Aug 11 03:44:00 raspberrypi zmc_m1[2657]: WAR [zmc_m1] [Return from Capture (-1), signal loss] +Aug 11 03:44:00 raspberrypi zmc_m1[2657]: ERR [zmc_m1] [Failed to capture image from monitor 1 main (1/1)] + +ok this + +hm.... +// +all kinds of errors +// +Aug 11 03:45:29 raspberrypi zmdc[2349]: INF ['zmc -m 1' sending stop to pid 2764 at 18/08/11 03:45:29] +Aug 11 03:45:29 raspberrypi zmc_m1[2764]: INF [zmc_m1] [Got signal 15 (Terminated), exiting] +Aug 11 03:45:29 raspberrypi zmc_m1[2764]: ERR [zmc_m1] [Unable to read packet from stream 0: error -1414092869 "Immediate exit requested".] +Aug 11 03:45:29 raspberrypi zmc_m1[2764]: WAR [zmc_m1] [Return from Capture (-1), signal loss] +Aug 11 03:45:29 raspberrypi zmc_m1[2764]: ERR [zmc_m1] [Failed to capture image from monitor 1 main (1/1)] +Aug 11 03:45:29 raspberrypi zmdc[2349]: INF ['zmc -m 1' exited normally] +Aug 11 03:45:30 raspberrypi zmdc[2349]: INF [Starting pending process, zmc -m 1] +Aug 11 03:45:30 raspberrypi zmdc[2349]: INF ['zmc -m 1' starting at 18/08/11 03:45:30, pid = 2787] +Aug 11 03:45:30 raspberrypi zmdc[2787]: INF ['zmc -m 1' started at 18/08/11 03:45:30] +Aug 11 03:45:31 raspberrypi zmc_m1[2787]: INF [zmc_m1] [Starting Capture version 1.31.44] +Aug 11 03:45:31 raspberrypi zmc_m1[2787]: INF [zmc_m1] [Priming capture from rtsp://admin:@192.168.1.138:88/videoMain] +Aug 11 03:45:31 raspberrypi zmc_m1[2787]: WAR [zmc_m1] [Unknown method (rtpUni)] +Aug 11 03:45:31 raspberrypi zmc_m1[2787]: INF [zmc_m1] [Stream open rtsp://admin:@192.168.1.138:88/videoMain, parsing streams...] +Aug 11 03:45:39 raspberrypi zmwatch[2428]: INF [Restarting capture daemon for main, no image since startup. Startup time was 1533959131 - now 1533959139 > 5] +Aug 11 03:45:41 raspberrypi zmdc[2349]: INF ['zmc -m 1' sending stop to pid 2787 at 18/08/11 03:45:41] +Aug 11 03:45:44 raspberrypi zmc_m1[2787]: INF [zmc_m1] [Got signal 15 (Terminated), exiting] +Aug 11 03:45:44 raspberrypi zmc_m1[2787]: ERR [zmc_m1] [Unable to read packet from stream 0: error -1414092869 "Immediate exit requested".] +Aug 11 03:45:44 raspberrypi zmc_m1[2787]: WAR [zmc_m1] [Return from Capture (-1), signal loss] +Aug 11 03:45:44 raspberrypi zmc_m1[2787]: ERR [zmc_m1] [Failed to capture image from monitor 1 main (1/1)] +Aug 11 03:45:44 raspberrypi zmdc[2349]: INF ['zmc -m 1' exited normally] +// + +hm... now mplayer doesn't work. +let's reboot camera. +// + +Exiting... (Quit) +dev@dev:~/delete/zmhwlasergit/ZMHW_Project_LaserDiodeSensor$ mplayer rtsp://admin:@192.168.1.138:88/videoMain +Playing: rtsp://admin:@192.168.1.138:88/videoMain + (+) Video --vid=1 (h264) + (+) Audio --aid=1 (pcm_mulaw) +File tags: + Comment: videoMain + Title: IP Camera Video +AO: [pulse] 8000Hz mono 1ch s16 +VO: [opengl] 1280x720 yuv420p +AV: 00:00:00 A-V: -0.462 Dropped: 8 + +Audio/Video desynchronisation detected! Possible reasons include too slow +hardware, temporary CPU spikes, broken drivers, and broken files. Audio +position will not match to the video (see A-V status field). + +AV: 00:00:04 A-V: -1.915 ct: -1.916 Dropped: 38 + + +Exiting... (Quit) +dev@dev:~/delete/zmhwlasergit/ZMHW_Project_LaserDiodeSensor$ mplayer rtsp://admin:@192.168.1.138:88/videoMain +Playing: rtsp://admin:@192.168.1.138:88/videoMain +[ffmpeg/demuxer] rtsp: Could not find codec parameters for stream 0 (Video: h264, none): unspecified size +[ffmpeg/demuxer] Consider increasing the value for the 'analyzeduration' and 'probesize' options + (+) Video --vid=1 (h264) + (+) Audio --aid=1 (pcm_mulaw) +File tags: + Comment: videoMain + Title: IP Camera Video +AO: [pulse] 8000Hz mono 1ch s16 +[lavf] error reading packet. +// + + +I rebooted the camera, tried mplayer again and it worked. + +I set the zm rpi to videoSub and resolution 640x360 +and it didn't work, but then two minutes later it worked... hm.. + +Load is good. I've taken a picture. very low. Looking at 3% +wow. + +OK, but that's 640 x 360. Let's try HD, and then let's try both without +mmal to see if there's a difference. See if the mmal is implemented in +this zm. + +tcp by the way, on ffmpeg. +tcp, ffmpeg, the path above, and videoSub worked. +trying videoMain now, let's see if it suddenly catches after a few minutes. + +I didn't have any luck with HD. +I tried rebooting camera, no luck. + +I set it back to 640 x 480 and it caught near immediately (within a minute) +this seems to be what the rpi wants. It looks like HD isn't working with the RPI. + +Load is low. I'm going to take this device on the road, and try it with +a couple more cameras. Let's see how many SD cameras we can get running +on it. + +Load is about .7, though htop shows no more than 5% on any given core (more +around 1-3.3%. + +So for rpi3, I'd stick with SD for now. + +TODO: try more cameras, try ffmpeg without mmal... + +just as a reminder there is +armel (32 bit arm without hardware floating point peripheral) +armhf (32 bit with fp peripheral) +arm64 (64 bit arm) + +Although each device has its own requirements beyond that which is why +arm is shit and not nearly as compatible as x86. I digress. + + +After looking a bit more, I realized that they aren't using the binary ffmpeg in ZM. I've never really +investigated much. I have used MJPEG up to this point. +here: +dev@raspberrypi:~/ZoneMinder/src $ less zm_ffmpeg.cpp +dev@raspberrypi:~/ZoneMinder/src $ grep -r mmal +zm_ffmpeg_camera.cpp: if ( (mVideoCodec = avcodec_find_decoder_by_name("h264_mmal")) == NULL ) { +zm_ffmpeg_camera.cpp: Debug(1, "Failed to find decoder (h264_mmal)" ); +zm_ffmpeg_camera.cpp: Debug(1, "Success finding decoder (h264_mmal)" ); + + +// + +I'm enabling debug logging in component files to see where this shows up. + +and then +grep -r ffmpeg | less +in the /var/log/zm folder + + +zm_debug.log.05486:08/11/18 04:51:33.526451 zmc_m1[5486].DB1-zm_ffmpeg_camera.cpp/503 [Success finding decoder (h264_mmal)] +zm_debug.log.05486:08/11/18 04:51:33.526678 zmc_m1[5486].DB1-zm_ffmpeg_camera.cpp/512 [Video Found decoder h264_mmal] +zm_debug.log.05486:08/11/18 04:51:33.526743 zmc_m1[5486].DB1-zm_ffmpeg.cpp/266 [Dumping stream index i(0) index(0)] +zm_debug.log.05486:08/11/18 04:51:33.526806 zmc_m1[5486].DB1-zm_ffmpeg.cpp/271 [ Stream #0:0] +zm_debug.log.05486:08/11/18 04:51:33.526865 zmc_m1[5486].DB1-zm_ffmpeg.cpp/279 [, frames:17, timebase: 1/90000] +zm_debug.log.05486:08/11/18 04:51:33.526974 zmc_m1[5486].DB1-zm_ffmpeg.cpp/281 [: Video: h264 (Baseline), yuv420p(progressive), 640x360] +zm_debug.log.05486:08/11/18 04:51:33.527227 zmc_m1[5486].DB1-zm_ffmpeg.cpp/229 [90k stream tb numerator , ] +zm_debug.log.05486:08/11/18 04:51:33.527316 zmc_m1[5486].DB1-zm_ffmpeg.cpp/229 [180k codec time base:] +zm_debug.log.05486:08/11/18 04:51:33.527382 zmc_m1[5486].DB1-zm_ffmpeg.cpp/336 [ +zm_debug.log.05486:08/11/18 04:51:33.527438 zmc_m1[5486].DB1-zm_ffmpeg_camera.cpp/519 [Calling avcodec_open2] +zm_debug.log.05486:08/11/18 04:51:33.588667 zmc_m1[5486].DB1-zm_ffmpeg_camera.cpp/542 [HWACCEL not in use] +zm_debug.log.05486:08/11/18 04:51:33.589192 zmc_m1[5486].DB1-zm_ffmpeg_camera.cpp/554 [Audio Found decoder] +zm_debug.log.05486:08/11/18 04:51:33.589282 zmc_m1[5486].DB1-zm_ffmpeg.cpp/266 [Dumping stream index i(1) index(0)] +zm_debug.log.05486:08/11/18 04:51:33.589347 zmc_m1[5486].DB1-zm_ffmpeg.cpp/271 [ Stream #0:1] +zm_debug.log.05486:08/11/18 04:51:33.589407 zmc_m1[5486].DB1-zm_ffmpeg.cpp/279 [, frames:86, timebase: 1/8000] +zm_debug.log.05486:08/11/18 04:51:33.589575 zmc_m1[5486].DB1-zm_ffmpeg.cpp/281 [: Audio: pcm_mulaw, 8000 Hz, 1 channels, s16, 64 kb/s] +zm_debug.log.05486:08/11/18 04:51:33.589641 zmc_m1[5486].DB1-zm_ffmpeg.cpp/336 [ +zm_debug.log.05486:08/11/18 04:51:33.589699 zmc_m1[5486].DB1-zm_ffmpeg_camera.cpp/561 [Calling avcodec_open2] + +Ah, so it is working. but I don't know where the decoders are found.... + + + +However, I'd like to disable it, to see what the difference is.. How do I do that? + +And even with all this success, the foscam, still has too slow of a h264 +stream. My cheaper Amovision camera gets better FPS than this... 3.5 vs 15fps. + +At least CPU is low. + + +here's an idea. Let's change it to remote, which doesn't use mmal +and see what the resource usage is. +not exactly the same, but similar. + +hm.. getting a no rtsp sources error. Will give up on that for now. + + +looking at the code +and this forum post: +https://forums.zoneminder.com/viewtopic.php?f=34&t=26112&p=100221&hilit=avcodec_find_decoder_by_name#p100221 +ffmpeg libavcodec +includes mmal codecs. Let's see if I can get an older one without libavcodec. + +https://packages.debian.org/stretch/libavcodec-dev +this is the package we want to get an older copy of . + +Hm.. well as long as I know mmal is being used, I don't really need +to test the old one, but I would like to. + +Question is, how to get the old version, without mmal installed... + +http://snapshot.debian.org/binary/libavcodec-dev/ +has it +but when was mmal added, and it is compatible with stretch... +Maybe I should just install 1.30.4 and compare that... Might be easier +in this case. + +That is the end for now. + + + diff --git a/pics/DSCN0277.JPG b/pics/DSCN0277.JPG new file mode 100644 index 0000000..f19f658 Binary files /dev/null and b/pics/DSCN0277.JPG differ diff --git a/pics/DSCN0278.JPG b/pics/DSCN0278.JPG new file mode 100644 index 0000000..67a1fbc Binary files /dev/null and b/pics/DSCN0278.JPG differ diff --git a/pics/DSCN0280.JPG b/pics/DSCN0280.JPG new file mode 100644 index 0000000..8a98a2f Binary files /dev/null and b/pics/DSCN0280.JPG differ