Time Lapse With Raspberry PI

Introduction: Time Lapse With Raspberry PI

I wanted to make the typical time lapse showing the clouds and the Sun.
But I always did it manually, and this is a long "work".

In this tutorial I prepared the scripts to take the photos and to make the video with a Raspberry PI on a window.

.

I am NOT going to explain how to put the Camera on the Raspberry PI.
I hope that you know how to attach it and configure it.

I am only going to put here the scripts that you have to put onto your Raspberry PI.

TAKE CARE:
After a few days, your Micro SD card will be full with a lot of photos and you will need to remove them.
You can prepare one script to remove the photos after creating the video.
In my case, I decided to remove them manually because I wanted to check if the camera was moved or if I had other issues.

Supplies

You will need:

- A Raspberry PI (one of them: 1, 2, 3, 4, Zero W).
- Camera module.

Obviously, you will need:

- Micro SD card (you need the System running there) (take a big-big one).
- Power adapter (the Raspberry PI needs to be "running").
- or Power bank if you do not have a plug near the window or if you want to put it outside (the Raspberry PI needs to be "running").

Optional:
- Screen.
- Keyboard.
- Mouse.

In my case I used a Raspberry PI Zero W and I connect to it using SSH (without dedicated screen, mouse and keyboard).

Step 1: Update Your System

I recommend you to update all the software on your Raspberry PI:

sudo apt-get update -y
sudo apt-get upgrade -y 

Step 2: Take a Picture Every "x" Minutes

To make the time lapse you need to take pictures. And after, with them, you will create a video.

Do I have to take a picture every 30 seconds?
Do I have to take a picture every minute?
Do I have to take a picture every 30 minutes?
...
It depends on you.
As much time you put, the resulted video will be "faster".

AND, and this is important, every picture will have around 2Mb !!!!
Take a look on the size of your Micro SD and use a big one to prevent having "no-space" on it.

I recommend you to start taking the pictures every 1 minute and you can create the video.
After, you can take the video after 5 minutes and you can create the video.
After, do the same every 10, 15, 30 and 60 minutes.
Take a look on the resulted videos and you will decide which one is the best for you.

We need to add one line on crontab:

sudo crontab -e

Then, add at the end this line:

*/1 * * * * sh /home/pi/Documents/TakeOnePhoto.sh 2>1&

If you want to take the picture every 5 minutes, you have to insert:

*/5 * * * * sh /home/pi/Documents/TakeOnePhoto.sh 2>1&

If you want to take the picture every 30 minutes, you have to insert:

*/30 * * * * sh /home/pi/Documents/TakeOnePhoto.sh 2>1&

I hope that you know how to put the correct timing for you.
But I know that you will change this value until you got the perfect video for you.

Now, you need to create the script.
Go to the folder, create the file "TakeOnePhoto.sh" and add this text on it:

#!/bin/bash
time=$(date +"%Y-%m-%d_%H%M")
dayFolder=$(date +"%Y-%m-%d")

# Check if the folder exists or create it....
mkdir -p /home/pi/Pictures/Time-Lapse/$dayFolder

raspistill -w 1920 -h 1080 --quality 75 -o /home/pi/Pictures/Time-Lapse/$dayFolder/$time.jpg

Step 3: Reduce the Size of the Photos of Yesterday

During the night, the photos will be black. And their size will be around 200Kb.
However, during the day, the size will be around 2Mb.
If you take a photo every minute, you will have 1440 photos every day.
That means that every day you will have around 2000Mb.

If you reduce the size of the photos, one day could be around 200Mb.

With this, you have to think about the size of your Micro SD card.
Also you can think to attach a huge USB and save the photos there.

Well, knowing that the photos will take up a lot of space, I prepared one script to reduce the photos the next day.
Why the next day and why not after taking the photo?
Well, I preferred to compress all in once, but you can compress the photo after taking it.

I decided to execute the script at 1am because the photos at this time are not so big and the timing of taking them is very short.

You need to install a program, imagemagick:

sudo apt-get install imagemagick -y

We need to add one line on crontab:

sudo crontab -e

Then, add at the end this line:

