Nibbo
Posted on Oct 31
Edited on Oct 31
You build an upload form, add a nice preview with URL.createObjectURL(file) in a <video> tag, and test it with an MP4 from your phone. Works great. Then support tickets arrive: "the preview is black", "it says the file is broken", "the upload button never activates".
The file usually isn't broken. It is in a container or codec the browser simply does not decode. Here's how I deal with it.
What browsers actually play
Roughly, across current Chrome, Firefox and Safari:
Container Typical codecs Plays in <video> ?
MP4 H.264 + AAC Yes, everywhere
WebM VP8/VP9/AV1 + Opus Yes (Safari: recent versions)
MOV H.264/HEVC Often, HEVC depends on OS/hardware
MKV anything Chrome sometimes, Safari no
AVI, WMV, 3GP, MTS/M2TS, FLV DivX, WMV9, H.263, AMR, AC-3… Usually no
Old phones (3GP with AMR audio), Windows Movie Maker exports (WMV), camcorders (MTS/AVCHD) and screen recorders from 2010 (AVI) are exactly what non-technical users find in their archives.
Step 1: detect…