I'm trying to make an audio upload to S3 and I'm a little confused what I should declare my mime type as. My audio file is an m4a recorded on an iphone as kAudioFormatMPEG4AAC
. Would this be considered audio/m4a
or audio/mp4
? I'm seeing conflicting answers online.
The m4
in m4a
is short-hand for MPEG-4
, just like mp4
is short-hand for MPEG-4
.
In fact, m4a
, m4v
and mp4
files all have the same internal MPEG-4
atom structure. The difference between the files is their content (video files have video atoms as well as audio atoms.)
The codec of the audio can also be different despite using the same file extension, for example both alac
and AAC
formats use the MPEG-4
container format with the m4a
file extension.
So to answer your question, it really doesn't make much difference. My personal preference would be audio/mp4
since that is effectively saying
Audio data in MPEG-4 container
Whereas, audio/m4a
is like saying
Audio data in MPEG-4 container containing audio
Use audio/mp4
. audio/m4a
may work, but it's invalid.
MP4 MIME type registration:
2. Selection of MIME Types for MP4 Files The MIME types to be assigned to MP4 files are selected according to the contents. Basic guidelines for selecting MIME types are as follows: a) if the file contains neither visual nor audio presentations, but only, for example, MPEG-J or MPEG-7, use application/mp4; b) for all other files, including those that have MPEG-J, etc., in addition to video or audio streams, video/mp4 should be used; however: c) for files with audio but no visual aspect, including those that have MPEG-J, etc., in addition to audio streams, audio/mp4 may be used. In any case, these indicate files conforming to the "MP4" specification, ISO/IEC 14496-1:2000, systems file format.
Further, the list of standard MIME types includes audio/mp4
, not audio/m4a
, and non-standard MIME types should include “x-”, like audio/x-m4a
.
In 2021 for me audio/mp4
for an .m4a
file worked on Firefox + Chrome (Linux), Opera (Android) but not on iPhone Safari. For some formats the OS plays a role due to codecs.
I used a source tag with type attribute set and I also set the same type in the Content-Type
header of the streamed / downloaded file.
Also see: How to play .m4a with HTML5 audio in IE(9+) and Safari (Pad)?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With