Jump to content

Welcome, Guest!

Sign in to follow this  
drewibbo

Tutorial: Time lapse Webcam With The Raspberry Pi, fswebcam and mencoder

Recommended Posts

Time lapse Webcam With The Raspberry Pi, fswebcam and mencoder


A nice easy tutorial now. This one will have you making your own time lapse movies in minutes using a button to start the camera.
I will also show you how to encode them into a short movie. View my sample video here. Here is a list of things that you will need: Rapsberry Pi Debian “Wheezy†Operating System USB webcam (I have used the Trust HD 1080) wiringPi gpio library Download and install the following packages:   sudo apt-get install fswebcamsudo apt-get install mencoder  To install wiringPi type the following into the terminal:   git clone git://git.drogon.net/wiringPi  Once downloaded then type:   cd wiringPi./build  This will install wiringPi on your system.   That is the software taken care of. Now lets take some photos as a time-lapse.
We have a button attached to wiringPi pin 16 on the GPIO header.
  Type the following into the terminal:   sudo nano timeplapse.sh  Copy the following into the file:   #!/bin/sh# Time-lapse capture script# Andy Ibbitson 17-03-2013###############################button=16setup (){echo Setupgpio mode 0 out}# waitButton:# Wait for the button to be pressed. Because we have the GPIO# pin pulled high, we wait for it to go low to indicate a push.#####################################################waitButton (){echo "Press the button to begin the sequence ... "while [ `gpio read $button` = 1 ]; dosleep 0.5done}beginCapture (){i=0echo "CAPTURING... [CTRL+C] to cancel..."while [ $i -lt 750 ]do fswebcam -r 1280x720 -S 15 --jpeg 99 -p MJPEG --shadow --title "IbboCam" --subtitle "BN11 1BY Looking North..." --info "Author: Andy Ibbitson" --save photos/home$i.jpg -q gpio write 0 1 sleep 0.01 gpio write 0 0 sleep 0.5 i=$(($i+1))done}setupwhile true;do waitButton beginCapturedoneSave as timelapse.sh and create a directory called “photosâ€. The script will take up to 750 photos and save them to “photosâ€. You can terminate the script early with CTRL+C.   Once you have taken all of your photos you can then use encode.sh to make your mini movie:   sudo nano encode.sh  Copy the following into the file:   echo "This script will encode a time lapse movie..."echo "\n"echo "ENCODE THE VIDEO NOW? [y/n]..."read inputmakefiledate=$(date +"%d-%m-%Y-%H-%M")if [ $inputmake == "y" ]; then cd photos ls -1tr | grep -v files > $filedate.txt echo "Enter the desired frame rate of the finished movie (15-20 is normal)..." read frames mencoder -nosound -ovc lavc -lavcopts vcodec=mpeg4 -o $filedate.avi -mf type=jpeg:fps=$frames:sc_threshold=-1000000000 mf://@$filedate.txt cd .. echo "\n" echo "Your time lapse movie has been created. It has been saved to the photos directory." rm *.jpg rm *.txt else echo "OK THIS SCRIPT WILL NOW EXIT... Nothing has been done." exitfi  And there we have it! Take a look at your time lapse movie.   One tip: Clouds make great subject matter as do people. :D

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

About Us

Bringing you the latest Raspberry Pi news, tutorials and user forum.

The Fruity Computer

×
×
  • Create New...