Category Archives: Python

Truncation to N Decimal Places in Python

I recently needed to truncate some IEEE 754 64bit floating point numbers to a given number of decimal places. I assumed Python would have built-in support for this. Not so.

Now there are reasons for this. The primary one being that you can’t really truncate floating point numbers. Now that being said – if you need to – I present here a good way to approximate the effect.

Continue reading

Closed Captions In SCC Format Python

SCC format subtitles

SCC format subtitles, basically a raw closed caption bitstreams.

After building the first version of the closed-caption decoder, I realized that SCC format would be a more useful format to output in. There are many tools to convert SCC format subtitles into other formats. Additionally SCC captures more of the presentation details of closed captions.

Enjoy.

ccDecode

25 May 2014 Update: An improved version is available see here.

Closed Caption Decoding In Python

I’ve been backing up my Laserdiscs after the problems I had with my players a month or so back, one thing I frequently noticed was the flicker of closed captions at the very top of the captured video file. This greatly intrigued me, as it would be useful to have subtitles these films. I began investigating software options for decoding the captions embedded in the video image area, but was unable to find anything that worked with video file embedded captions, or was cheap enough to justify spending the money on. Having been intending to do some video-processing work in Python this seemed like an ideal warm-up exercise.

Continue reading