MIME Types
The correct MIME type of an HLS playlist is application/vnd.apple.mpegurl
.
Here is a table of some other extensions of media files typically used in HLS and their MIME types:
File extension | MIME type |
---|---|
m3u | audio/mpegurl |
ts | video/mp2t |
mp4 | video/mp4 |
m4s | video/iso.segment |
aac | audio/aac |
mp3 | audio/mpeg |
If you are using a recent version of Nginx or Apache2 you shouldn't have to make any changes, but if you are using an older version here's how you can update the MIME type associated with a specific file extension. Nginx comes with its own list of MIME types (/etc/nginx/mime.types
on Debian / Ubuntu). You can use a tool like grep
to look for "m3u8" in that file; if the MIME type is not correct, you’ll need to edit the file and change it. Alternatively, you can add the following configuration to either the http
, server
, or location
contexts:
types { application/vnd.apple.mpegurl m3u8; }
This means that the "Content-Type
" header will be set to "application/vnd.apple.mpegurl
" for any requests ending in .m3u8.
Apache2 also comes with its own list of MIME type (conf/mime.types
). Again, look for "m3u8" in that file and check the MIME type. If it’s wrong, update it. You can also use the AddType directive.
Amazon S3 is a popular solution for storing files. You can use Amazon S3 to host a static website or use it as an origin for CloudFront. If you already have a playlist in an S3 bucket, you may to check the content type to make sure it is correct. To do that (via the S3 management console) navigate to the S3 bucket where you uploaded the file. Click on the playlist and under the Properties tab, scroll down to the Metadata section. Check the value of the Content-Type
key. If you need to change it, you can only do so by creating a copy of the file and then modifying the settings of the copy. Here are the steps to do that:
- Select the checkbox next to the name of the playlist
- From the Actions drop-down, select Copy
- Enter the name of the S3 bucket in the Destination field
- Scroll down and in the Additional copy settings section, select Specify settings
- Scroll down further and locate the Metadata section. Select Replace all metadata then click on the Add metadata button
- Select System defined from the Type drop-down then Content-Type from the Key drop-down. Enter "application/vnd.apple.mpegurl" in the Value field
- Click Copy
When entering the name of the bucket in step 3, if the destination bucket is the same as the current version of the file, the copy action will overwrite it with the new settings. This is OK in this instance but you may want to enable versioning on the bucket to prevent accidental overwrites.
For comments, please send me an email