Drivelapse script - Completed and Working Scripts - CHDK Forum

Drivelapse script

  • 35 Replies
  • 16901 Views
*

Offline gjb

  • *
  • 24
    • Motoscape Rally 2012 - Team Grayson
Drivelapse script
« on: 27 / August / 2012, 11:04:33 »
Advertisements
Introduction
In just a few days, my friend and I will be taking part in a rally across Europe, covering 12 countries in 7 days in a 17-year-old car bought for just £333 (€400; $500). We are doing this to raise funds for our chosen charity, Action Medical Research.

We plan to capture a timelapse of the entire trip, condensing each day of driving into a short video.

There are plenty of excellent timelapse scripts available for CHDK, but capturing images from a moving vehicle has specific requirements. I was unable to find a script for this purpose, so I decided to create 'Drivelapse' (attached).

Hardware requirement
The script was written for a Canon SD800 IS (IXUS 850 IS). It may work with other camera models, but I have been unable to test this. Attempting to use the script with a camera that has a variable aperture as opposed to an ND filter will result in the depth of field changing between shots. It was designed for IXUS/SD-series cameras.

CHDK version
The script has been tested with CHDK 1.1. It has not been tested with other versions.

Configuration
The script has the following configurable parameters:

Target interval (sec)
This specifies how often a photo is taken. This should be 1 second for the smoothest results, but a larger interval can be considered if you have limited storage space.
Default: 1

Focus (mm)
This specifies the focus distance. Usually, this should be 'infinity' to capture the scenery, but you can reduce it if you need to focus on something closer to the camera.
Default: 65535 (infinity)

Target Tv96
This specifies the shutter speed to be used. A small amount of motion blur is desirable as it will result in a smoother video.
Adding or subtracting 96 from this value will result in a doubling or halving of the shutter speed respectively.
Default: 576 (1/60 sec)

Minimum Sv96
This controls the minimum ISO to be used. It should be set to the minimum Sv96 for your camera model.
Default: 371* (ISO 80)

Maximum Sv96
This controls the maximum ISO to be used. It should be set to the maximum Sv96 value for your camera model, or lower if the noise level is not acceptable.
Default: 795* (ISO 1600)

* These are the Sv96 values for a Canon SD800 IS. To determine the correct values for your camera model, you can use this script.

The default settings should be fine for the majority of use cases.

Prerequisites
  • Manually set the white balance to 'Sunny'. Do not use auto white balance or the colour temperature will vary between shots.
  • Set the metering mode to 'Center weighted'. This gives more consistent results than evaluative metering.
  • Set exposure compensation if required. This is largely dependent upon how much sky appears in the composition relative to the road, but generally +1/3 produces good results.
  • Set the image format to 16:9.
  • Set the image quality to 'Normal'.
  • Securely mount the camera to the inside of the vehicle. Use of a windscreen suction mount is recommended.
  • Powering the camera from a DC adapter (or AC adapter in conjunction with a power inverter) is highly recommended.
  • If required, set the script to auto start when the camera is powered on.

How it works
The script allows the camera to enable/disable the built-in ND filter according to the current light level. It then sets the shutter speed to Target Tv96, and adjusts the Sv96 (ISO) to achieve a correct exposure taking into account any exposure compensation. This works much like a shutter-priority mode.

If a correct exposure cannot be obtained due to over-exposure even at Minimum Sv96, the shutter speed is increased until a correct exposure can be achieved. This will result in a shutter speed faster than Target Tv96 if it is particularly bright.

If a correct exposure cannot be obtained due to under-exposure even at Maximum Sv96, the shutter speed is decreased until a correct exposure can be achieved. This will result in a shutter speed slower than Target Tv96 if light levels are low, but has the advantage of creating some nice light trails when driving through tunnels etc.

The exposure is recalculated prior to each shot to allow for changing lighting conditions.

Status display
The script will display the amount of recording time left until the memory card becomes full. Note that if you are using a memory card that is capable of holding over 9,999 shots, the script will display 'Over X hours' until there are fewer than 9,999 shots remaining.

