Why won't Safari play file without extension in <video>?

mp4, safari, video

Solution

Safari is extremely fussy when it comes to playback of streamed media such as video and audio. It has the following requirements

- The server/application hosting the media MUST support byte ranges. Safari will do a trial download of 2 bytes to ascertain the media length, it will then download the media in one or more chunks depending on the size of the file. It won't play nice if you just send it all the data.

- The content range returned from the media server must include a figure for total media size and not just "*".

- The media URL MUST have a suffix matching the type of media. It's like IE all over again: getting the mime type right is a fruitless exercise because Safari isn't going to follow the rules here and it will ignore mime type.

Note that Safari doesn't tell you what the problem is if it fails on playback, there's just a media error raised with no further information.

For mpeg 4 video / h.264, the suffix .mp4 works For mpeg 4 audio / aac, the suffix .aac works

If you are a Safari dev please consider fixing these things.

This is tested on Safari 11.1.2

Problem

I have file named 52bbb58c without file extension and it is mp4 video. When I try to add it as `&<source>` to `<video>` with attribute type (video/mp4), it doesn't play. This works on Chrome and Firefox working. How do I fix it for Safari?

Original source

Related problems