About AVI video files
An old Windows container that browsers don’t play. Convert AVI to MP4 or WebM before putting it on a web page. video/avi and video/msvideo are also seen.
Other types seen for these files:
video/avi
,
video/msvideo
. Accept them when reading uploads, but send video/x-msvideo yourself.
File signature
AVI files start with "RIFF", then "AVI " at byte 8. The extension and the type a browser reports for an upload both
come from the file name, so check these bytes on the server before trusting a file.
Serve .avi with the right Content-Type
Content-Type: video/x-msvideo
video/x-msvideo avi;
AddType video/x-msvideo .avi
@avi path *.avi
header @avi Content-Type "video/x-msvideo"
curl -sI https://example.com/file.avi | grep -i '^content-type'
# Content-Type: video/x-msvideo
Set the type in code
res.set('Content-Type', 'video/x-msvideo');
// Or make the browser download it:
res.attachment('file.avi');
import mimetypes
mimetypes.add_type('video/x-msvideo', '.avi') # if your system doesn't know it
mimetypes.guess_type('file.avi')[0] # 'video/x-msvideo'
mime.AddExtensionType(".avi", "video/x-msvideo")
w.Header().Set("Content-Type", "video/x-msvideo")
Accept .avi uploads
<input type="file" accept=".avi,video/x-msvideo">
The accept attribute only filters the file picker; users can still choose another file. Listing the
extension as well as the type matters, because operating systems don’t always report the type you expect.
Related types
-
.mp4 (
video/mp4): MP4 video -
.mkv (
video/x-matroska): Matroska video -
.mov (
video/quicktime): QuickTime video
More video
.webm , .m3u8 , .ts . Look up any extension or type with the MIME type lookup.
Sources
Spotted a mistake? Email hello@devtoolsmith.com and we’ll fix it.
Frequently asked questions
What is the MIME type for .avi files?
video/x-msvideo. You may also see video/avi, video/msvideo, which are older or unofficial; send video/x-msvideo. The full header is "Content-Type: video/x-msvideo".
Why does my server send the wrong Content-Type for .avi?
Web servers pick the type from the file extension using a table (mime.types in nginx and Apache). If .avi is missing from that table, they send a default such as application/octet-stream or text/plain. Add the mapping as shown on this page, then check the response with "curl -sI".
How can I check that a file really is AVI?
Look at the first bytes rather than the extension or the type the browser reports, which both come from the file name. AVI files start with "RIFF", then "AVI " at byte 8. The MIME type lookup on this site reads them for you when you drop a file on it.