sindresorhus / file-type

Detect the file type of a file, stream, or data
MIT License
3.64k stars 345 forks source link

Use mimetype `audio/wav` for .wav files #620

Closed luckv closed 8 months ago

luckv commented 8 months ago

Use mimetype audio/wav for .wav files instead of unsupported audio/vnd.wave

As pointed out in this comment, the correct mimetype supported by all major browsers (chrome, firefox, safari) is audio/wav and not audio/vnd.wave.

I made a simple html page to test the behaviour, which also include a test for .avi files. The test show that I didn't find any supported mimetype for .avi files, so I will not do a PR for that.

test-mimetype.zip

Borewit commented 8 months ago

Wiki mentions 3 used MIME types for the "WAV audio file format":

  1. audio/vnd.wave
  2. audio/wav
  3. audio/wave
  4. audio/x-wav

None of those is solid, as there is no authoritative IANA registration.

audio/vnd.wave is mentioned in RFC 2361 WAVE and AVI Codec Registries

vnd. is prefixed for vendor as specified in RFC 6838 Media Type Specifications and Registration Procedures. After the .vnd the vendor name should appear, so audio/vnd.microsoft.wave would be a more sensible MIME type in my humble opinion. Given that the WAV format is in nowadays more common good then proprietary, to register this format as vendor specific does not make much sense to me.

WAV is using the RIFF container format, which is documented with a unregistered MIME type: application/x-riff. To fall back on the container format, does not seem to be the convention.

Unregistered entries should be prefixed x- (no 4) *. By that definition, number four is valid. But the The paradoxical statement made also in RFC 6838 is that these x- should only be used in private / local environments. The reality is, is that WAV files are widely used in public, and just to prevent this kind of painful solution, if I would be working for IANA, I would just register audio/wav for the sake of normalization. Yet I do not work for IANA.

Then there is audio/wav. wav is the original Microsoft extension, in the MIME types there is no need to stick to the 3 character extension, and in that aspect audio/wave or audio/waveform would be more logic.

I have no objections to change to audio/wav, it's a bit of an arbitrary choice. One can choose the most widely spread convention, unfortunately this is also something which is hard to measure.

If the Mozilla listing of audio/wav can be accepted as a common browser convention, we could follow their convention as well.

Borewit commented 8 months ago

Sorry, I noticed the discussion on #150 after I wrote my response. Conclusion is aligned.