0 1 * * * sh /home/pi/Documents/ReduceQualityYesterday.sh 2>1&

Now, you need to create the script.
Go to the folder, create the file "ReduceQualityYesterday.sh" and add this text on it:

#!/bin/bash

folderYesterday=$(date -d "yesterday" '+%Y-%m-%d')

convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_000*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_001*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_002*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_003*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_004*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_005*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_010*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_011*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_012*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_013*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_014*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_015*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_020*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_021*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_022*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_023*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_024*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_025*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_030*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_031*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_032*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_033*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_034*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_035*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_040*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_041*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_042*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_043*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_044*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_045*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_050*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_051*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_052*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_053*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_054*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_055*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_060*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_061*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_062*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_063*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_064*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_065*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_070*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_071*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_072*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_073*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_074*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_075*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_080*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_081*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_082*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_083*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_084*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_085*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_090*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_091*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_092*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_093*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_094*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_095*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_100*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_101*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_102*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_103*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_104*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_105*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_110*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_111*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_112*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_113*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_114*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_115*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_120*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_121*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_122*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_123*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_124*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_125*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_130*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_131*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_132*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_133*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_134*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_135*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_140*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_141*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_142*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_143*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_144*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_145*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_150*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_151*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_152*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_153*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_154*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_155*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_160*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_161*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_162*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_163*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_164*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_165*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_170*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_171*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_172*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_173*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_174*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_175*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_180*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_181*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_182*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_183*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_184*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_185*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_190*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_191*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_192*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_193*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_194*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_195*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_200*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_201*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_202*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_203*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_204*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_205*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_210*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_211*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_212*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_213*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_214*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_215*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_220*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_221*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_222*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_223*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_224*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_225*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_230*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_231*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_232*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_233*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_234*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg
convert -quality 80% '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/'$folderYesterday'_235*.jpg' -set filename:original %t '/home/pi/Pictures/Time-Lapse/'$folderYesterday/%[filename:original].jpg

If you want to compress the photos on a diferent percentage, change "80%" to your desired percentage.
My recomendation, 80 is the best to create the video.

Why the script is so long?
I was using a Raspberry PI Zero W, and it is not so fast.
I had some issues if I group them every hour instead of every 10 minutes.
However, I recomend you to check if you do not have issues with a Raspberry PI 3 or 4.

Step 4: Create the Video

You need to install a program, ffmpeg:

sudo apt-get install ffmpeg -y

We need to add one line on crontab:

sudo crontab -e

Then, add at the end this line:

0 2 * * * sh /home/pi/Documents/CreateVideoYesterday.sh 2>1&

Why at 2am?
Well, at 1am you are converting the images, and normally you need them to create the video.
Reducing the size of the images takes time, and to prevent having both at the same time, 1 hour is enough.

Now, you need to create the script.
Go to the folder, create the file "CreateVideoYesterday.sh" and add this text on it:

#!/bin/bash

folderYesterday=$(date -d "yesterday" '+%Y-%m-%d')

ffmpeg -r 25 -pattern_type glob -i '/home/pi/Pictures/Time-Lapse/'$folderYesterday'/*.jpg' -c:v copy '/home/pi/Pictures/Time-Lapse/'$folderYesterday'.avi'<br>

With this script you will have all the videos on the same folder.

Step 5: Recomendations

I know that we normally do not have a 256Gb Micro SD card on the Raspberry PI.
That means that our Micro SD card will be without space in a few days.

Recomendations:

- First of all, check that all works without errors for 3 days (to say a numer of days, but it could be 2 or 4 if you want).

- Adjust the number of pictures that you have to take. One per minute, one per hour....
Less pictures per day means less ocupied space per day. That means that you have to take care about the space not every 2 days.

- Move the videos to your normal computer every 2 or 3 days to have more space on your Raspberry PI.

- Move the photos to your normal computer every 2 or 3 days if you want to keep them. Or remove the photos every 2 or 3 days. The numebr of days depends on the size of your Micro SD card.

Be the First to Share

    Recommendations

    • Backyard Contest

      Backyard Contest
    • Make it Fly Challenge

      Make it Fly Challenge
    • Maps Challenge

      Maps Challenge

    Comments