yuppity / ttml2srt Goto Github PK
View Code? Open in Web Editor NEWConvert TTML subtitles used by Netflix, HBO, CMore and others to SRT format
License: The Unlicense
Convert TTML subtitles used by Netflix, HBO, CMore and others to SRT format
License: The Unlicense
some xml based subtitles has region field, that specifies if the text is supposed to appear on the top or the bottom.
{\an8}, though not a native tag for srt, works with most players to display text on the top.
<layout>
<region tts:displayAlign="before" xml:id="region0"/>
<region tts:displayAlign="after" xml:id="region1"/>
</layout>
Hi, I found an EBU-TT-D file where some timestamps are without milliseconds. I made this small change to accommodate this:
def fraction_timestamp_to_ms(self, timestamp):
"""Convert hh:mm:ss.fraction to milliseconds
"""
if '.' in timestamp:
hh, mm, ss, fraction = re.split(r'[:.]', timestamp)
else:
hh, mm, ss = re.split(r'[:]', timestamp)
fraction = '0'
hh, mm, ss = [int(i) for i in (hh, mm, ss)]
# Resolution beyond ms is useless for our purposes
ms = int(fraction[:3])
return self._scaler(self._hhmmss_to_ms(hh, mm, ss) + ms)
Hi,
i got this error
$ python3 ttml2srt.py Doctor\ Who:\ Unleashed\,\ 60th\ Anniversary\ Specials\,\ Wild\ Blue\ Yonder\ \[m001t439\].en.ttml Doctor\ Who:\ Unleashed\,\ 60th\ Anniversary\ Specials\,\ Wild\ Blue\ Yonder\ \[m001t439\].en.srt
Traceback (most recent call last):
File "ttml2srt.py", line 572, in <module>
ttml.write2file(getattr(args, 'output-file') or '-')
File "ttml2srt.py", line 489, in write2file
for parag in self.paragraphs(generator=True):
File "ttml2srt.py", line 462, in paragraphs
for i, s in enumerate(self.to_paragraphs()))
File "ttml2srt.py", line 380, in to_paragraphs
[self.process_parag(p) for p in self.lines], key=lambda x: x[0])
File "ttml2srt.py", line 380, in <listcomp>
[self.process_parag(p) for p in self.lines], key=lambda x: x[0])
File "ttml2srt.py", line 371, in process_parag
ms_begin, subrip_begin = self.timeexpr_to_subrip(begin)
File "ttml2srt.py", line 310, in timeexpr_to_subrip
ms = self.timeexpr_to_ms(time_expr) + self.shift
File "ttml2srt.py", line 131, in timeexpr_to_ms
return self._timeexpr_to_ms(*args)
File "ttml2srt.py", line 139, in _timeexpr_to_ms
return self.timeexpr_to_ms(time_expr)
File "ttml2srt.py", line 250, in frame_timestamp_to_ms
hh, mm, ss, frames = [int(i) for i in timestamp.split('.')[0].split(':')]
ValueError: not enough values to unpack (expected 4, got 3)
when trying to convert this file
231203ttmlError.zip
please have a look into it, thx!
Hello,
a license is missing, is this an error or is intentional?
I am using this code with some minor modifications in my hbo go add-on for kodi under GPL license TTML2SRT Class in the Add-on. Am I permitted to do so?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.