Introduction: Timelapse With the Raspberry Pi and His Camera
this video was example.
you never dreamed of making videos in timelapse, to film an event in accelerated?
This tutorial will aim to set up the camera, then use it to make a timelapse taking regular photos and then mount them on video Installed mencoder.
For this first tutorial, so we will put some home automation and robotics for next to toy and make a beautiful timelapse
Step 1: 3d Print and Materials
the first thing I suggest you do is to print in 3D, support for your camera.
well, your film will be perfectly fixed
A Raspberry Pi
A camera for Raspberry Pi
And that's all ! Hehehehe!
Step 2: Update
Update Raspberry Pi:
Above all, you will have to update your Raspbian to get the latest drivers embedded in this distribution.
To do this, begin by running the following command:
sudo apt-get update
sudo apt-get upgrade
These commands take some time to run a few minutes for example.
Then there is activate the camera, for that you type the following command:
Then activate the camera, and when one offers to reboot, say yes!
Step 3: The Camera
In Raspi config, the camera is activated (pic 1)
and we active (pic 2)
So much for the activation part. Now we will connect the camera to the Raspberry Pi in a physical way.
Connect the camera
The camera connects to this location: (pic 3)
Gently pull to unlock the Csi port, then insert the camera cable so that the little blue portion of the cable faces the Ethernet port.
We plug in this direction! We plug in this direction! Any connection is seen in this video of the Raspberry Pi Foundation.
Step 4: Méthode 1 : Via a Script
The first method is called: the buggers method. My favorite :)
We will make a script that will loop and that will take a picture every X seconds as you do not quit the process (CTRL + C). We will then use the soft mencoder to assemble these images in a video for our timelapse.
So we will start by creating a script that will turn to regularly take pictures.
One creates a folder for all this:
then creates our file timelapse.sh
Copy the following code:
while [ true ]; do
filename=-$(date -u +"%d%m%Y_%H%M-%S").jpg
/opt/vc/bin/raspistill -o $SAVEDIR/$filename
This script will then save a picture every four seconds in the SAVEDIR file, formatting them so that we have as the name of the photo, the date it was taken.
This script will run as long as you do not stop (via CTRL + C).
For now, we'll settle for this operation not super clean. This is our first timelapse, so we will not take the lead too. I would indicate the end of article for solutions to make it cleaner, or even practice.
We will now install mencoder order to encode images in a video (very good software, with huge capacities but that requires to read the examples and search the doc).
To install, do as usual:
sudo apt-get install mencoder
Confirm and leave the installation to complete. Once completed, then we will list all the images in a file that will pass a parameter to mencoder as sources
ls > ../stills.txt
Vérifiez que ce fichier contienne bien la liste de vos photos (il se trouvera dans le dossier timelapse). Il est maintenant temps de lancer la commande mencoder pour créer la vidéo. Assurez vous que vous êtes dans le dossier des photos, puis lancez la commande suivante :
sudo mencoder -nosound -ovc lavc -lavcopts vcodec=mpeg4:aspect=16/9:vbitrate=8000000 -vf scale=1920:1080 -o tlcam.avi -mf type=jpeg:fps=24 mf://@../stills.txt
I invite you to read the documentation (you will see it is pokey) to get an idea of the options used. Overall, this line means: is recorded without sound (-nosound), using the MPEG4 codec, 16/9, out of the file will be called tlcam.avi, and is taken as a source of jpeg files , which are assembled to compose a second film at the rate of 24 frames / second, using images ../stills.txt listed in the file.
Easy eh :)
Once launched, the command will display some thing like this: (pic 1)
As you can see, this is long .... very long. And because it can only be the limits of our small Raspberry Pi. 3h pictures to compile the video, he does it well, but it takes time (about 1:15 in my example).
Step 5: The Result
You then no longer have to read the video! the sky in france.
Here is the timelapse got this evening sunset (film / north / east). I finally enjoyed the return of the sun to make a less gray video. Although the coup was more texture in the sky, which is a shame ...
Step 6: Method 2: Via the Raspicam Options
But in fact, can be a little easier! If you've looked at the list of available options for the executable raspistill, you may have noticed that there is an option -tl (tl timelapse: p) that allows you to specify the frequency of shooting, and -t option which allows you to specify the total time of the shooting.
So if we execute the following command:
raspistill -o timelapse_%d.jpg -tl 3000 -t 10800000
On va prendre une photo toutes les 3 secondes, sur une durée de 3 heures (3 * 60 * 60 * 1000). Les durées sont exprimées en millisecondes.
Et hop, le tour est joué Vous pouvez ensuite assembler la vidéo avec mencoder comme dans la solution 1.
Disable this ******** red LED
If you do your timelapses behind glass (which is my case saw the rotten time), you will be faced with a problem: the reflection of the red LED in the ice. This LED indicates that a decision is pending. So it can be useful from time to time. But for a timelapse have a red reflection on your video, it drunk. Fortunately, you can disable it :)
Edit the config file using the following command:
sudo nano /boot/config.txt
Then add the following line:
It is then necessary to reboot :
and that's all. do not forget to follow me, and especially to vote for my tutorial
We have a be nice policy.
Please be positive and constructive.