Today I raised the issue of “time lapse”, a particular photographic technique that through the sequence of shots allows the creation of small animations. To get an idea of what the time lapse, I refer you to spectacular video easily available on youtube, or rather those dedicated of this page.
For the good time lapse is necessary to automate the process of shooting, in practice things are not handled personal skill, the better the final result.
What you need for a traditional time lapse:
- a tripod for the camera (or a fixed support, in order not to move),
- a system that allows me to shoot without touching the camera (this is. remote control),
- a good deal of attention / precision to take at regular intervals,
- free time (at least an hour for a short video),
- a lot of desire.
While for a time lapse automated serves much less “steals”:
- a tripod for the camera (or a fixed support),
- a cable to connect the camera to your computer,
- “gPhoto2” and (eventually) “cron”,
- ffmpeg to encode the shots in a video.
In the last tutorial we discussed how “gPhoto2” let us take pictures remotely through the simple USB connection of the camera to pc. In the past I wondered what could serve to take pictures remotely, the mirror of the SLR is easily audible and in case of video surveillance would alert thieves (you probably just steal the camera), and here is the practice appilcazione, or one of the possible: the time lapse.
First we position the camera to shoot something interesting: a scene that changes appearance with the slow passage of time. It can be, un tramonto, a busy street at night, a concert or event. The camera must be supported / secured to something solid, as a wall, un davanzale, or better yet a special stand so that it does not move.
We connect our cameras to the PC with the USB cable. At this point, the most recent distributions gPhoto2 will use to mount the camera directly and allow us to download photos via the file-default browser. To enable automatic clicks but it will be essential that the camera is not mounted, the easiest way is to open file manager in Gnome, click with the right button in the left column on the resource corresponding to the camera and select “Skinned” or “Remove drive safely”.
We check that gPhoto2 and camera are able to “communicate”. Run the command to take a picture “gphoto2 –capture-image”. If the shutter is tripped and the picture is saved in the internal memory can go to the next step.
As described in the previous article gPhoto2 is a software (as well as fun) full of features, you run the risk of “waste” much time to play with it. To make sure that the machine photo shots of continuous, set an interval in seconds, and determine the total number of shots the command is this: ”
gphoto2 -I <#secondi> -F <#scatti> --capture-image --get-all-files“.
If there is any problem, and the camera is not recognized after a few shots, I refer you to section “Problems” at bottom of article. At this point we have a series of shots in ascending order, and we want to encode a video. The easiest thing is to use ffmpeg, a command line program for encoding video. Fortunately ffmpeg is automatic and aligns the images in ascending order, Unfortunately, if you find a “hole” between a file and the other does not skip to the next, but interrupts the coding (this is. missing photo 36 fra photography 35 e la 37). For this we have to rename all the files in ascending order so that there are no missing photos. The fastest way is still the shell. The command is this: ”
ls *.jpg | nl -nrz -w5 | while read newname oldname; do mv "$oldname" $newname.jpg; done“. Create files with names 5 characters, in increasing numbers.
And now finally usiamo ffmpeg: ”
ffmpeg -i '%05d.jpg' -target pal-dvd -y video.mpg“.
For more complex time lapse camera is made to slip on a track with every shot, so that in the final composition to have the impression of a scene shot “a mano”, dal life.
I do not have an objective, but from my personal experience it seems that gphoto2 does not like much of my camera. The problem does not always occur, it is the red LED of operation of camera. When you set an interval between two shots, the LED continues to flash intermittently. This means that gphoto2 is working, and waiting for the moment to take, but after a few shots I noticed that the camera is no longer recognized. I solved the problem with Cron, a small program command line already present in Linux distributions.
Cron is a simple program whose job is to run programs at certain intervals. The configuration file is “crontab”, to change it launch the command from the terminal “crontab-e” and my looks more or less like:
# Edit this file to introduce tasks to be run by cron. # # Each task to run has to be defined through a single line # indicating with different fields when the task will be run # and what command to run for the task # # To define the time you can provide concrete values for # minute (m), hour (h), day of month (dom), month (mon), # and day of week (dow) or use '*' in these fields (for 'any').# # Notice that tasks will be started based on the cron's system # daemon's notion of time and timezones. # # Output of the crontab jobs (including errors) is sent through # email to the user the crontab file belongs to (unless redirected). # # For example, you can run a backup of all your user accounts # at 5 a.m every week with: # 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/ # # For more information see the manual pages of crontab(5) and cron(8) # # m h dom mon dow command * * * * * /home/joe/script/time_lapse.sh * * * * * sleep 15; /home/joe/script/time_lapse.sh * * * * * sleep 30; /home/joe/script/time_lapse.sh * * * * * sleep 45; /home/joe/script/time_lapse.sh
The interesting lines are the last four. With this configuration, the last four lines launch the script “/home/joe/script/time_lapse.sh” every minute. The first retail precise, the second 15 seconds after, the third 30 seconds after the fourth and with a delay of 45 seconds. In this way snap photos spaced 15 seconds of each other (longer the shutter speed).
To get a general idea of working with cron, rimando a Wikipedia.