Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.m4a is considered audio/m4a or audio/mp4

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.

like image 762
Brosef Avatar asked Oct 06 '16 00:10

Brosef


3 Answers

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

like image 166
Tim Avatar answered Oct 19 '22 20:10

Tim


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.

like image 32
twhb Avatar answered Oct 19 '22 20:10

twhb


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.

  • https://en.wikipedia.org/wiki/HTML5_audio#Supported_audio_coding_formats
  • https://developer.mozilla.org/en-US/docs/Web/Guide/Audio_and_video_delivery/Cross-browser_audio_basics
  • https://developer.mozilla.org/en-US/docs/Web/HTTP/Configuring_servers_for_Ogg_media

Also see: How to play .m4a with HTML5 audio in IE(9+) and Safari (Pad)?

like image 1
Christophe Roussy Avatar answered Oct 19 '22 21:10

Christophe Roussy