Monday, July 30, 2012

Making a Time Lapse movie and dragging the shutter in post production

Since the release of Android Ice Cream Sandwich and the camera's timelapse feature, I've been having fun. Examples:

The only problem is that you cannot drag the shutter because there's no shutter speed control.

So I decided to see if I can do this from a regular movie. Tools needed: avidemux, imagicmagick, QuickTime,

1.  Take the movie and turn into individual images. This will create a LOT of files! AT 25 frames per second, an hour of video will be 90,000 frames!

For this I use avidemux. Open the video file, and move the slider to where you want to start, then click Edit > Set Marker A.

Then move to the end of where you want, and click Edit > Select Marker B.

and now you see how much of the movie you've selected

You can estimate how many frames that'll be.

Then go to File > Save > Save Selection as JPEG Images

Its best to create a new folder for the images, then you have to have a start character. This will give a naming scheme like f0001.jpg f0002.jpg etc

Here's the folder

2.  We need to remove the 'f', and then the extra zeroes.

To remove the 'f' we can use the command

    for f in *; do mv "$f" "${f#?}"; done
each ? in the {} is one character, so the above command removes one leading character.

Then we need to remove the leading zeroes. We can use the command

    for FILE in *; do mv $FILE `echo $FILE | sed -e 's:^0*::'`; done

and that gets us

3.  Simulate dragging the shutter.

Going to use ImageMagick. On OSX you can get a pre-compiled version here, or compile it yourself.

So what you need to do is create a script that averages a number of images, to simulate dragging the shutter. With help from folks on the ImageMagick forum:

        #! /bin/bash
        while [ $i -le $num ]; do
        /usr/local/ImageMagick/bin/convert $i1.jpg $i2.jpg $i3.jpg $i4.jpg $i5.jpg $i6.jpg $i7.jpg $i8.jpg $i9.jpg $i10.jpg -evaluate-sequence mean /path/to/output/result$i.jpg

You can extend this as much as you want.

What does this mean?

  1. totnum is the total number of frames to be processed, which I got from running avidemux above
  2. segnum is the number of images to be averaged into one image ie the duration of the "drag"
  3. In the example above I have 500 frames, and I average 1 to 10, then 2 to 11, 3 to 12 and so on.
  4. The "i=$((i+1))" at the end is critically important: it sets the advance for each averaging cycle, and is in essence the time lapse period you'd set on the camera.

The result is that you can have a drag duration greater than the time lapse interval, which is not possible on a camera.

4.  Join the frames back into a movie. I use Quicktime Pro, version 7. Click File > Open Image Sequence

navigate to the folder with the processed images

Click one and select "Open"

Then your framerate for the movie, 25 would be PAL standard, and after a few seconds, depending on the number of frames the movie appears. Here it uploaded to YouTube.

dragging 100 frames, timelapse 25

Some interesting aspects to this.

Basically you can drag / blend over one period / duration, and time lapse over a different one.

ImageMagick can hold up to 999 images in RAM, so the maximum drag would be 40 seconds at PAL fps. Bear in mind that "dragging" ie averaging lots of images can takes a long time, and if you have 1hr of original movie, thats 90,000 frames to process. You may need to run the script overnight.

Here's another example where I've blended over 500 frames ie 20 seconds, and timelapsed at one frame per second.

drag = 500, timelapse = 25

drag = 500, timelapse = 500

Just to mention that I'm a novice at this, so my terminology may be incorrect and my techniques rudimentary. Certainly I think someone could  make a plugin for Final Cut, or Adobe Premier, or even iMovie.

Wednesday, July 25, 2012

How fast is AES-NI on a Mac?

Previously I looked at the then new Apple Mac laptops with Core i CPUs and their AES-NI hardware extensions. Since then I've learnt that the openssl shipping with Mac OSX Lion has not been compiled with AES-NI support.

Here's an easy way to tell. From the command line run "openssl engine"

$ openssl engine
(aesni) Intel AES-NI engine
(dynamic) Dynamic engine loading support(dynamic) Dynamic engine loading support

See the line "(aesni) Intel AES-NI engine"? if its not there, then its not happening.

And thats how I know openssl on Mac OSX Lion 10.7.4 doesn't have it.

So how to benchmark? Turns out that Truecrypt has a benchmarking engine.

1.  Launch Truecrypt and click "Create Volume"

2.  Then click "create an encrypted file container"

3.  Give it a name, doesn't matter what and where, we'll never save it

4.  Then Benchmark

5.  When this screen loads, select a buffer size and press Benchmark. Try not to have any other processes eg browsers running since this will skew the results.

Here's an example - this is a Core 2 Duo at 2.26GHz

and Core i5 at 1.6 GHz with AES-NI

As you'd expect, huge difference!

Some more here

Friday, July 6, 2012

Howto Connect to Mac OSX Client VPN from iPad

Howto connect to Mac OSX Client VPN from iPad.

Mac OSX Server has the VPN GUI, but what if you have the client / desktop version of Lion or Snow Leopard.

Fortunately, help is at hand, from, where there ther is an app called vpn-activator.

Download, drop it into the Applications folder, put in some details, and click 'start'. Easy as.

image from

You'll need to setup your firewall / NAT device to forward UDP ports 500, 1701 and 4500 to the machine you want to connect to:

Also, if the VPN server has Little Snitch or other local traffic blocker, you'll need to allow RACOON service to connect to the Internet.