GithubHelp home page GithubHelp logo

hippojay / pitimelapse Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mrmebailey/pitimelapse

0.0 1.0 0.0 638 KB

Shell Script for automating time-lapse video creation from images

Shell 100.00%

pitimelapse's Introduction

Overview

Shell Script for automating time-lapse video creation from images, hosts on an Apache Web Server for easy viewing.

Another over a much shorter period in HD which was taken every 10 minutes.

SC2 Video

Here's an example time-lapse video I recorded of chilli peppers growing over an 7 month period (click to view on YouTube):

SC2 Video

There are other examples in my Timelapses playlist on YouTube.

Prerequisites

Enable Camera Module

First, make sure the camera interface is enabled, if you don't, you'll see the message Camera is not enabled. Try running 'sudo raspi-config':

  1. Run sudo raspi-config
  2. Go to 'Interfacing Options'
  3. Select 'Camera'
  4. Select 'Yes' for enabling the camera
  5. Select 'Finish' in the main menu and then 'Yes' to reboot the Pi

Install Apache

Update the package lists first ;

sudo apt update
sudo apt-get install apache2 -y

Adjust the Apache permissions to allow the pi user to write so the script does not need to run as root.

sudo usermod -a -G www-data pi
sudo chown -R -f www-data:www-data /var/www/html
sudo chmod g+w /var/www/html

ffmpeg

Install ffmpeg

sudo apt install -y ffmpeg

Check it installed by checking the version

ffmpeg -version

Install piLapse

Install Pi-Lapse as Pi

cd ${HOME}
curl -LJO https://raw.githubusercontent.com/mrmebailey/pitimelapse/v1.0/timeLapse.sh
chmod 755 ./timeLapse.sh

Check it downloaded fine ;

./timeLapse.sh

You should see the output

This script will create a folder in the HTML Root with the project name

Usage: $0 [Project Name in HTML Root to be created, no spaces...]

VNC Install Pi HD lens Only

Becuase the Pi runs headless we need to use VNC to logon to the Pi in order to focus the camera as no display is attached.

sudo apt update
sudo apt install realvnc-vnc-server realvnc-vnc-viewer

Now we need to enable VNC in raspi-config

sudo raspi-config

Navigate to Interfacing Options.

Scroll down and select VNC โ€บ Yes.

Camera Focus Pi HD lens Only

Connect to the pi by donwloading VNC Viewer and execute raspistill in live mode using the command below.

raspistill -t -0

Alt Image text

Focus the camera on your subject in live view, do not forget to lock off the lens screws

Alt Image text

First Time Lapse

Now we have the script we can start testing, execute this command which will create the first picture and the project directory in the web root for us.

./timeLapse.sh my_first_laspe

If there was an issue with the camera or it is not connected properly you will get the error now, check the connections and that you have enabled the camera properly.

ls -ltr /var/www/html/my_first_laspe/
total 244
-rw-r--r-- 1 pi pi 247283 Sep 30 11:12 1.jpg

Now when we run the script the second time it will create picture number 2 and build the videos with the data overlay.

./timeLapse.sh my_first_laspe
ls -ltr /var/www/html/my_first_laspe/

The output will look like this.

total 592
-rw-r--r-- 1 pi pi 247283 Sep 30 11:12 1.jpg
-rw-r--r-- 1 pi pi 248216 Sep 30 11:12 2.jpg
-rw-r--r-- 1 pi pi  31630 Sep 30 11:13 timelapse.mp4
-rw-r--r-- 1 pi pi  33383 Sep 30 11:13 timelapse_banner.mp4
-rw-r--r-- 1 pi pi  33383 Sep 30 11:13 timelapse_banner_static.mp4

Now visit the pi with a browser and check your pictures and video all work...

http://<PI IP ADDRESS>

Alt Image text

The final part is to define the crontab entry, now the settings here will depend on the quality you want which is not currently tunable but essentially the smoother the timelapse the more pictures you need but depends on how quickly your target lapse environment changes.

So for example to catch ice melting that out be each minute in a house as it will only last about 30 or 40 minutes. The chilli peppers growing over months I found each hour was enough to show the plants growing.

Chill flowers came and went within 2-3 days but that required a medium of every 10 minutes but experiment.

In this example we will run every minute and show a melting lolly so lets get started....

Add the cron entry by executing the below command.

(crontab -l ; echo "* * * * * /home/pi/timeLapse.sh my_first_laspe") | crontab

You can remove it or hash it out when you are done with this command

 ( crontab -l | grep -v -F "/home/pi/timeLapse.sh my_first_laspe" ) | crontab -

pitimelapse's People

Contributors

mrmebailey avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.