subsync
subsync copied to clipboard
Recursively split subtitles where spaces occur
With srt3, you can use the following code to split subtitles and remove the space between them (once the timestamps of the space are found):
# Finds all subtitles up to :05, and after :08 using srt3 (version 1.0.0)
import srt
# Parse the srt file at some point.
subs = srt.parse("subtitle content")
# Use the find method to filter out space.
space_start = srt.timestamp_to_timedelta("00:00:05,00")
space_end = srt.timestamp_to_timedelta("00:00:08,00")
new_subs = srt.tools.find.find_by_timestamp(subs, space_end, space_start) # returns a generator of subtitles
srt3 also performs 30% faster than pysrt on typical workloads.