Posts Tagged: python


23
Mar 09

Python Timecode Class

It’s a work in progress, but I had to throw this together for a Combined Continuity Spotting List compiler script I’m working on.

Basically it’s just a Python Timecode class. You can initialise it with a string, another Timecode class, or hours/mins/secs/frames as ints. e.g. Timecode( AnotherTimecode ) … Timecode( “01:00:00:00″ ) … Timecode( 1,0,0,0 )

Once initialised you can do what you’d expect … add, multiply, etc. to Timecodes .. you can do maths with Timecodes and ints and floats, and the result will be a Timecode. It converts the Timecode to Frames, does the math, then converts back and returns as a Timecode object.

So … Timecode( “01:00:00:00″ ) * (25/24) will return a timecode corrected for a PAL (25fps) -> NTSC (24fps) time scale, as you would want if doing a timescaled 25fps->24fps->[pulldown]->29.97fps conversion.

Moth_Timecode.py