In addition, the Av96, Tv96 and Sv96 values used for each shot will be displayed.

Sample
This sample video was produced using LRTimelapse in conjunction with Adobe Lightoom. It was rendered at 25fps.

Drivelapse: Sandbach, Cheshire to Hinckley, Leicestershire

This was one of a number of test videos that we made prior to the rally. It is slightly underexposed, so could have done with +1/3 or +2/3 of exposure compensation.

Donate
A lot of time and testing has gone into developing this script. If you find it useful, please consider making a donation to Action Medical Research.

You can also follow our Facebook page to see our timelapse videos as they are posted. The rally starts on 1 September 2012.

Feedback
Any comments, suggestions or feedback welcome. Please let me know if you find this script useful, or if you can confirm that it works with any other camera models.



Changelog

v1.0: Initial release
v1.1: Adds a check to verify that the camera is in record mode. If not, switches to record mode. (Thanks lapser and waterwingz)
« Last Edit: 28 / August / 2012, 04:39:46 by gjb »

Re: Drivelapse script
« Reply #1 on: 27 / August / 2012, 11:44:59 »
Nicely done.  A good clean looking script !

I'm curious though - did you have to do anything special to get the camera to maintain a 1 fps shooting rate ?
Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline gjb

  • *
  • 24
    • Motoscape Rally 2012 - Team Grayson
Re: Drivelapse script
« Reply #2 on: 27 / August / 2012, 12:03:32 »
Nicely done.  A good clean looking script !

I'm curious though - did you have to do anything special to get the camera to maintain a 1 fps shooting rate ?

Thanks!

The script only uses 1 second as a target. If the camera is unable to keep up -- for example in very low light, the shutter speed may drop as low as 1/2 second -- then there will be more than 1 second between shots.

Re: Drivelapse script
« Reply #3 on: 27 / August / 2012, 12:07:59 »
The script only uses 1 second as a target. If the camera is unable to keep up -- for example in very low light, the shutter speed may drop as low as 1/2 second -- then there will be more than 1 second between shots.
That's about what I expected.  Have you experimented with going to lower resolution jpg's ?  I did some experiments a year ago where SD card time proved to be a big part of the limiting factor on shooting rate so more compression = smaller files = faster saves.

Ported :   A1200    SD940   G10    Powershot N    G16


*

Offline gjb

  • *
  • 24
    • Motoscape Rally 2012 - Team Grayson
Re: Drivelapse script
« Reply #4 on: 27 / August / 2012, 12:19:28 »
That's about what I expected.  Have you experimented with going to lower resolution jpg's ?  I did some experiments a year ago where SD card time proved to be a big part of the limiting factor on shooting rate so more compression = smaller files = faster saves.

I did experiment with the different resolutions and qualities.

For this particular case, we wanted to produce a 1080p video. The camera only has one built-in 16:9 resolution, so that seemed like the best option. Any of the other aspect ratios would end up storing unnecessary pixels.

As for the qualities, I couldn't see any difference between Normal and Superfine, and there was a considerable difference in file size between the two.

Fast SD cards are pretty cheap now. We managed to pick up a 32GB class 10 SDHC card, so that should be good for around 10 hours recording at 1 shot per second.

*

Offline lapser

  • *****
  • 1093
Re: Drivelapse script
« Reply #5 on: 27 / August / 2012, 18:33:50 »
Worked great with the new SX260 pre-release beta if I start in record mode. But when I started the script in play mode with the lens retracted it crashed the first time. Tried it again and the lens made a grinding noise as it extended out, but it worked. Removed the first focus call and started in play mode. Got a card full error. Maybe adding something at the beginning to put the camera in record mode followed by a delay would help.

I noticed you do a press "shoot_half" followed by click "shoot_full" without a release "shoot_half". It seems to work. I'll have to experiment with it.

The fastest I can get the sx260 to shoot from a script is about 2 seconds per picture, so it's always shooting as fast as it can. I noticed that your video speeds up and blurs more at the end, probably because the shutter speed is longer. It would be better to have the final video play back at a constant speed.

