Friday, May 17, 2024
43
rated 0 times [  43] [ 0]  / answers: 1 / hits: 65435  / 2 Years ago, tue, december 14, 2021, 12:37:18

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.


More From » software-recommendation

 Answers
3

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


mkdir ~/Desktop/cap
cd ~/Desktop/cap

We use streamer to do the capture so let's install it:


sudo apt-get install streamer

And now we want to capture


streamer -o 0000.jpeg -s 300x200 -j 100 -t 2000 -r 1

-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 including mencoder but I just prefer ffmpeg's outlook on life. After installing it (sudo apt-get install ffmpeg) just wang out this:


ffmpeg -r 30 -i %04d.jpeg -s hd480 -vcodec libx264 -vpre hq time-lapse.mp4

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.


[#44464] Wednesday, December 15, 2021, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
diket

Total Points: 167
Total Questions: 124
Total Answers: 109

Location: Somalia
Member since Wed, Mar 15, 2023
1 Year ago
diket questions
Fri, Dec 24, 21, 22:31, 2 Years ago
Fri, Mar 31, 23, 02:30, 1 Year ago
Mon, Jan 23, 23, 05:58, 1 Year ago
Tue, Nov 1, 22, 02:02, 2 Years ago
;