Friday, June 19, 2009

Splitting long lines in subtitles files

My media player do not show properly subtitles when the lines are too long. I created this python script to split those lines in shorter ones. Not very nice code, but hope it is useful for anybody else.

import sys

for line in sys.stdin:
if len(line) <= 60: print line, else: print line[:60] print line[60:],

To use it in Linux you can do :

"python <>"

No comments: