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.

331 lines
9.5 KiB

6 years ago
  1. Objective: To install ZM on an rpi3 with mmal support and verify it's using mmal. Evaluate.
  2. Preface:
  3. I tried before to install Devuan directly from IMG provided, and then build ffmpeg with mmal included.
  4. I don't think was necessary as we are not compiling ffmpeg, but instead using libavcodec (I know this now, but
  5. didn't at the time).
  6. In any case, if you want ZM to have mmal working you must have the libavcodec development headers that include mmal
  7. and you can confirm it by switching debug logging on zmc_m1 (if 1 is your test camera)
  8. But let's cover install steps.
  9. The goal is to:
  10. install raspbian stretch lite
  11. update
  12. install ffmpeg, verify mmal is included
  13. if it does, then install git of zm
  14. compile zm, from a more recent branch that includes the Hardware peripheral calls (HWACCEL)
  15. migrate to devuan (this ended up being required for my setup, as the docker entrypoint.sh doesn't run with zmsystemctl)
  16. it's important to migrate to devuan after installing ffmpeg, as i think the raspbian mirrors are supposed
  17. to have support for mmal in ffmpeg but the devuan mirrors may not. Devuan pulls from debian, not Raspbian.
  18. Don't bother trying to custom compile ffmpeg, as I mentioned before, you need libavcodec, not ffmpeg.
  19. OK, now to install ZM from git...
  20. git clone https://github.com/zoneminder/zoneminder.git
  21. also this dockerfile has instructions for building a
  22. ubuntu
  23. img. That might work...
  24. https://github.com/ZoneMinder/zmdockerfiles/blob/master/development/ubuntu/xenial/Dockerfile
  25. the only changes we will make is:
  26. remove libjpeg-turbo8
  27. remove libjpeg-turbo8-dev
  28. remove libmysqlclient-dev
  29. remove libmime-perl
  30. from list
  31. as they are named differently. We'll add them back in later.
  32. also removing the no depends...
  33. so
  34. apt-get update
  35. apt-get dist-upgrade
  36. then
  37. the command I'll run (similar to docker file)
  38. is
  39. apt-get install -y \
  40. apache2 \
  41. build-essential \
  42. cmake \
  43. dh-autoreconf \
  44. dpatch \
  45. git \
  46. libapache2-mod-php \
  47. libarchive-zip-perl \
  48. libavcodec-dev \
  49. libavdevice-dev \
  50. libavfilter-dev \
  51. libavformat-dev \
  52. libavresample-dev \
  53. libav-tools \
  54. libavutil-dev \
  55. libbz2-dev \
  56. libcurl4-gnutls-dev \
  57. libdate-manip-perl \
  58. libdbd-mysql-perl \
  59. libdbi-perl \
  60. libdevice-serialport-perl \
  61. libgcrypt-dev \
  62. libgnutls-openssl-dev \
  63. libmime-lite-perl \
  64. libmp4v2-dev \
  65. libnet-sftp-foreign-perl \
  66. libnetpbm10-dev \
  67. libpcre3 \
  68. libpcre3-dev \
  69. libpolkit-gobject-1-dev \
  70. libpostproc-dev \
  71. libssl-dev \
  72. libswscale-dev \
  73. libsys-cpu-perl \
  74. libsys-meminfo-perl \
  75. libsys-mmap-perl \
  76. libtheora-dev \
  77. libtool \
  78. libv4l-dev \
  79. libvlc5 \
  80. libvlccore8 \
  81. libvlccore-dev \
  82. libvlc-dev \
  83. libvorbis-dev \
  84. libvpx-dev \
  85. libwww-perl \
  86. libx264-dev \
  87. mysql-client \
  88. mysql-server \
  89. php \
  90. php-cli \
  91. php-gd \
  92. php-mysql \
  93. ssmtp \
  94. software-properties-common \
  95. vlc-data \
  96. yasm \
  97. zip
  98. hopefully that finishes without any errors.
  99. I had dpkg stall halfway through, but that was because I forgot to resize the fs when originally using the Devuan img.
  100. With the raspbian img, I think it might auto resize the FS.
  101. I reinstalled at that point. easy enough.
  102. and it went through without error.
  103. The four libraries we had to remove
  104. we will now add back in
  105. libturbojpeg0 - TurboJPEG runtime library - SIMD optimized
  106. libturbojpeg0-dev - Development files for the TurboJPEG library
  107. default-libmysqlclient-dev - MySQL database development files (metapackage)
  108. libmariadbclient-dev-compat - MariaDB database development files (libmysqlclient compatibility)
  109. libmime-base32-perl - Base32 encoder/decoder
  110. libmime-base64-urlsafe-perl - Perl version of Python's URL-safe base64 codec
  111. libmime-charset-perl - module for MIME character set information
  112. libmime-encwords-perl - Perl interface to deal with RFC 2047 encoded words
  113. libmime-explode-perl - Perl extension to explode MIME messages
  114. libmime-lite-html-perl - Transform HTML page into MIME email
  115. libmime-lite-perl - module for convenient MIME message creation
  116. libmime-lite-tt-html-perl - module to create HTML mail with MIME::Lite and T
  117. T
  118. libmime-lite-tt-perl - module to generate MIME messages from Template Toolki
  119. t templates
  120. libmime-tools-perl - Perl5 modules for MIME-compliant messages
  121. libmime-types-perl - Perl extension for determining MIME types and Transfer
  122. Encoding
  123. libemail-mime-perl
  124. probably a few extra here we don't need, but regardless...
  125. so
  126. apt-get install libturbojpeg0 libturbojpeg0-dev default-libmysqlclient-dev \
  127. libmariadbclient-dev-compat libmime-base32-perl libmime-base64-urlsafe-perl \
  128. libmime-charset-perl libmime-encwords-perl libmime-explode-perl libmime-lite-html-perl \
  129. libmime-lite-perl libmime-lite-tt-html-perl libmime-lite-tt-perl libmime-tools-perl \
  130. libmime-types-perl libemail-mime-perl
  131. then follow the docker guide:
  132. git clone --recursive https://github.com/ZoneMinder/ZoneMinder
  133. cd ZoneMinder
  134. If you want a certain tagged or commit of ZM now's the time to git checkout
  135. e.g. I am doing
  136. git checkout f07b1105d33c088cce4130970ee2f776867f67d0
  137. just so I'm always using the same commit.
  138. then
  139. cmake .
  140. this comes up with a jpeg error...
  141. that is explained here:
  142. in CMakeLists.txt
  143. //
  144. # jpeg
  145. find_package(JPEG)
  146. if(JPEG_FOUND)
  147. set(HAVE_LIBJPEG 1)
  148. list(APPEND ZM_BIN_LIBS "${JPEG_LIBRARIES}")
  149. #link_directories(${JPEG_LIBRARY})
  150. include_directories("${JPEG_INCLUDE_DIR}")
  151. set(CMAKE_REQUIRED_INCLUDES "${JPEG_INCLUDE_DIR}")
  152. check_include_files("stdio.h;jpeglib.h" HAVE_JPEGLIB_H)
  153. if(NOT HAVE_JPEGLIB_H)
  154. message(FATAL_ERROR
  155. "ZoneMinder requires libjpeg headers - check that libjpeg development
  156. packages are installed")
  157. endif(NOT HAVE_JPEGLIB_H)
  158. else(JPEG_FOUND)
  159. message(FATAL_ERROR
  160. "ZoneMinder requires jpeg but it was not found on your system")
  161. endif(JPEG_FOUND)
  162. //
  163. /usr/lib/aarch64-linux-gnu/
  164. so do this.
  165. apt-get install libjpeg-dev libjpeg62-turbo-dev libjpeg62-turbo libjpeg-turbo-progs
  166. one of those will handle jpeg
  167. NOTE: we might be losing turbo jpeg support, with libjpeg, so beware this is not
  168. optimized for MJPEG... I only plan to use this for RTSP H264 streams, (whole point of this)
  169. so your needs may vary.
  170. # Configure ZoneMinder
  171. RUN cmake .
  172. # Build & install ZoneMinder
  173. RUN make && make install
  174. # ensure writable folders
  175. RUN ./zmlinkcontent.sh
  176. this all worked, no problem. Devuan ascii.
  177. I skipped the volumes part, as we are not using docker.
  178. service mysql stop && service apache2 stop
  179. # Configure Apache
  180. cp misc/apache.conf /etc/apache2/sites-available/000-default.conf
  181. echo "ServerName localhost" > /etc/apache2/conf-available/servername.conf && a2enconf -q
  182. servername
  183. a2enmod -q cgi && a2enmod -q rewrite
  184. This came up with an error for rewite..
  185. //
  186. AH00526: Syntax error on line 62 of /etc/apache2/sites-enabled/000-default.conf:
  187. Invalid command 'RewriteEngine', perhaps misspelled or defined by a module not included in
  188. the server configuration
  189. //
  190. It can be ignored, as we hadn't enabled module rewrite when that loaded.
  191. echo "sql_mode=NO_ENGINE_SUBSTITUTION" >> /etc/mysql/mysql.conf.d/mysqld.cnf
  192. this fails, but you can change /etc/mysql/mysql.conf.d/mysqld.cnf
  193. to
  194. /etc/mysql/my.cnf
  195. We have ZM, but not init scripts.
  196. Since we are testing, here. Let's just use the dockerfile's entrypoint.sh
  197. That works just as well, as an init script.
  198. wget https://raw.githubusercontent.com/ZoneMinder/zmdockerfiles/master/utils/entrypoint.sh
  199. root@devuan:~# mv entrypoint.sh /usr/local/bin/.
  200. root@devuan:~# chmod 755 /usr/local/bin/entrypoint.sh
  201. root@devuan:~#
  202. now run
  203. /usr/local/bin/entrypoint.sh
  204. I sometimes run it in a screen session
  205. apt-get install screen
  206. # screen
  207. type
  208. ctrl-a :sessionname entrypoint
  209. ctrl-d to disconnect
  210. root@devuan:~# /usr/local/bin/entrypoint.sh
  211. mysql: unknown variable 'sql_mode=NO_ENGINE_SUBSTITUTION'
  212. * Removing stale lock file
  213. * Starting MySQL database server service ...done.
  214. * Warning: Mysql startup timer expired!
  215. mysql: unknown variable 'sql_mode=NO_ENGINE_SUBSTITUTION'
  216. * First run of mysql in the container, creating ZoneMinder dB.
  217. mysql: unknown variable 'sql_mode=NO_ENGINE_SUBSTITUTION'
  218. * Starting Apache http web server service ...done.
  219. * Starting ZoneMinder video surveillance recorder ...failed!
  220. //
  221. this fails, but we are close.
  222. The error I had made before was accidentally following the docker exactly.
  223. It added the 'sql_mode=NO_ENGINE_SUBSTITUTION' to my.cnf
  224. and my.cnf didn't understand it.
  225. So simply comment that out, if you added that by accident.
  226. when you run entrypoint you should see
  227. root@devuan:~# /usr/local/bin/entrypoint.sh
  228. * Removing stale lock file
  229. * MySQL database server already running.
  230. * First run of mysql in the container, creating ZoneMinder dB.
  231. * Starting Apache http web server service ...done.
  232. * Starting ZoneMinder video surveillance recorder ...done.
  233. And that tells us everything is working.
  234. If you go to ZM at the IP address, you should see it "Running". If you see it stopped, and you still have
  235. raspbian... read below.
  236. NOW, one problem I had is that when I was testing this is raspbian, it tried to call zmsystemctl
  237. which failed to actually run ZM.
  238. At this point I migrated to Devuan, following the dev1fanboy ascii migration guide (this is what I did)
  239. * add devuan repos to apt/sources
  240. * apt-get install sysvinit-core
  241. * make sure /etc/inittab is there and has init data
  242. * reboot
  243. And then running the entrypoint.sh didn't try to call zmsystemctl, and it worked.
  244. Now follow the next guide for details about my testing with mmal and a camera.