Skip to content
Browse files

added start offset option

  • Loading branch information...
1 parent 3b7fe82 commit 89d63cf7819775b9f61fafaf6bfe64518cfe104a @digi604 committed Feb 7, 2012
Showing with 5 additions and 6 deletions.
  1. +5 −6 stl2srt.py
View
11 stl2srt.py
@@ -176,12 +176,12 @@ class STL:
TTIfields = 'SGN SN EBN CS TCIh TCIm TCIs TCIf TCOh TCOm TCOs TCOf VP JC CF TF'.split(' ')
- def __init__(self, pathOrFile):
+ def __init__(self, pathOrFile, offset):
+ self.offset = float(offset)/1000
if isinstance(pathOrFile, file):
self.file = pathOrFile
else:
self.file = open(pathOrFile, 'rb')
-
self._readGSI()
def _readGSI(self):
@@ -211,7 +211,7 @@ def _readGSI(self):
int(GSI['TCF'][2:4]),
int(GSI['TCF'][4:6]),
int(GSI['TCF'][6:8])
- )
+ ) - self.offset
logging.debug(self.__dict__)
def __timecodeDecode(self, h, m, s, f):
@@ -257,16 +257,15 @@ def next(self):
parser = OptionParser(usage = 'usage: %prog [options] input output')
parser.add_option('-d', '--debug', dest='debug_level', action='store_const', const=logging.DEBUG, default=logging.ERROR)
-
+ parser.add_option('-o', '--offset', dest='offset', help='start offset in milliseconds', default=0)
(options, args) = parser.parse_args()
@yanncoupin
yanncoupin added a note Feb 8, 2012

You should probably specify the type of the parameter by adding type="int" and remove the inline conversion below

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
-
if len(args) != 2:
parser.print_help()
sys.exit(1)
logging.basicConfig(level=options.debug_level)
- stl = STL(args[0])
+ stl = STL(args[0], int(options.offset))
c = SRT(args[1])
for sub in stl:
(tci, tco, txt) = sub

0 comments on commit 89d63cf

Please sign in to comment.
Something went wrong with that request. Please try again.