tkarabela / pysubs2

A Python library for editing subtitle files
http://pysubs2.readthedocs.io
MIT License
318 stars 40 forks source link

ASS to SRT/WebVTT cue ordering #67

Closed AntonOfTheWoods closed 1 year ago

AntonOfTheWoods commented 1 year ago

I couldn't find a source of truth for SRT but WebVTT specifies that:

Cue timings

A cue timing indicates when the cue is shown. It has a start and end time which are represented by timestamps. The end time must be greater than the start time, and the start time must be greater than or equal to all previous start times. Cues may have overlapping timings.

Currently the to_file method doesn't sort according to start, which means if the input cues aren't in order, invalid WebVTT are created.

tkarabela commented 1 year ago

@AntonOfTheWoods Thanks for the bug report and fix! :) I've released version 1.6.1 of the library that writes WebVTT in correct order as you suggested. I'm not sure about SRT, so for backward compatibility I've kept it as-is.

AntonOfTheWoods commented 1 year ago

Great, thanks. I'm 99.9% certain that having subs in start time order is going to be compatible with SRT, and about 80% sure it's also necessary there also (bad things seemed to happen with VLC when they were out of order, though it might have been something else too...). It's good for me though, and I can't find anything resembling a proper spec, so I guess it's an implementation detail :).