Requirements: FFmpeg :

Editing the bash_profile:

In VIM editor press’i’ key to edit the file

  • esc : w to write the file
  • esc : x to close the file

vim ~/.bash_profile

  • alias ccap=’cd ~/Desktop/Screencapture/’
  • alias scap=’ruby timelapse.rb start’
  • alias dcap=’ruby timelapse.rb delete’
  • alias ecap=’ruby timelapse.rb encode’
  • alias pcap=’ruby timelapse.rb play’
  • alias lcap=’ls -shR’
  • alias cap=’ruby timelapse.rb help’


# first i store the givin parameter
argument = ARGV[0]
# And i store the time
time =
day =
hour = time.hour
minute = time.min
seconds = time.sec
# Then i store the time concatenated
capturename = “#{day}#{hour}#{minute}#{seconds}”
# Now i check what parameter has been givin
if argument == “start”
puts “capture running”
# Then i take a picture every 4 seconds
# And name it with the current concatenated time
# so that every time i start to capture the files will have a unique prefix
# and then i add a counter number
puts `i=1;while [ 1 ];do screencapture -t jpg -x ~/Desktop/screencapture/#{capturename}$i.jpg; let i++;sleep 4; done`
elsif argument == “encode”
puts “encoding”
# Now i am encoding all screeshots to a mov file
puts `ffmpeg -r 24 -i %*.jpg -b 15000k timelapse#{capturename}.mov`

elsif argument == “delete”
# # Now i am deleteing all screeshots
allFilesInDirectory = Dir.glob(“*.jpg”)
allFilesAmount = allFilesInDirectory.size
i = 0
while i < allFilesAmount
i += 1
elsif argument == “play”
# I find the last modified file by the file name ending of mov
playFile = Dir.glob(“*mov”).max_by {|f| File.mtime(f)}
# And open the last modified file
puts `open #{playFile}`
elsif argument == “help”
puts “**********************”
puts “**** capture Help ****”
puts “**********************”
puts “ccap=’change directory to ~/Desktop/Screencapture/’
scap=’start capture’
dcap=’delete jpg capture files’
ecap=’encode to mov file’
pcap=’play captured mov file’
lcap=’list mov files'”
puts “i dont know the parameter #{argument} !!!”


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s