How to decode Base64 to MP4
- Paste the Base64 into Base64 or data URI. A
data:video/mp4;base64,prefix can stay. For long strings, use Open .txt file; anything over 4 MB is decoded without being shown in the text area. - The player loads the clip. Duration and Dimensions appear when the browser has read the index, for example
0:02.0and96 × 64 pxfor the sample. - Look at the note area: it stays empty for a real MP4 and names the format otherwise.
- Press Download file.
Decoding and playback stay inside your browser; the page may not make network requests other than Cloudflare’s page-view count.
MP4, MOV, M4A: one structure, several formats
MP4 files are built from boxes, and the first box, ftyp, holds a brand that says which variant of the format the file follows. The tool reads that brand:
Brand in ftyp | Detected as | Note on this page |
|---|---|---|
isom, mp41, mp42, avc1, iso6 and most others | MP4 | None |
qt | MOV (QuickTime) | “This looks like MOV, not MP4.” with Download as .mov |
M4A | M4A | “This looks like M4A, not MP4.”: audio only |
3gp4, 3gp5 and other 3g brands | 3GP, old phone video | “This looks like 3GP, not MP4.” |
heic, mif1, avif | HEIC, AVIF | “This looks like HEIC, not MP4.”: still images in the same box structure |
A clip whose brand says MP4 can still contain only sound. It plays, and Dimensions shows audio only. A WebM file sent as “MP4” is reported as “This looks like WebM, not MP4.”
Where the index sits, and why it matters for broken files
Every MP4 has a moov box, the index that tells the player where each frame is. Many encoders, ffmpeg among them, write it at the end of the file by default, after the media data in mdat. With -movflags +faststart, ffmpeg moves it to the front so that streaming can start before the whole file has arrived.
On this page the whole file is in memory, so the position does not matter for a complete clip. It matters when the Base64 was truncated, by a size limit in a log, a database column or a message queue:
- Index at the end: the cut removes the index, and nothing plays. The tool still says MP4, because the first bytes are intact, and the player reports “can’t play” with Duration n/a.
- Index at the front: the browser reads the index, shows the full duration and plays until the data runs out.
So when a long clip fails while a short one works, compare the decoded size with the original before blaming the codec.
Inspect the boxes in Python
The box layout is simple enough to walk without a library: four bytes of size, four bytes of type, then the content. This lists the top-level boxes and the brands:
import base64, struct
def mp4_boxes(data):
pos = 0
while pos + 8 <= len(data):
size, kind = struct.unpack(">I4s", data[pos:pos + 8])
if size == 1:
size = struct.unpack(">Q", data[pos + 8:pos + 16])[0]
elif size == 0:
size = len(data) - pos
yield kind.decode("latin-1"), pos, size
if size < 8:
break
pos += size
with open("clip.b64") as f:
data = base64.b64decode(f.read())
for kind, pos, size in mp4_boxes(data):
print(kind, pos, size)
if kind == "ftyp":
body = data[pos + 8:pos + size]
brands = [body[i:i + 4].decode("latin-1") for i in range(8, len(body), 4)]
print(" major:", body[:4].decode("latin-1"), "compatible:", brands)
For an ffmpeg-made H.264 clip it prints ftyp 0 32 with the major brand isom, then free, mdat and moov last. A moov before mdat means faststart; moof boxes mean a fragmented MP4, as produced for streaming and by the sample on this page. If moov is missing from the list, the file is incomplete.
For codec support across browsers, see Base64 to video. To encode a clip, use MP4 to Base64; Base64 in Python covers decoding large inputs.
FAQ
How do I convert Base64 to an MP4 file?
Paste the string above, check the clip in the player and press Download file. The video is saved as decoded.mp4, byte for byte as it was encoded.
Why does my MP4 show 'can't play' even though it is an MP4?
Either the codec inside is one your browser lacks, most often HEVC, or the file is incomplete and its index is missing. ffprobe on the downloaded file tells the two apart: it names the codec, or reports that the moov atom was not found.
Should I save a MOV as .mp4?
Use Download as .mov, the extension that matches the content. MOV and MP4 share most of their structure, so renaming often works in practice, but some players check the brand and refuse a mismatch.