SRT
application/x-subrip
Magic Bytes
Offset: 0
31 0A 30 30
The SubRip Text (SRT) format is a plain-text subtitle file format originally developed for the SubRip software by programmer Jean-Luc Coulon. It is widely used to provide synchronized time-stamped captions for video playback across various media players, streaming platforms, and video editing suites. As a text-based format containing sequence numbers and timecodes, it is considered safe; however, its lack of complex styling features has led to its gradual replacement by more robust standards like WebVTT.
Validation Code
How to validate .srt files in Python
Python
def is_srt(file_path: str) -> bool:
"""Check if file is a valid SRT by magic bytes."""
signature = bytes([0x31, 0x0A, 0x30, 0x30])
with open(file_path, "rb") as f:
return f.read(4) == signature
How to validate .srt files in Node.js
Node.js
function isSRT(buffer: Buffer): boolean {
const signature = Buffer.from([0x31, 0x0A, 0x30, 0x30]);
return buffer.subarray(0, 4).equals(signature);
}
Go
func IsSRT(data []byte) bool {
signature := []byte{0x31, 0x0A, 0x30, 0x30}
if len(data) < 4 {
return false
}
return bytes.Equal(data[:4], signature)
}
API Endpoint
GET
/api/v1/srt
curl https://filesignature.org/api/v1/srt