I have a webcam that works as a v4l2 device.
What is the most convenient way to capture either a stop-motion or time-lapse video?
N.B.
stop-motion and time-lapse are related but conceptually different.
Time-lapse is where you take a photo of a scene at a set interval and then combine it into a video (that looks like it's going really fast).
Stop-motion is where you control the scene and take an image for every change you make, to form an animation (eg Wallace and Grommit).
An application for time-lapse needs to be able to take a photo at a set interval.
Capturing a zillion images.
The first step is capturing images. Let's imagine you want to take a photo once every 10 seconds and save that into a directory sitting on your desktop
We use
streamer
to do the capture so let's install it:And now we want to capture
-t
is the number of frames we want to capture.-r
is frames per second. So this should grab one frame every second. If you compress that down into a 30fps video, one minute of capture becomes 2 seconds of video. You'll want to tune this appropriately depending on how much output video you want.That line will give you 2000 images, it'll take half an hour to record and, at 30fps, will generate just over 1 minute of video.
Putting it all together
I'm going to use
ffmpeg
. There are many different ways of putting it together includingmencoder
but I just preferffmpeg
's outlook on life. After installing it (sudo apt-get install ffmpeg
) just wang out this:The quality settings there aren't anything like that of my webcam so you might want to play around with the options a lot more to get a better encode, but that should generate you a nice 30fps video, compressed up in x264.
You might want to play around with the framerate (
-r
) but I wouldn't go below 15fps.To capture every X amount of seconds from a webcam use motion.
Install
motion
sudo apt-get install motion
orsudo aptitude install motion
Configure motion for every X amount of seconds
sudo nano /etc/motion/motion.conf
Change the variables minimum_frame_time and snapshot_interval to the same amount of seconds you wish to take the picture with the webcam.
10 Minutes = 600 Seconds
20 Minutes = 1200 Seconds
30 Minutes = 1800 Seconds
1 Hour = 3600 Seconds
2 Hours = 7200 Seconds and so on...
run motion with
sudo motion
stop it with CTRL+CNOTE - Configure motion.conf to save the files in another directory than the default /tmp. For example your home folder. Since going to /tmp needs more privileges. You will also find many useful options in the motion.conf for many other things you might like.
gTimelapse (Download Link)
Compile instructions
Download the source from the sourceforge website
in a terminal type the following:
To run the application type
n.b. 1
n.b. 2
see this blog for further useful info
lists all compatible devices that the application supports
n.b. 3
I've read the gphoto2 does not support webcams - I'll leave this answer visible anyway just in-case anyone wants to try this answer with a decent digital camera instead of a webcam.
From this edit by an anonymous user.
I've used Stopmotion to do this, it's in the software center. You can also capture with Cheese, but you have to alter Cheese's configuration to boost the max number of images. I found it easiest to just use Stopmotion for the entire process.
The best and easy way to do this is by installing Motion. It's full-scale surveillance software for Linux-based operating systems.
You should be able to set up motion (in motion.conf) to stream - by default it streams on port 8081. All you then have to do to get your 'rear view' mirror is to open VLC, "Open Network Stream" and point it at http://localhost:8081.
Camorama is a webcam viewer/recorder which I've used to take pictures, at 1 minute intervals and upload them to a webserver, from my webcam; it's a straightforward setup. Also it's available in the Ubuntu Software Center or you can install it using:
Hope this helps.