HTML5 Audio & Video MIME Types

HTML5 video and audio can be endlessly frustrating to get working properly across all platforms. To further complicate matters there is more misinformation out there than definitive resources. This problem isn’t much different than JavaScript where there hundreds of thousands who can write JavaScript, but there must only be 10 people in the world that really understand it.

An important step in serving HTML5 audio and video is serving the files with the correct MIME type. To add them to an Apache server, use the AddType directive in a .htaccess or directly in a Virtual Host file. The following example assumes separate .htaccess files for each:

Audio

AddType audio/aac .aac
AddType audio/mp4 .mp4 .m4a
AddType audio/mpeg .mp1 .mp2 .mp3 .mpg .mpeg
AddType audio/ogg .oga .ogg
AddType audio/wav .wav
AddType audio/webm .webm
Video
AddType video/mp4 .mp4 .m4v
AddType video/ogg .ogv
AddType video/webm .webm
The only tricky and rarely discussed thing is some files use the same file extension for both audio and video formats. This means depending on the types of files you want to serve you might want to add a .htaccess file to the specific directory containing either the audio or the video files so the proper MIME type is served.

References:


			

3 Responses to “HTML5 Audio & Video MIME Types”

  1. [...] audio converter Freemake Free Audio Converter Google Chrome Frame HTML5 Audio — The State of Play HTML5 Audio & Video MIME Types und das Buch HTML5 von Peter Kröner, Open Source Press Dieser Eintrag wurde von Torsten Kelsch [...]

Leave a Reply