Making a time lapse video on Mac
Me on a time lapse from James Broad on Vimeo.
This video is what you can create (that or something similar) by following these steps on your Mac.
Step 1
Download & install a command line webcam capture utility, we will be using isightcapture
http://www.macupdate.com/info.php/id/18598
Open the DMG and extract the binary to /usr/bin/
sudo cp /Volumes/isightcapture1_1/isightcapture /usr/bin/
Step 2
Set up new directory to work in.
Lets use ~/captures/
cd ~
mkdir captures
mkdir captures/scripts
mkdir captures/series
Step 3
Make script to take photo and save it
cd ~/captures/scripts
vi captureme.sh
Insert the contents into the file:
CAPTURE="isightcapture -t jpg" cd $HOME/captures D1=`date +%y%m%d/%H` D2=`date +%y%m%d.%H%M%S` # If the date directory does not exist, create it if [ ! -d $D1 ] ; then mkdir -p $D1 fi # Construct the filename and path and capture a pic FN="$D1/$D2.jpg" $CAPTURE $FN # Make a symlinked image of the last photo taken if [ -h 'last.jpg' ] ; then rm last.jpg fi ln -s $FN last.jpg
Save and quit (:wq)
To be able to run this script we need to allow execution permission on this file.
chmod a+x captureme.sh
Step 4
Put your capture script on cron
crontab -e
Write the contents:
* * * * * ~/captures/scripts/captureme.sh
Step 5
Install a utility to convert a series of images to a movie. We will be using ffmpeg
cd /tmp/
svn checkout svn://svn.ffmpeg.org/ffmpeg/trunk ffmpeg
cd ffmpeg
We need to install ffmpeg to our machine, this process is going to basically compile the code. Hopefully nothing will go wrong for you here, if it does though, take a look on http://stephenjungels.com/jungels.net/articles/ffmpeg-howto.html
./configure --enable-shared --disable-mmx
sudo make
sudo make install
Step 5
Make script to grab photos and run them through ffmpeg
mkdir ~/captures/videos/
cd ~/captures/scripts
vi make_complete_sequence.sh
Write the contents to the file:
COUNTER=0; rm ~/captures/series/*.jpg for i in `find ~/captures -name '*.jpg'` ; do #Write the filename to be friendly with ffmpeg's odd filename input FILENAME=`printf '%03d.jpg' $COUNTER` cp $i ~/captures/series/$FILENAME let COUNTER=COUNTER+1; done nice ffmpeg -r 20 -vcodec copy -i ~/captures/series/%3d.jpg ~/captures/videos/timelapse_complete.mov
Again setting the permissions to be able to run the script and then run it to generate a movie based on the images taken so far.
chmod a+x make_complete_sequence.sh
./make_complete_sequence.sh
Step 6
View the finished result
Browse in finder to your home directory > captures/videos and watch the result.
14 Comments
There’s significant pixelation in the video, is that from compression rate on the images? Any way to adjust?
@Matt It is the video compression, the images themselves will be pretty clear. To make quality better, modify make_complete_sequence.sh
nice ffmpeg -r 20 -b1800-i ~/captures/series/%3d.jpg ~/captures/videos/timelapse_complete.mp4to be:
nice ffmpeg -r 20 -b 64k -i ~/captures/series/%3d.jpg ~/captures/videos/timelapse_complete.mp4James,
This is a great walk through and worked perfectly for me.
Thanks for being so thorough.
I’ll finish copying you completely by posting a video of one of my days soon!
Cheers,
P
@Phil,
Look forward to seeing your results, glad it worked first time!
[...] lapse video. After seeing James Broad (friend and ex-colleague back from my Yahoo days) post about Making a time lapse video on Mac it got me thinking about how I could do the same using [...]
[...] James Broad has a good step by step tutorial how to use iSight for a timelapse video [...]
I added a call to lsof that keeps the script from running if the screensaver is running.
I added a call to lsof that keeps the script from running if the screensaver is running. http://gist.github.com/111265 (dupe comment sorry)
If you want a GUI to do the same sort of thing, Gawker is an open source project that works well.
@Les Reynolds I agree Gawker is good, this technique is better for running in the background for extended periods of time. Gawker is better suited to running for set periods of time. The other benefit of my approach is that you have a way to capture individual frames at a fairly decent quality and produce films of a particular period of time.
how do i extract the binary? and where do i extract it? i can;’t find user/bin…..
[...] 나의 회사생활. 아침8시-저녁7시 분당 한컷을 10일동안 찍은것을 가지고 초당 30프레임 영상 만들었다. 이런건 할일 없는 이들이 하는 일이라 생각하지 않는다면 한번 해보세요. [...]
[...] have talked in the past about how to get a fully working time lapse system on a Mac using a webcam and some command line scripting. That was great but could do with some tweaks to get [...]
Sadly the required cli app isightcapture is no longer available.
The developer discontinued the app and the download is now broken