raspitimelapse
Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen der Seite angezeigt.
| Beide Seiten, vorherige ÜberarbeitungVorherige ÜberarbeitungNächste Überarbeitung | Vorherige Überarbeitung | ||
| raspitimelapse [2017/02/27 11:51] – noone | raspitimelapse [2017/10/16 23:43] (aktuell) – Externe Bearbeitung 127.0.0.1 | ||
|---|---|---|---|
| Zeile 1: | Zeile 1: | ||
| + | ====Timelapse with Raspberry Pi==== | ||
| + | |||
| + | 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. | ||
| + | |||
| + | http:// | ||
| + | |||
| + | * Raspberry Pi | ||
| + | * camera for Raspberry Pi | ||
| + | |||
| + | ===Step 2: Update=== | ||
| + | |||
| + | 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 -y | ||
| + | |||
| + | These commands take some time to run a few minutes for example. | ||
| + | |||
| + | Then activate the camera, for that you type the following command: | ||
| + | sudo raspi-config | ||
| + | |||
| + | Activate the camera, then reboot. | ||
| + | |||
| + | So much for the activation part. Now we will connect the camera to the Raspberry Pi in a physical way. The camera connects to this location: 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. | ||
| + | |||
| + | ===Step 4: Methode 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 software 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. | ||
| + | |||
| + | Create a folder for all this: | ||
| + | mkdir / | ||
| + | cd / | ||
| + | mkdir stills | ||
| + | |||
| + | then create our file timelapse.sh | ||
| + | cd / | ||
| + | nano timelapse.sh | ||
| + | |||
| + | Copy the following code: | ||
| + | | ||
| + | while [ true ]; do | ||
| + | |||
| + | | ||
| + | / | ||
| + | |||
| + | sleep 4; | ||
| + | done; | ||
| + | |||
| + | 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 | ||
| + | cd / | ||
| + | ls > ../ | ||
| + | |||
| + | Verifiez 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: | ||
| + | |||
| + | 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 ../ | ||
| + | |||
| + | 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 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: | ||
| + | | ||
| + | |||
| + | 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, | ||
| + | |||
| + | Edit the config file using the following command: | ||
| + | sudo nano / | ||
| + | |||
| + | Then add the following line: | ||
| + | | ||
| + | |||
| + | It is then necessary to reboot : | ||
| + | sudo reboot | ||
| + | |||
| + | and that's all. | ||
| + | |||
| + | [[http:// | ||
| + | |||
| + | ====anderer Ansatz==== | ||
| + | |||
| + | Making time-lapse video with raspberry pi and using on-board graphic card to encode the videos! | ||
| + | |||
| + | using raspberry pi camera module and timelapse script | ||
| + | |||
| + | adding the software for encoding | ||
| + | sudo apt-get install debian-keyring | ||
| + | sudo sh -c "echo 'deb http:// | ||
| + | gpg --keyserver pgp.mit.edu --recv-keys 0C667A3E | ||
| + | gpg --armor --export 0C667A3E | apt-key add - | ||
| + | sudo apt-get update | ||
| + | sudo apt-get install libgstreamer1.0-0 liborc-0.4-0 gir1.2-gst-plugins-base-1.0 gir1.2-gstreamer-1.0 gstreamer1.0-alsa gstreamer1.0-omx gstreamer1.0-plugins-bad gstreamer1.0-plugins-base gstreamer1.0-plugins-base-apps gstreamer1.0-plugins-good gstreamer1.0-plugins-ugly gstreamer1.0-pulseaudio gstreamer1.0-tools gstreamer1.0-x libgstreamer-plugins-bad1.0-0 libgstreamer-plugins-base1.0-0 | ||
| + | |||
| + | create folder to store images | ||
| + | mkdir / | ||
| + | |||
| + | Download the time-lapse script from github repo | ||
| + | sudo wget -O / | ||
| + | sudo chmod +x / | ||
| + | |||
| + | edit crontab to execute raspistill every min | ||
| + | sudo crontab -e | ||
| + | * * * * * sh / | ||
| + | |||
| + | command to sort photos to number query | ||
| + | ls -1v | awk ' | ||
| + | |||
| + | command to convert photos to video | ||
| + | | ||
| + | |||
| + | [[http:// | ||
| + | |||
| + | mencoder muss aus den Quellen kompiliert und installiert werden: | ||
| + | wget http:// | ||
| + | bunzip2 * | ||
| + | tar xvf * | ||
| + | cd mplayer-export-2016-03-26/ | ||
| + | sudo apt-get install ffmpeg | ||
| + | ./configure | ||
| + | make | ||
| + | < ... wait a long time here ...> | ||
| + | ./mencoder | ||
| + | sudo make install | ||
| + | |||
| + | [[https:// | ||
| + | |||
| + | eine neuere Variante | ||
| + | [[http:// | ||
| + | |||
| + | ====Create mp4-video==== | ||
| + | sudo apt-get -y install libav-tools | ||
| + | |||
| + | Next you can generate an mp4 video (" | ||
| + | |||
| + | | ||
| + | |||
| + | Since we want to generate a video at the end of the day we add this command to the crontab | ||
| + | |||
| + | sudo crontab -e | ||
| + | |||
| + | Once the crontab editor comes up, add this line. This will run avconv and generate the yesterday.mp4 video at 12:01 AM every day | ||
| + | |||
| + | 1 0 * * * avconv -i " | ||
