Technology
 

UBASIC/Scripts: Time lapse script variable shutter speed

From CHDK Wiki

Written for/on: Powershot S5 IS
Also works on: SD800IS, A590IS
Doesnt works on:

This script attempts is meant to shoot time-lapse videos of sunsets: starting from full daylight and ending in full night, always adapting exposure for a correct shot.

Up to a certain point (when there is enough light to be directly measured) the script exposes automatically, then starts guessing the exposure, increasing first exposure time (up to a certain limit) then ISO (again, up to a certain limit).

Suggested camera settings: Camera mode: manual White balance: Sun (other settings, if desired but not auto) Image size: a small image size (S) is suggested, in order to allow more shots Flash: off Focus: manual, set to infinity Aperture: maximum

Note: all the parameters here are expressed in APEX*96 units, with equivalence.

First, you wll have to decide the delay between one shot and the other (how many seconds between each shot) Suggested values: 5 or 10 seconds. Longer might also be ok, bu the resulting video will be shorter.

Then, you will have to decide what will be the final exposure parameters. These will depend strongly on the type of scene you will be shooting.

Examples of suggested values: Landscape with strong lights (city), illuminated sky 5" (Tv -224) ISO 1250 (Sv 767). Stars will be barely visible Landscape without lights (countryside), dark sky 15" (Tv -384) ISO 2500 (Sv 864) Stars will be well visible

These parameters are called "Limit Tv" and "Limit Sv" in the script.

Finally, you have to decide the "Default Sv", (the ISO settings to start with). I suggest ISO 100 (Sv 419)

Other values ("Guess mode limit" and "Slope in guess mode") are better left to their default values

You can now run the script.

For debugging purposes, the program logs quite some information in the PR_SCREEN.TXT file (in CHDK/SCRIPTS). If you have problems with the script, save the PR_SCREEN.TXT so that problems are better pinpointed.

This is the script:

Script Code (save as "Sunset4.bas" to your /CHDK/SCRIPTS/ folder)

@title Sunset4
  rem Script to shoot time-lapse videos of sunsets
  rem v. 4, Fbonomi apr 30th 2008
  rem Released under GPL
  @param a Delay (sec)
  @default a 10
  @param b Limit Tv 
  @default b -414
  rem (-414=20 sec; -384=15 sec; -320=10 sec; -224=5 sec.)
  @param c Default Sv
  @default c 480
  rem (480=160)
  @param d Limit Sv 
  @default d 776
  rem (776=1250 ISO; 960=5000)
  @param e Guess mode limit
  @default e -200
  @param f Slope in guess mode
  @default f 5
  print_screen 1
  print "Sunset Time Lapse"
  rem initialize guess mode value
  x=e
  rem get start Tv
  get_tv96 T
  rem picture counter 
  p=1
  :loop
  rem measure luminance and aperture
  press "shoot_half"
  sleep 500
  release "shoot_half"
  get_bv96 B
  get_av96 A
  rem release "shoot_half"
  print "Measured: ",B ,A
  rem resulting Tv would be:
  T=B-A
  T=T+c
  print "Calculated T: ", T
  rem check Tv Values
  if T>e then
   rem normal mode, shoot with calculated Tv and default Sc
   X=T
   Y=c
   print "Mode: Standard"
  else
   rem Guess mode, every shot will be 5/96th steps longer
   x=x-f
   if  x>b then 
    rem we are in dark, but exposure is not too long
    rem normal mode, shoot with guessed Tv and default Sc
    X=x
    Y=c
    print "Mode: Guess"
   else
    rem we are in very dark area, we want to avoid too long exposures
    rem shoot with maximum allowed time (b) and
    rem adjust Sv accordingly
    X=b
    Y=c+b-x  
    rem BUT check we don't go in too high ISO!
    if Y>d then
     Y=d
    endif  
    print "Mode: Guess with High ISO" 
   endif 
  endif
  rem we can now shoot
  sleep 100
  set_sv96 Y
  set_tv96_direct X
  sleep 100
  shoot
  sleep 100
  print "SHOOT ",p,X,Y
  p=p+1
  sleep a*1000
  goto "loop"