Python based interface for the pi zero w for timelapse videos and live streaming
- Raspberry Pi Zero W
- Offizielles Raspberry Pi Zero Gehäuse
- Raspberry Pi Kameramodul v2
- Adafruit I2S MEMS Mikrofon-Breakout - SPH0645LM4H
- Tactile Button switch (6mm) x 20 pack
- Linux - pi:raspberry
- Django -
- SSID:
zerocamap - Password:
zerocampw - static ip:
192.168.4.1 - dhcp-range:
192.168.4.2 - 192.168.4.20
- hostname
- zerocam
- zerocam.local
- livestream
- Django: http://zerocam.local:8000/static/video/index.m3u8
- nginx: http://zerocam.local/hls/index.m3u8
- node-rtsp-rtmp-server: rtmp://zerocam.local/live/picam
- webinterface
- Django Landing Page: http://zerocam.local:8000/video/
picam.service | start picam streaming
django.service | Django Webinterface
gpiobutton.service | listen for button press and shutdown pi or activate access point
picam-ramdisk.service | create ramdisk folder on startup
testing: code snippets and testing of modulesscript: mainly setup and startup scriptsmedia: folder for videos, images, timelapse, etc.
- Set shared Memory to 256mb
Needed for picamera pictures with highest resolution
https://github.com/legotheboss/YouTube-files/wiki/(RPi)-Compile-FFmpeg-with-the-OpenMAX-H.264-GPU-acceleration https://www.reddit.com/r/raspberry_pi/comments/5677qw/hardware_accelerated_x264_encoding_with_ffmpeg/ https://askubuntu.com/questions/87111/if-i-build-a-package-from-source-how-can-i-uninstall-or-remove-completely
Delete previous version of ffmpeg: sudo apt-get remove ffmpeg
Install checkinstall: sudo apt-get install checkinstall
Download and Compile ffmpeg with Hardware Acceleration on Raspberry Pi:
cd /home/pi/
sudo apt-get install libomxil-bellagio-dev -y
git clone https://github.com/FFmpeg/FFmpeg.git
cd FFmpeg
sudo ./configure --arch=armel --target-os=linux --enable-gpl --enable-omx --enable-omx-rpi --enable-nonfree
sudo make
sudo checkinstall
You can remove it from your system anytime using:
dpkg -r ffmpeg
If an error occurs when running checkinstall try:
sudo checkinstall --fstrans=no
ffmpeg with mmal support (probably not needed):
https://maniaclander.blogspot.com/2017/08/ffmpeg-with-pi-hardware-acceleration.html
sudo ./configure --arch=armel --target-os=linux --enable-gpl --enable-mmal --enable-omx --enable-omx-rpi --enable-nonfree
- Django Webinterface
- HotSpot
- Aktiviern über Button
- Script um zwischen AP und Wifi zu wechseln
- Change /etc/hosts with script (add 192.168.4.1 and comment out 127.0.1.1)
- WiFi
- aktivieren über Webinterface
- Stop-Motion Push-Button (in webinterface)
- Timelaps Videos
- pip3 install --user pipenv (required)
- pipenv install
- Projekt erstellen django-admin startproject zerocam_ui
- In zerocam_ui Ordner wechseln
- pipenv shell
- Django App erstellen python manage.py startapp wifi_setup
- Anleitung befolgen https://docs.djangoproject.com/en/2.1/intro/tutorial01/
- Admin User erstellen python manage.py createsuperuser
- cd zerocam/
- pipenv install
- pipenv run zerocam_ui/manage.py runserver
- Enjoy
-- Symlink anlegen damit django die Files ausliefert ln -s /run/shm/hls /home/pi/zerocam/zerocam_ui/wifi_setup/static/video
picam with hls streaming / framerate 25 / volume gain 10x:
/home/pi/picam/picam --alsadev complex_convert -o /run/shm/hls -f 25 --volume 10
picam with timestam
/home/pi/picam/picam --alsadev complex_convert -o /run/shm/hls -f 25 --volume 10 --time
picam with timeformat "2018-12-01 12:30:05"
/home/pi/picam/picam --alsadev complex_convert -o /run/shm/hls -f 25 --volume 10 --time --timeformat "%F %T"
Create timelapse from jpg
ffmpeg -framerate 10 -pattern_type glob -i '*.jpg' -r 25 timelapse10.mp4
Create timelapse with hardware acceleration
(Change -framerate value to your needs)
ffmpeg -framerate 10 -pattern_type glob -i '*.jpg' -c:v h264_omx -b:v 4000k -r 25 timelapse10.mp4
check if service is active
https://stackoverflow.com/questions/30056280/test-if-a-systemd-unit-is-active-in-a-bash-script
systemctl is-active picam.service
check if service is active (only exit-code):
systemctl -q is-active picam.service
https://picamera.readthedocs.io/en/release-1.13/index.html
mpromonet/v4l2rtspserver#94 (comment)
https://howchoo.com/g/mwnlytk3zmm/how-to-add-a-power-button-to-your-raspberry-pi
-
While: pass
Bad. 100% CPU -
While: time.sleep(1)
Better. CPU every 1 sec -
While: Event().wait()
https://stackoverflow.com/a/48631852
Python 3.2+ / No Windows / No CPU time -
While: GPIO.wait_for_edge
https://howchoo.com/g/mwnlytk3zmm/how-to-add-a-power-button-to-your-raspberry-pi
when using while loop to wait for gpio but can't be used withGPIO.add_event_detect
- Check if variable contains string
https://stackoverflow.com/questions/3437059/does-python-have-a-string-contains-substring-method
if "string" in variable:
if "string" not in variable: