1
0
Fork 0
mirror of https://github.com/TeamNewPipe/NewPipe.git synced 2025-10-03 09:49:21 +02:00

Merge pull request #12671 from TransZAllen/SRT_numbering

Fix initial numbering of frames in TTML to SRT converter
This commit is contained in:
Tobi 2025-10-01 02:42:33 -07:00 committed by GitHub
commit c25f83da6c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -24,7 +24,11 @@ public class SrtFromTtmlWriter {
private final boolean ignoreEmptyFrames;
private final Charset charset = StandardCharsets.UTF_8;
private int frameIndex = 0;
// According to the SubRip (.srt) specification, subtitle
// numbering must start from 1.
// Some players accept 0 or even negative indices,
// but to ensure compliance we start at 1.
private int frameIndex = 1;
public SrtFromTtmlWriter(final SharpStream out, final boolean ignoreEmptyFrames) {
this.out = out;
@ -39,7 +43,8 @@ public class SrtFromTtmlWriter {
private void writeFrame(final String begin, final String end, final StringBuilder text)
throws IOException {
writeString(String.valueOf(frameIndex++));
writeString(String.valueOf(frameIndex));
frameIndex += 1;
writeString(NEW_LINE);
writeString(begin);
writeString(" --> ");