FotoMentum

View Original

Create a Timelapse Using Free Software

This is a repost as I move blogs from my previous hosting service.

In this post I share how I create timelapse videos.  You can see an example on my youtube channel here.

But I must give you a warning, because I geek out in this post.   I combine my photography hobby with my computer geek skills.   I will explain how I made this time lapse completing this 2,000 piece puzzle.

 Setup was very simple.

1) Tripod

2) Camera –Canon XTI

3) Intervalometer

4) Puzzle

Okay, pretty simple so far.  The camera was set to auto focus with manual exposure settings so that the pictures would be consistent.  A very helpful part  of the setup was the location:   my backroom in my basement with no windows.  So no changes in light due to the time of day.

The intervalometer might be something you are not familiar with.  The intervalometer is a simple device connected to my camera to automatically take a photo at specified intervals.  Hence the name “intervalometer.”   I am not endorsing this specific device, but it is similar to the one I use.

I set up the camera on the tripod, set the exposure settings, and connected the intervalometer.  Most times I want high quality photos and have the camera set to large or raw.   This time, though, I set the photo quality to small and no raw.  I then  set the intervalometer to take a picture every 10 seconds and began working on my puzzle.  Every time I worked on the puzzle I would turn on the camera and intervalometer unti I completed the puzzle.

Now, a little truth here.  At this point, I had no idea how I was going to make the time lapse.  Wasn’t even sure that my setup was even a good setup.  But after about 30+ hours of work on the puzzle I had 8,336 photos.

That is a lot of photos and seemed to be more than I needed.  I wanted to use about a fourth of the photos.  But how to get those photos without having to click and copy and paste through over 8,000 photos seemed a little daunting.  If you don't need to reduce the number of photos skip to the next section.

Ready for some computer geeking?    I wrote a powershell script to copy every fourth photo using a simple counter and math.   As my script  goes through the files, I increment a counter and use division and if the remainder = 1, copy the photo to the new destination, otherwise I skip that photo.  This results in a folder with every fourth photo and leaves the original 8,336 photos in tact.  The final folder resulted in 2,084 photos.   You will have to change the folder names in the script and make sure the destination folder exists because I don’t create it for you).  Use my scripts at your own risk.  I do not guarantee it will work.

$path = "D:\PuzzleTimeLapse\AllPics\"

$oldnames = Get-ChildItem $path*.* | select name

foreach ($item in $oldnames)
{

$itemx=$item.name

if ($i%4 -eq 1)
{
copy-item -path $path$itemx -Destination d:\timelapse
}

$i=$i+1

}

END OF SECTION TO SKIP

So, now what.  I have a good set of pictures, but the size is still pretty large if you add them all together and I felt I needed to reduce it even more.   Each photo was about 1.2 to 1.5 MB.

Introduce PhotoShop.  Using the built-in scripts in PhotoShop I reduced every photo to about .5MB or less.

I am finally ready to create the time-lapse.  Looking for timelapse software, they cost 50 dollars or more or come with mal-ware, ads, nag screens, or hijacks of my browsers and toolbars.   However,  I found a great command-line program that comes at no cost, no ads, no mal-ware, no hijacks, no ads, etc.   The owner does ask for donations, and I will give them a donation.  So if you use the software, I hope you do the same.

Here is a link to the software and some instructions on how to use it:

Reading how to use this tool I found the files needed to be numbered sequentially and since I copied every 4th photo, there was no longer a smooth sequence.  It was more like 1, 5,9,13….  You can also use my script below to rename your files just to get them in the format needed for ffmpeg.

Again, there is software available but filled with extras  I would rather not have on my computer.   Back to Powershell.  With all the photos in a single folder, I wrote this script to rename all the photos with a new name with sequential numbering.  Again, use my scripts at your own risk.  I do not guarantee it will work.

$NewName = "img-"
$i = 1
$path = "D:\timelapse\"

$oldnames = Get-ChildItem $path -Filter *.* | select name,lastwritetime | sort name

foreach ($item in $oldnames)
{

if ($i -lt 9)   {$pad = "000"}
if ($i -gt 9)   {$pad = "00"}
if ($i -gt 99)  {$pad = "0"}
if ($i -gt 999) {$pad = ""}

$oldname=$item.Name
Rename-Item $path$oldname -NewName $path$NewName$pad$i.jpg
$i=$i+1

}

I am finally to a point to actually create the time-lapse using ffmpeg.  Instead of getting even geekier with how I learned this command, suffice it to say, it took some trial and error and reading the documentation to figure it out.  I Hope, this works for you as well if you try.

Ffmpeg -r 30 -f image2 -start_number 1 -i C:\Photos\TimeLapse2-20\JPEG\img-%04d.jpg -vf scale=1280:720:-1 ../new_movie.mp4

There is no on the line wrap, so img-%04d.jpg is altogether.

Hope you have good luck if you give this a try.