1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00
FFmpeg/tests/ref/fate/sub-srt-madness-timeshift
Clément Bœsch 77eeaa2c3d lavf/srtdec: rewrite parsing logic
Fixes Ticket #5032

The samples in Ticket #5032 is using \r\r\n as line breaks.  Since we
already are handling \r, or \n, or \r\n as line breaks, \r\n\n will be
considered as a double line breaks. This is an issue because
ff_subtitles_read_text_chunk() will as a result stop extracting a chunk
after just one line.

So instead of parsing the SRT by "chunks" (which means splitting every
double LB), this new parser is detecting timing lines, and split the
events on this basis. While this sounds safe and simple, it needs to
take into account the event number preceding the timing line while
handling situations such as:

 - event number starting at 0 or actually any number instead of 1
 - event numbers not being ordered at all
 - event number being followed by text garbage (this really happened,
   see Ticket #4898)
 - event payload containing one or multiple number (a protagonist saying
   a count-down, a date or whatever) which could be confused with a
   chapter number
 - event number being empty (see Ticket #2167)
 - all kind of weird line breaks can appear randomly like wild pokémons
 - untrustable line breaks (Ticket #5032)

The sample madness.srt tries to sum up most of this into one sample,
ticket5032-rrn.srt is the file containing \r\r\n line breaks. and
empty-events-2167.srt contains empty events.
2016-01-01 18:31:49 +01:00

37 lines
512 B
Plaintext

1
00:00:04,251 --> 00:00:05,362
okay, let's make things easy
2
00:00:05,160 --> 00:00:05,263
31 i'm a number but the only payload so please keep me :)
3
00:00:06,473 --> 00:00:07,584
hello
5
don't forget me.
4
00:00:08,695 --> 00:00:09,806
no.
let's add some fun
5
00:00:10,917 --> 00:00:12,028
let's do it in reverse bc wtf not
45 yes this is a number but i'm actually part of the sub
6
00:00:12,028 --> 00:00:13,139
1
0
next is negative, not a chapnum ;)
-1
7
00:00:13,241 --> 00:00:13,263
credits
2015