Time-Lapse Calculator - Script Writing - CHDK Forum

Time-Lapse Calculator

  • 2 Replies
Time-Lapse Calculator
« on: 05 / September / 2008, 21:32:52 »
I was trying to learn how to write scripts because I wanted to have a simple way to find out how many frames I would need for a video of a certain length. I came up with the script below. Could someone look this over and see if is written right? It SEEMS TO BE working properly, but I'm not sure I did the calculations and used the basic commands right. Especially that % command thing in the print statements. I was really bad in math when it came to rate, distance, time calculations for some stuff. My mind can't wrap itself around time related concepts. I'm sure I must have done something wrong.

Code: [Select]
@title Time-Lapse Calc
@param h Video Hours Needed
@default h 0
@param m Video Minutes Needed
@default m 1
@param s Video Seconds Needed
@default s 0
@param f Frame-Rate
@default f 30
@param M Shoot Interval Minutes
@default M 0
@param S Shoot Interval Seconds
@default S 10

rem Shoot Interval is your intervalometer shooting rate

rem calculate needed video-length in seconds

rem calculate intervalometer shoot-time in seconds

rem calculate total shooting time needed in seconds

rem display results in console

print "Shoot " v*f " frames,"
print "for " t/3600 " H, " t%3600/60 " M, " t%60 " S"


Re: Time-Lapse Calculator
« Reply #1 on: 14 / September / 2008, 13:35:44 »
Your math looks correct to me.

I used to code in Qbasic a long time ago
I would suggest using brackets to make the math more readable,
 making it obvious that       v=h*3600+m*60+s        is calculated like this     v=(h*3600)+(m*60)+s

I find it to be a good habit for when you get into large equations.

Re: Time-Lapse Calculator
« Reply #2 on: 15 / September / 2008, 09:04:19 »
If I remember right, capital variables will not work in the param statements at the beginning. You can use them in the rest of the script, but in that part, you can only use lowercase.


Related Topics

SimplePortal 2.3.6 © 2008-2014, SimplePortal