Test files › Audio and video › fake-mp4-wrong-magic.mp4
Fake MP4 with wrong magic bytes
Named .mp4 but the first bytes are random noise rather than an ftyp box. Contains no video data.
↓ Download fake-mp4-wrong-magic.mp4| Filename | fake-mp4-wrong-magic.mp4 |
| Format | MP4 (spoofed) |
| Size | 64.0 KB (65,536 bytes) |
| MIME type | video/mp4 |
| SHA-256 | 678b109814ee687b8672b6fe9f559cfae722aa79285ac23bf1ca792de9e97ded |
What this file catchesTranscode queues that accept a job based on the extension and only discover the file is not video after burning a worker slot on it. Validate the ftyp box at upload time.
Handle it in code
Each snippet below was run against this exact file with Python 3.14.4 and Node 24.15.0 when this page was built, and the output shown is what it printed.
Python
An MP4 is a sequence of boxes: a 4-byte size, a 4-byte type, then the contents. Walking the top level shows a missing moov box (no index, so nothing to play) or a file that is not an MP4 at all, without a media library.
import struct
kinds = []
with open("fake-mp4-wrong-magic.mp4", "rb") as f:
while len(head := f.read(8)) == 8:
size, kind = struct.unpack(">I4s", head)
header = 8
if size == 1: # a 64-bit size follows
size, header = struct.unpack(">Q", f.read(8))[0], 16
kinds.append(kind.decode("ascii") if all(32 <= b < 127 for b in kind) else "0x" + kind.hex())
if size == 0:
break # the box runs to the end of the file
if size < header:
print(f"rejected: box {kinds[-1]!r} declares {size} bytes")
break
f.seek(size - header, 1)
if not kinds or kinds[0] != "ftyp":
print("not an MP4: the first box is", kinds[0] if kinds else "missing")
elif "moov" not in kinds:
print("boxes:", ", ".join(kinds) + "; no moov box, so there is nothing to play")
else:
print("boxes:", ", ".join(kinds))Run against this file, it prints: not an MP4: the first box is 0x62dda363
Related guides and tools
Download & verify
curl -fsSL -o "fake-mp4-wrong-magic.mp4" "https://files.hexaqa.com/video/fake-mp4-wrong-magic.mp4"
curl -fsSL "https://files.hexaqa.com/video/fake-mp4-wrong-magic.mp4" | sha256sum
# expect: 678b109814ee687b8672b6fe9f559cfae722aa79285ac23bf1ca792de9e97ded