Testing the hardware video decoding peripheral of the rpi 3 in ZM, with Devuan Stretch and 1.31.44.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

250 lines
10 KiB

  1. setting up zm on raspberry pi
  2. installed raspbian,
  3. installed zm per docker steps
  4. using entrypoint.sh in docker utils
  5. zm wouldn't start, because zmsystemctl is not working via this docker script
  6. i migrated to devuan
  7. (change apt repos, then apt-get install sysvinit-core, then reboot)
  8. and it now doesn't try to run zmsystemctl and it actually works
  9. next error:
  10. failed to open vchiq instance
  11. this reportedly has to do with www-user not having permissions to video group
  12. let's change that...
  13. usermod -a -G video www-data
  14. usermod -a -G wheel www-data
  15. edit: that was not it. dead end.
  16. let's try
  17. https://raspberrypi.stackexchange.com/questions/19436/how-can-i-permanently-fix-dev-vchiq-permission-errors
  18. chmod 777 on /dev/vchiq worked.
  19. NOTE: it looks like a reboot would've worked for the video group as well.
  20. need to log out and back in the www-data user...
  21. but i 777'd it.
  22. Now, on to testing the RTSP path for H264, and use passthrough.
  23. I tested the path in Mplayer and it does work from my laptop, so the path
  24. is correct. ZM doesn't seem to work. Something with ZM is broken...
  25. i tried to run the onvif probe...
  26. seems there are a couple dependencies not installed on
  27. this install for onvif probe
  28. i'm giving up for now on configuring onvif probe.
  29. This is no doubt due to it being a docker script.
  30. rtsp://admin:@192.168.1.138:88/videoMain
  31. this path works in mplayer but not in zm ffmpeg.
  32. let's try changing to tcp or udp or something else...
  33. OK
  34. this time it seems to work sorta
  35. except
  36. [zmc_m1] [Monitor dimensions are 1280x720 but camera is sending 320x240]
  37. 7]: INF [zmc_m1] [Got signal 15 (Terminated), exiting]
  38. Aug 11 03:44:00 raspberrypi zmc_m1[2657]: INF [zmc_m1] [Unable to read packet from stream 0: error -541478725 "End of file".]
  39. Aug 11 03:44:00 raspberrypi zmc_m1[2657]: WAR [zmc_m1] [Return from Capture (-1), signal loss]
  40. Aug 11 03:44:00 raspberrypi zmc_m1[2657]: ERR [zmc_m1] [Failed to capture image from monitor 1 main (1/1)]
  41. ok this
  42. hm....
  43. //
  44. all kinds of errors
  45. //
  46. Aug 11 03:45:29 raspberrypi zmdc[2349]: INF ['zmc -m 1' sending stop to pid 2764 at 18/08/11 03:45:29]
  47. Aug 11 03:45:29 raspberrypi zmc_m1[2764]: INF [zmc_m1] [Got signal 15 (Terminated), exiting]
  48. Aug 11 03:45:29 raspberrypi zmc_m1[2764]: ERR [zmc_m1] [Unable to read packet from stream 0: error -1414092869 "Immediate exit requested".]
  49. Aug 11 03:45:29 raspberrypi zmc_m1[2764]: WAR [zmc_m1] [Return from Capture (-1), signal loss]
  50. Aug 11 03:45:29 raspberrypi zmc_m1[2764]: ERR [zmc_m1] [Failed to capture image from monitor 1 main (1/1)]
  51. Aug 11 03:45:29 raspberrypi zmdc[2349]: INF ['zmc -m 1' exited normally]
  52. Aug 11 03:45:30 raspberrypi zmdc[2349]: INF [Starting pending process, zmc -m 1]
  53. Aug 11 03:45:30 raspberrypi zmdc[2349]: INF ['zmc -m 1' starting at 18/08/11 03:45:30, pid = 2787]
  54. Aug 11 03:45:30 raspberrypi zmdc[2787]: INF ['zmc -m 1' started at 18/08/11 03:45:30]
  55. Aug 11 03:45:31 raspberrypi zmc_m1[2787]: INF [zmc_m1] [Starting Capture version 1.31.44]
  56. Aug 11 03:45:31 raspberrypi zmc_m1[2787]: INF [zmc_m1] [Priming capture from rtsp://admin:@192.168.1.138:88/videoMain]
  57. Aug 11 03:45:31 raspberrypi zmc_m1[2787]: WAR [zmc_m1] [Unknown method (rtpUni)]
  58. Aug 11 03:45:31 raspberrypi zmc_m1[2787]: INF [zmc_m1] [Stream open rtsp://admin:@192.168.1.138:88/videoMain, parsing streams...]
  59. 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]
  60. Aug 11 03:45:41 raspberrypi zmdc[2349]: INF ['zmc -m 1' sending stop to pid 2787 at 18/08/11 03:45:41]
  61. Aug 11 03:45:44 raspberrypi zmc_m1[2787]: INF [zmc_m1] [Got signal 15 (Terminated), exiting]
  62. Aug 11 03:45:44 raspberrypi zmc_m1[2787]: ERR [zmc_m1] [Unable to read packet from stream 0: error -1414092869 "Immediate exit requested".]
  63. Aug 11 03:45:44 raspberrypi zmc_m1[2787]: WAR [zmc_m1] [Return from Capture (-1), signal loss]
  64. Aug 11 03:45:44 raspberrypi zmc_m1[2787]: ERR [zmc_m1] [Failed to capture image from monitor 1 main (1/1)]
  65. Aug 11 03:45:44 raspberrypi zmdc[2349]: INF ['zmc -m 1' exited normally]
  66. //
  67. hm... now mplayer doesn't work.
  68. let's reboot camera.
  69. //
  70. Exiting... (Quit)
  71. dev@dev:~/delete/zmhwlasergit/ZMHW_Project_LaserDiodeSensor$ mplayer rtsp://admin:@192.168.1.138:88/videoMain
  72. Playing: rtsp://admin:@192.168.1.138:88/videoMain
  73. (+) Video --vid=1 (h264)
  74. (+) Audio --aid=1 (pcm_mulaw)
  75. File tags:
  76. Comment: videoMain
  77. Title: IP Camera Video
  78. AO: [pulse] 8000Hz mono 1ch s16
  79. VO: [opengl] 1280x720 yuv420p
  80. AV: 00:00:00 A-V: -0.462 Dropped: 8
  81. Audio/Video desynchronisation detected! Possible reasons include too slow
  82. hardware, temporary CPU spikes, broken drivers, and broken files. Audio
  83. position will not match to the video (see A-V status field).
  84. AV: 00:00:04 A-V: -1.915 ct: -1.916 Dropped: 38
  85. Exiting... (Quit)
  86. dev@dev:~/delete/zmhwlasergit/ZMHW_Project_LaserDiodeSensor$ mplayer rtsp://admin:@192.168.1.138:88/videoMain
  87. Playing: rtsp://admin:@192.168.1.138:88/videoMain
  88. [ffmpeg/demuxer] rtsp: Could not find codec parameters for stream 0 (Video: h264, none): unspecified size
  89. [ffmpeg/demuxer] Consider increasing the value for the 'analyzeduration' and 'probesize' options
  90. (+) Video --vid=1 (h264)
  91. (+) Audio --aid=1 (pcm_mulaw)
  92. File tags:
  93. Comment: videoMain
  94. Title: IP Camera Video
  95. AO: [pulse] 8000Hz mono 1ch s16
  96. [lavf] error reading packet.
  97. //
  98. I rebooted the camera, tried mplayer again and it worked.
  99. I set the zm rpi to videoSub and resolution 640x360
  100. and it didn't work, but then two minutes later it worked... hm..
  101. Load is good. I've taken a picture. very low. Looking at 3%
  102. wow.
  103. OK, but that's 640 x 360. Let's try HD, and then let's try both without
  104. mmal to see if there's a difference. See if the mmal is implemented in
  105. this zm.
  106. tcp by the way, on ffmpeg.
  107. tcp, ffmpeg, the path above, and videoSub worked.
  108. trying videoMain now, let's see if it suddenly catches after a few minutes.
  109. I didn't have any luck with HD.
  110. I tried rebooting camera, no luck.
  111. I set it back to 640 x 480 and it caught near immediately (within a minute)
  112. this seems to be what the rpi wants. It looks like HD isn't working with the RPI.
  113. Load is low. I'm going to take this device on the road, and try it with
  114. a couple more cameras. Let's see how many SD cameras we can get running
  115. on it.
  116. Load is about .7, though htop shows no more than 5% on any given core (more
  117. around 1-3.3%.
  118. So for rpi3, I'd stick with SD for now.
  119. TODO: try more cameras, try ffmpeg without mmal...
  120. just as a reminder there is
  121. armel (32 bit arm without hardware floating point peripheral)
  122. armhf (32 bit with fp peripheral)
  123. arm64 (64 bit arm)
  124. Although each device has its own requirements beyond that which is why
  125. arm is shit and not nearly as compatible as x86. I digress.
  126. After looking a bit more, I realized that they aren't using the binary ffmpeg in ZM. I've never really
  127. investigated much. I have used MJPEG up to this point.
  128. here:
  129. dev@raspberrypi:~/ZoneMinder/src $ less zm_ffmpeg.cpp
  130. dev@raspberrypi:~/ZoneMinder/src $ grep -r mmal
  131. zm_ffmpeg_camera.cpp: if ( (mVideoCodec = avcodec_find_decoder_by_name("h264_mmal")) == NULL ) {
  132. zm_ffmpeg_camera.cpp: Debug(1, "Failed to find decoder (h264_mmal)" );
  133. zm_ffmpeg_camera.cpp: Debug(1, "Success finding decoder (h264_mmal)" );
  134. //
  135. I'm enabling debug logging in component files to see where this shows up.
  136. and then
  137. grep -r ffmpeg | less
  138. in the /var/log/zm folder
  139. 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)]
  140. 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]
  141. 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)]
  142. zm_debug.log.05486:08/11/18 04:51:33.526806 zmc_m1[5486].DB1-zm_ffmpeg.cpp/271 [ Stream #0:0]
  143. zm_debug.log.05486:08/11/18 04:51:33.526865 zmc_m1[5486].DB1-zm_ffmpeg.cpp/279 [, frames:17, timebase: 1/90000]
  144. 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]
  145. zm_debug.log.05486:08/11/18 04:51:33.527227 zmc_m1[5486].DB1-zm_ffmpeg.cpp/229 [90k stream tb numerator , ]
  146. zm_debug.log.05486:08/11/18 04:51:33.527316 zmc_m1[5486].DB1-zm_ffmpeg.cpp/229 [180k codec time base:]
  147. zm_debug.log.05486:08/11/18 04:51:33.527382 zmc_m1[5486].DB1-zm_ffmpeg.cpp/336 [
  148. zm_debug.log.05486:08/11/18 04:51:33.527438 zmc_m1[5486].DB1-zm_ffmpeg_camera.cpp/519 [Calling avcodec_open2]
  149. zm_debug.log.05486:08/11/18 04:51:33.588667 zmc_m1[5486].DB1-zm_ffmpeg_camera.cpp/542 [HWACCEL not in use]
  150. zm_debug.log.05486:08/11/18 04:51:33.589192 zmc_m1[5486].DB1-zm_ffmpeg_camera.cpp/554 [Audio Found decoder]
  151. 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)]
  152. zm_debug.log.05486:08/11/18 04:51:33.589347 zmc_m1[5486].DB1-zm_ffmpeg.cpp/271 [ Stream #0:1]
  153. zm_debug.log.05486:08/11/18 04:51:33.589407 zmc_m1[5486].DB1-zm_ffmpeg.cpp/279 [, frames:86, timebase: 1/8000]
  154. 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]
  155. zm_debug.log.05486:08/11/18 04:51:33.589641 zmc_m1[5486].DB1-zm_ffmpeg.cpp/336 [
  156. zm_debug.log.05486:08/11/18 04:51:33.589699 zmc_m1[5486].DB1-zm_ffmpeg_camera.cpp/561 [Calling avcodec_open2]
  157. Ah, so it is working. but I don't know where the decoders are found....
  158. However, I'd like to disable it, to see what the difference is.. How do I do that?
  159. And even with all this success, the foscam, still has too slow of a h264
  160. stream. My cheaper Amovision camera gets better FPS than this... 3.5 vs 15fps.
  161. At least CPU is low.
  162. here's an idea. Let's change it to remote, which doesn't use mmal
  163. and see what the resource usage is.
  164. not exactly the same, but similar.
  165. hm.. getting a no rtsp sources error. Will give up on that for now.
  166. looking at the code
  167. and this forum post:
  168. https://forums.zoneminder.com/viewtopic.php?f=34&t=26112&p=100221&hilit=avcodec_find_decoder_by_name#p100221
  169. ffmpeg libavcodec
  170. includes mmal codecs. Let's see if I can get an older one without libavcodec.
  171. https://packages.debian.org/stretch/libavcodec-dev
  172. this is the package we want to get an older copy of .
  173. Hm.. well as long as I know mmal is being used, I don't really need
  174. to test the old one, but I would like to.
  175. Question is, how to get the old version, without mmal installed...
  176. http://snapshot.debian.org/binary/libavcodec-dev/
  177. has it
  178. but when was mmal added, and it is compatible with stretch...
  179. Maybe I should just install 1.30.4 and compare that... Might be easier
  180. in this case.
  181. That is the end for now.