Jsrt
A small SRT parser and editor in Java
Install / Use
/learn @fredyw/JsrtREADME
jsrt
A small SRT parser and editor in Java. SRT is a subtitle file format.
Download
https://github.com/fredyw/jsrt/releases
How to Build
jsrt uses Gradle build system and requires Java 8 to build.
Building jsrt JAR
gradle
The JAR will be created in dist directory.
Running jsrt-gui
java -jar dist/jsrt-gui-<version>.jar
Screenshot

Examples
in.srt
1
00:00:20,000 --> 00:00:24,400
Hello World. This is a long text.
Bye World. This is a short text.
2
00:00:24,600 --> 00:00:27,800
Foo Bar
Bar Foo
out1.srt
1
16:17:55,370 --> 16:17:55,370
Hello
World
2
16:17:55,370 --> 16:17:55,370
Bye
World
out2.srt
1
00:00:05,000 --> 00:00:07,000
Test
2
00:00:20,100 --> 00:00:24,500
Hello
World.
This is a
long text.
Bye World.
This is a
short
text.
3
00:00:24,600 --> 00:00:27,800
Foo Bar
Bar Foo
4
00:01:05,000 --> 00:01:07,000
Test
Main.java
package examples;
import java.io.File;
import java.util.Arrays;
import java.util.Date;
import org.fredy.jsrt.api.SRT;
import org.fredy.jsrt.api.SRTInfo;
import org.fredy.jsrt.api.SRTReader;
import org.fredy.jsrt.api.SRTTimeFormat;
import org.fredy.jsrt.api.SRTWriter;
import org.fredy.jsrt.editor.SRTEditor;
public class Main {
private static void print(SRTInfo info) {
for (SRT s : info) {
System.out.println("Number: " + s.number);
System.out.println("Start time: " + SRTTimeFormat.format(s.startTime));
System.out.println("End time: " + SRTTimeFormat.format(s.endTime));
System.out.println("Texts:");
for (String line : s.text) {
System.out.println(" " + line);
}
System.out.println();
}
}
private static void testRead() {
SRTInfo info = SRTReader.read(new File("in.srt"));
print(info);
}
private static void testWrite() {
SRTInfo info = new SRTInfo();
Date d = new Date();
info.add(new SRT(1, d, d, "Hello", "World"));
info.add(new SRT(2, d, d, "Bye", "World"));
File f = new File("out1.srt");
f.deleteOnExit();
SRTWriter.write(f, info);
}
private static void testEdit() {
SRTInfo info = SRTReader.read(new File("in.srt"));
SRTEditor.updateText(info, 1, 10);
SRTEditor.updateTime(info, 1, SRTTimeFormat.Type.MILLISECOND, 100);
SRTEditor.prependSubtitle(info, "00:00:05,000", "00:00:07,000",
Arrays.asList("Test"));
SRTEditor.appendSubtitle(info, "00:01:05,000", "00:01:07,000",
Arrays.asList("Test"));
print(info);
// Write it back
File f = new File("out2.srt");
f.deleteOnExit();
SRTWriter.write(f, info);
}
public static void main(String[] args) {
testRead();
testWrite();
testEdit();
}
}
Related Skills
node-connect
346.4kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
107.2kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
346.4kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
346.4kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
