How to Remove Subtitle Times from SRT Files
Subtitles (.srt) files are commonly used to provide transcripts or translations for videos. They typically include timestamps to synchronize the text with the video. However, you might need to remove these timestamps for various purposes, such as:
- Creating a plain text transcript: When you only need the text content without timing information.
- Sharing subtitles with others: You might want to share the subtitles with someone who doesn't need the timing information.
- Using subtitles in a different context: If you're using subtitles for a different purpose, the timestamps might be irrelevant.
Luckily, removing timestamps from SRT files is a relatively simple process. Here's a breakdown of the most common methods:
1. Using a Text Editor
The simplest way to remove timestamps from an SRT file is using a plain text editor like Notepad (Windows), TextEdit (macOS), or any code editor like Visual Studio Code or Atom.
Here's how:
- Open the SRT file: Open the SRT file in your chosen text editor.
- Delete timestamps: Identify the lines containing timestamps (usually starting with a number, then a colon, and then the timestamp). Select and delete these lines.
- Save the file: Save the modified file with a new name to preserve the original SRT file.
Example:
Original SRT File:
1
00:00:00,000 --> 00:00:05,000
Hello, world!
2
00:00:05,000 --> 00:00:10,000
This is a subtitle example.
3
00:00:10,000 --> 00:00:15,000
Enjoy!
Modified SRT File (without timestamps):
Hello, world!
This is a subtitle example.
Enjoy!
2. Using a Text Processing Tool
You can also use powerful text processing tools like sed (Stream Editor) on Linux or grep on macOS and Windows to achieve the same result.
Linux (using sed):
sed 's/^[0-9]* [0-9][0-9]:[0-9][0-9]:[0-9][0-9],[0-9][0-9][0-9] --> [0-9][0-9]:[0-9][0-9]:[0-9][0-9],[0-9][0-9][0-9] //' < input.srt > output.srt
Explanation:
sed
is the command for stream editor.'s/^[0-9]* [0-9][0-9]:[0-9][0-9]:[0-9][0-9],[0-9][0-9][0-9] --> [0-9][0-9]:[0-9][0-9]:[0-9][0-9],[0-9][0-9][0-9] //'
is the substitution command.^[0-9]* [0-9][0-9]:[0-9][0-9]:[0-9][0-9],[0-9][0-9][0-9] --> [0-9][0-9]:[0-9][0-9]:[0-9][0-9],[0-9][0-9][0-9]
is the pattern to match (the timestamp line).//
means replace the matched pattern with nothing.< input.srt
redirects the input from the input.srt file.> output.srt
redirects the output to the output.srt file.
macOS and Windows (using grep):
grep -v '^ *[0-9]* [0-9][0-9]:[0-9][0-9]:[0-9][0-9],[0-9][0-9][0-9] --> [0-9][0-9]:[0-9][0-9]:[0-9][0-9],[0-9][0-9][0-9] *