Why won't some MP4 files play via HTML5?

南楼画角 提交于 2019-12-01 02:23:11

mp4 is only the container format. It may contain video and audio in a number of different codecs. Players (including those in a browser) need to support the container format and all of the used codecs in order to play a video properly.

Using VideoJS is definitely a good idea, it handles a lot of browser-specific workarounds for you.


However it does not solve one problem: There is no single video codec supported in all browsers. (See also Wikipedia: HTML5 video: Browser_support)

The practical solution probably is to provide two versions: h264 in a mp4 container and what is usually called webm (VP8 video and vorbis audio in a specific Matroska container). With those two you cover all major browsers.


For video conversion/recoding there are some tools and services available. I have no idea about your operating system or requirements. So just as a wild guess:

Something I used to help a friend publish a few videos on his little blog is this shell script using ffmpeg for conversion. It still leaves a lot of potential for improvement (in all of video quality, performance and coding) but should be good enough to get started.

The first video uses h264 encoding which is supported by everything except Firefox and Opera. The second video uses the MPEG-4 video codec which is not supported by browsers. The only widely supported video codecs are Theora, H.264 and VP8.

MPEG-4 Part 2 video codec is different from the MPEG-4 Part 14 container format

Your video 1.mp4 is encoded using h.264 but video 2.mp4 is not. get MediaInfo to check about it.

MP4 supports multiple codecs. Some players don't support all codecs (some codes require licensing, or some codecs were released after the browser was written).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!