Closed UrosOgrizovic closed 3 years ago
Thanks for filing an issue! This looks like it may benefit from the srt maintainer's eyes, but in my tests, it seems like the parse error comes from the timestamp 00:00:01
without the extra decimal part. I think this probably is because the timestamp regular expression expects 4 "fields":
RGX_TIMESTAMP = RGX_TIMESTAMP_MAGNITUDE_DELIM.join([RGX_TIMESTAMP_FIELD] * 4)
I can work on getting a PR out later, but for now, one workaround would be to manually add those fields or to use a sed command to add them back in automatically, something like:
sed -E 's/([0-9]+:[0-9]+:[0-9]+) /\1,0/g' bad.srt > good.srt
The file parses after running it through this transformation.
Just saw this and merged https://github.com/cdown/srt/commit/8eb45f98e8497b230d9264661ca2f3829504ee69. :-)
Environment (please complete the following information):
Describe the bug I'm aware that an issue about this same problem has already been opened (and closed), but I can't seem to solve it.
I have some subtitles like so
and I'm trying to synchronize them to a video. The problem I'm getting is in
srt.py -> _check_contiguity()
, which is being called on line 350 of that same file, insideparse()
. Essentially,expected_start != actual_start
is the problem.expected_start
is 0, whereasactual_start
is 118. In other words,SRT_REGEX.finditer(srt)
skips the first subtitle block, causing_check_contiguity()
to raise anSRTParseError
. Why is that?To Reproduce
Copy the following code into a Python file:
Expected behavior The code given above prints
<re.Match object; span=(116, 253), match="\n\n2\n00:00:06,250000 --> 00:00:11,500000\nperso>
, i.e. it skips the first subtitle block, which is not what I want.Output Here's the output of running
ffs video.mp4 -i unsynchronized.srt -o synchronized.srt