MPEG video

video/mpeg

Safe

Magic Bytes

Offset: 0
00 00 01 BA

The MPEG video file format is a multimedia container and compression standard developed by the Moving Picture Experts Group for digital video broadcasting. It was historically the primary format for movies distributed online and on physical media such as Video CDs. Although largely superseded by more efficient modern standards like MP4 and MKV, this legacy format remains viewable in most contemporary media players without requiring additional codecs.

Extension

.mpg

MIME Type

video/mpeg

Byte Offset

0

Risk Level

Safe

Validation Code

How to validate .mpg files in Python

Python
def is_mpg(file_path: str) -> bool:
    """Check if file is a valid MPG by magic bytes."""
    signature = bytes([0x00, 0x00, 0x01, 0xBA])
    with open(file_path, "rb") as f:
        return f.read(4) == signature

How to validate .mpg files in Node.js

Node.js
function isMPG(buffer: Buffer): boolean {
  const signature = Buffer.from([0x00, 0x00, 0x01, 0xBA]);
  return buffer.subarray(0, 4).equals(signature);
}
Go
func IsMPG(data []byte) bool {
    signature := []byte{0x00, 0x00, 0x01, 0xBA}
    if len(data) < 4 {
        return false
    }
    return bytes.Equal(data[:4], signature)
}

API Endpoint

GET /api/v1/mpg
curl https://filesignature.org/api/v1/mpg

Related Formats