#!/usr/bin/env python import argparse import sys import re ap = argparse.ArgumentParser("convert srt into vtt") ap.add_argument('infile', nargs='?', type=argparse.FileType('r'), default=sys.stdin) ap.add_argument('outfile', nargs='?', type=argparse.FileType('w'), default=sys.stdout) args = ap.parse_args() print ("WEBVTT\n", file=args.outfile) for line in args.infile: print (re.sub(r"(\d\d:\d\d:\d\d),(\d\d\d) --> (\d\d:\d\d:\d\d),(\d\d\d)", r"\1.\2 --> \3.\4", line.rstrip()), file=args.outfile)