Have you thought about just recording a video with the camera, or any video camera, and speeding that up? The problem with Canon is the 4GB file limit, which comes out around 30 minutes max.

A few questions for the gurus here:

1. Can a script start a video recording and when it stops after 30 minutes or so, start recording another video immediately?

2. How do you find the path of the picture file that was just saved, for JPG and RAW files (from a script)?
    It would be nice to add a suffix to the file name if you missed the target time interval. I.E. -2 means there are 2 intervals between shots, so slow down the output video by 1/2 to maintain constant speed.
EOS-M3_120f / SX50_100b / SX260_101a / G1X_100g / D20_100b
https://www.youtube.com/user/DrLapser/videos

Re: Drivelapse script
« Reply #6 on: 27 / August / 2012, 19:16:55 »
Maybe adding something at the beginning to put the camera in record mode followed by a delay would help.
I usually put this at the start of all my production scripts :
Code: [Select]
if get_mode = 0 then goto "in_rec"
  sleep 1000
  set_record 1
:wait_rec
  sleep 100
  if get_mode <> 0 then goto "wait_rec"
:in_rec

Quote
I noticed you do a press "shoot_half" followed by click "shoot_full" without a release "shoot_half". It seems to work. I'll have to experiment with it.
As long as you don't do the release "shoot_half",  the camera will hold the previous exposure setting.

Quote
The fastest I can get the sx260 to shoot from a script is about 2 seconds per picture, so it's always shooting as fast as it can.
Try dropping the resolution (as I mentioned in my previous post).  Also,  a fast SD card (class 10) helps.  And if you deleted the set_aflock then things will slow down a lot as the camera refocusses between shots.

Quote
1. Can a script start a video recording and when it stops after 30 minutes or so, start recording another video immediately?
http://chdk.wikia.com/wiki/Continuous_Video_Scripts

Quote
2. How do you find the path of the picture file that was just saved, for JPG and RAW files (from a script)?
    It would be nice to add a suffix to the file name if you missed the target time interval. I.E. -2 means there are 2 intervals between shots, so slow down the output video by 1/2 to maintain constant speed.
That part is tricky - lots of posts about that on the forum but I don't believe I've seen a good answer.
Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline reyalp

  • ******
  • 14080
Re: Drivelapse script
« Reply #7 on: 27 / August / 2012, 21:39:57 »
Quote
I noticed you do a press "shoot_half" followed by click "shoot_full" without a release "shoot_half". It seems to work. I'll have to experiment with it.
As long as you don't do the release "shoot_half",  the camera will hold the previous exposure setting.
I believe the click('shoot_full') will implicitly release shoot_half. click('shoot_full_only') will click only the shutter stage.
Quote
Try dropping the resolution (as I mentioned in my previous post).  Also,  a fast SD card (class 10) helps.  And if you deleted the set_aflock then things will slow down a lot as the camera refocusses between shots.
On some cameras, the low resolution modes have actually been found to be slower than full res, so experiment. On newer cameras, the ISO3200 / HIGH ISO / FAST modes are very fast. Using CHDK, you can force the actual ISO low in high ISO mode, although the quality is still reduced compared to shooting a normal image of the same size. You also can't shoot raw in this mode.
Don't forget what the H stands for.


Re: Drivelapse script
« Reply #8 on: 27 / August / 2012, 21:49:44 »
I believe the click('shoot_full') will implicitly release shoot_half. click('shoot_full_only') will click only the shutter stage.
Doh !  :-[
Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline gjb

  • *
  • 24
    • Motoscape Rally 2012 - Team Grayson
Re: Drivelapse script
« Reply #9 on: 28 / August / 2012, 04:37:50 »
Maybe adding something at the beginning to put the camera in record mode followed by a delay would help.
I usually put this at the start of all my production scripts :
Code: [Select]
if get_mode = 0 then goto "in_rec"
  sleep 1000
  set_record 1
:wait_rec
  sleep 100
  if get_mode <> 0 then goto "wait_rec"
:in_rec

I didn't include this check because the camera I am using has a hardware switch to toggle between record and playback modes.

I have updated the attachment in my original post with v1.1, which adds this functionality.

 

Related Topics