Hi guys,
I try to find a script which is converts a Qlab5 seconds data to timecode (h m s frm).
Is there a simple scenario to answer this question?
I can convert seconds to h:mm:ss. But how can I convert the remaining data part to frame?
Thanks in advance.
Kalman
I think I found a solution, I show:
tell theSeconds to tell {it div hours, it mod hours div minutes, it mod minutes div 1} to return "" & ((item 1) div 10) & ((item 1) mod 10) & ":" & ((item 2) div 10) & ((item 2) mod 10) & ":" & ((item 3) div 10) & ((item 3) mod 10) & ":" & (((theSeconds * fps mod fps) div 1) div 10) & (((theSeconds * fps mod fps) div 1) mod 10)
Obviously I don’t have the full script so I arbitrarily set the two variables and ran the script:
set theSeconds to 4102
set fps to 24
I think it works fine until you get to fractions of a second.
First, you might consider using a ‘.
’ instead of a ‘:
’ when dealing with the last fraction of a second.
Second, it seems inevitable that you will always end up with 0 as the last number (the div 1
effectively makes the number an integer).
Unless you intend to exclude any remaining frames, this will only be accurate if your video has some multiple of 24 as its number of frames.
Finally, I’ve read that using frame counts is difficult to implement, primarily because most container formats use time stamps to identify frames. So consider using milliseconds, ie 3 decimal places.
Frames are sub section of seconds.
IE Frames per seconds.
If you’re not providing sub-seconds. Your frames are always going to be zero.
Often if this is calculated most often
The time is provided in milliseconds.
Then divide this by 1000 and you have seconds
With decimal amount
You can then get your frames by multiplying the
Decimal amount by your FPS. 24. 29.97. 23.97 etc . You probably need to round that
Just for an interesting project, I wrote a shortcut that is functionally equivalent to the OP’s script.
Convert Seconds.shortcut (22.6 KB)