Skip to content

Instantly share code, notes, and snippets.

@otsaloma
Created May 1, 2012 18:45
Show Gist options
  • Save otsaloma/2570392 to your computer and use it in GitHub Desktop.
Save otsaloma/2570392 to your computer and use it in GitHub Desktop.
Remove subtitle overlaps using aeidon
#!/usr/bin/env python
import aeidon
project = aeidon.Project()
project.open_main("test.srt")
for i in range(len(project.subtitles) - 1):
end = project.subtitles[i].end_seconds
next_start = project.subtitles[i+1].start_seconds
if end > next_start:
print (i + 1,
project.calc.seconds_to_time(end),
project.calc.seconds_to_time(next_start))
overlap = end - next_start
project.subtitles[i].end = end - 0.5 * overlap
project.subtitles[i+1].start = next_start + 0.5 * overlap
project.save_main(aeidon.files.new(aeidon.formats.SUBRIP,
"test_fixed.srt",
"utf_8"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment