MPEG transport streamfile
application/octet-stream
Magic Bytes
Offset: 0
47 46 31 50 41 54 43 48
MPEG Transport Stream (TS) is a standard digital container format for the transmission and storage of audio, video, and data, maintained by the Moving Picture Experts Group. It is primarily utilized in broadcast systems such as DVB, ATSC, and IPTV, as well as for streaming media over unreliable networks where packet loss may occur. While inherently safe, the format lacks native encryption or integrity verification, necessitating external conditional access systems for secure commercial distribution.
Validation Code
How to validate .ts files in Python
Python
def is_ts(file_path: str) -> bool:
"""Check if file is a valid TS by magic bytes."""
signature = bytes([0x47, 0x46, 0x31, 0x50, 0x41, 0x54, 0x43, 0x48])
with open(file_path, "rb") as f:
return f.read(8) == signature
How to validate .ts files in Node.js
Node.js
function isTS(buffer: Buffer): boolean {
const signature = Buffer.from([0x47, 0x46, 0x31, 0x50, 0x41, 0x54, 0x43, 0x48]);
return buffer.subarray(0, 8).equals(signature);
}
Go
func IsTS(data []byte) bool {
signature := []byte{0x47, 0x46, 0x31, 0x50, 0x41, 0x54, 0x43, 0x48}
if len(data) < 8 {
return false
}
return bytes.Equal(data[:8], signature)
}
API Endpoint
GET
/api/v1/ts
curl https://filesignature.org/api/v1/ts