Open mohitvishnoi opened 5 years ago
If you need alignment code in SRT file replace in to_srt.py
file, in class STL:
the function _readTTI(self):
with the one below:
def _readTTI(self):
while (True):
tci = None
tco = None
txt = []
while (True):
data = self.file.read(128)
if not data:
raise StopIteration()
TTI = dict(zip(
self.TTIfields,
struct.unpack('<BHBBBBBBBBBBBBB112s', data)
))
logging.debug(TTI)
# if comment skip
if TTI['CF']:
continue
# discard blocks with user data
if TTI['EBN'] == 254:
continue
if not tci:
tci = self.__timecodeDecode(TTI['TCIh'], TTI['TCIm'], TTI['TCIs'], TTI['TCIf']) - self.startTime
tco = self.__timecodeDecode(TTI['TCOh'], TTI['TCOm'], TTI['TCOs'], TTI['TCOf']) - self.startTime
text = TTI['TF']
text = self.__parseFormatting(text, self.richFormatting)
text = text.decode(self.codePage).strip()
# tl, tc, tr
if 1 <= TTI['VP'] <= 2:
if TTI['JC'] == 1:
txt += '{\\an7}'
elif TTI['JC'] == 2:
txt += '{\\an8}'
elif TTI['JC'] == 3:
txt += '{\\an9}'
# ml, mc, mr
elif 10 <= TTI['VP'] <= 12:
if TTI['JC'] == 1:
txt += '{\\an4}'
elif TTI['JC'] == 2:
txt += '{\\an5}'
elif TTI['JC'] == 3:
txt += '{\\an6}'
# bl, br
elif 20 <= TTI['VP'] <= 23:
if TTI['JC'] == 1:
txt += '{\\an1}'
elif TTI['JC'] == 3:
txt += '{\\an3}'
txt += text
if TTI['EBN'] == 255:
# skip empty subtitles and those before the start of the show
if txt and tci >= 0:
return (tci, tco, ''.join(txt))
break
Be careful at code alignment. I hope this helps.
While trying to convert STL file with text alignment code after conversion srt file dont show any text alignment code.
Other software converted file
this file show all alignment tag
Original STL file
to_srt.py converted file this file dont show any text alignment tag