This is the script I used:
@title Sunset12
rem Script to shoot time-lapse videos of sunsets
rem v. 12, Fbonomi may 22nd 2008
rem Released under GPL
rem incorporates feedback from previous shot: if more than 10% of pixels
rem are in the 100-800 range, decrease exposure
rem also, if the median of the frame is above 250, the exposure
rem is decreased faster
@param a Delay (sec)
@default a 5
@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 N
rem picture counter
p=1
rem initialize delay start time to a long time ago
k= 0 - (a*2000)
rem exposure factors of previous shot
h=0
j=300
rem mark "FIFO BUFFER EMPTY"
Z=-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:
N=B-A
N=N+c
print "Calculated T: ", N
rem check Tv Values
rem per vedere se siamo ai limiti del sensore,
rem invece di controllare N, sarebbe meglio controllare B
if N>e then
rem normal mode, shoot with calculated Tv and default Sc
M=N
L=c
print "Mode: Standard"
else
rem Guess mode, every shot will be 5/96th steps longer
x=x-f
rem but if last exposure was over-exposed, don't decrease,
rem and instead increase at twice the speed
if h>10 then
x=x+f+f
print "Compensating ", h, x
endif
rem If image is highly over-exposed, then step up the speed of decreasing the exposure
rem j is the percentage of pixels that were in the 0-250 range (set below)
rem If less than 50% of pixels are in that range, the median of the histogram
rem is above 250: this means the image is very overexposed
rem (probably because luminance was rising very fast).
rem We therefore have to decrease exposure much faster!
if j < 50 then
x=x+(f*5)
print "Over-compensating ", j, x
endif
rem x has now the desired exposure, we will now attempt
rem to smooth its value (mobile average over 10 shots)
rem the last 10 values of x are stored in a FIFO buffer
rem made by variables Q to Z
rem The first time we are here, the FIFO buffer will be empty
rem let's initialize it
if Z=-1 then
Q=x
R=x
S=x
T=x
U=x
V=x
W=x
X=x
Y=x
Z=x
endif
rem feed the buffer
Z=Y
Y=X
X=W
W=V
V=U
U=T
T=S
S=R
R=Q
Q=x
rem calculate the average of values stored in FIFO buffer
P= Q+Q+Q+Q+Q
P=P +R+R+R+R
P=P +S+S+S
P=P +T+T
P=P +U
P=P/15
print "Smoothed ",x, " ", P
rem P now contains a smoothed value of what was in x
rem avoid overcompensating (guess mode climbing over guess mode limit)
if P>e then
P=e
endif
if P>b then
print "Mode: Guess ", P ,b
rem we are in dark, but exposure is not too long
rem normal mode, shoot with guessed Tv and default Sc
M=P
L=c
else
print "Mode: Guess with High ISO", P ,b
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
M=b
L=c+b-P
rem BUT check we don't go in too high ISO!
if L>d then
L=d
endif
endif
endif
rem wait until a*1000 ticks have occurred since
rem the beginning of previous shot
w=k+(a*1000)
print "wait: start ",k, w
do
until get_tick_count>=w
k=get_tick_count
print "wait: done", k
rem remember when we started the shoot sequence
rem (so next time we can measure the elapsed time)
rem we can now shoot
sleep 100
set_sv96 L
sleep 100
set_tv96_direct M
sleep 100
shoot
sleep 100
rem let's read histogram of the shot that was just taken
exp_get_info 100 800 h
rem h contains the percentage of pixels that are between 100/1024 and 800/1024
exp_get_info 0 250 j
rem j contains the percentage of pixels that are between 0/1024 and 250/1024
print "SHOOT ",p,M,L,h,j
p=p+1
goto "loop"
This script requires my build (see above and ask for binaries for your cameras).
I probably won't be developing it in this form any more, for better results I think I will switch to Jucifer build (that includes the shot_histogram routines) and maybe (MAYBE) to LUA instead of uBasic..