最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - HTML5 Video Format Best Practices - Stack Overflow

programmeradmin8浏览0评论

I am working on adding the ability to upload videos to a CMS that I am developing, and I am a little confused about the "best practices" for uploading videos. The videos will be played using the Video.js library.

My understanding of HTML5 videos is that there are three possible formats: MP4, OGG and WEBM. It would appear that MP4 is supported by all browsers while the other two are less supported.

  • If I want to allow users to upload any sort of video, will I then have to convert whatever they upload into a format that works with HTML5? Or is there a different way that I can go about this?
  • If MP4 is basically supported everywhere, what is the point of including the other two formats? If I do convert videos after the user uploads, should I convert the video into all three versions?
  • I assume that when you upload a video into YouTube, they convert the video into the correct formats? Or how else are they able to play any video format?
  • Are there any libraries or techniques available to convert an uploaded video quickly?

I am working on adding the ability to upload videos to a CMS that I am developing, and I am a little confused about the "best practices" for uploading videos. The videos will be played using the Video.js library.

My understanding of HTML5 videos is that there are three possible formats: MP4, OGG and WEBM. It would appear that MP4 is supported by all browsers while the other two are less supported.

  • If I want to allow users to upload any sort of video, will I then have to convert whatever they upload into a format that works with HTML5? Or is there a different way that I can go about this?
  • If MP4 is basically supported everywhere, what is the point of including the other two formats? If I do convert videos after the user uploads, should I convert the video into all three versions?
  • I assume that when you upload a video into YouTube, they convert the video into the correct formats? Or how else are they able to play any video format?
  • Are there any libraries or techniques available to convert an uploaded video quickly?
Share Improve this question asked Feb 19, 2017 at 20:50 WilliamWilliam 3,4039 gold badges46 silver badges76 bronze badges 6
  • You can use ffmpeg to convert media to different format at server, and use <source> element as child node of <video> at html to play different media if supported at browser. – guest271314 Commented Feb 19, 2017 at 21:00
  • Yea I was looking at github./AydinAdn/MediaToolkit to convert the video - but should I be converting the video into all three formats or is just having them in MP4 sufficient? – William Commented Feb 19, 2017 at 21:02
  • See <source> – guest271314 Commented Feb 19, 2017 at 21:08
  • "If MP4 is basically supported everywhere," It is not. I don't know how many UAs don't want to pay for royalties, but I can tell that at least chromium doesn't, and doesn't support mp4. – Kaiido Commented Feb 20, 2017 at 1:34
  • @William what did you end up implementing for this? – geoboy Commented May 9, 2017 at 2:43
 |  Show 1 more ment

1 Answer 1

Reset to default 8

MP4, (in detail h.264 pression and MP4 container) has a license / rights held by a private pany, MPEG LA. That's why some of the browsers want to avoid depending on it. Although browsers are not likely to drop their existing support, license issues prevent developers to think browsers' support for MP4/h.264 will continue forever.

Google has announced that it would remove h.264 support from Chromium project in 2011 but Chrome still supports it.

Google's VP8 and VP9 (and WEBM container) has a free and open license. But due to petition, not all of the other browsers are willing to give support for VP8-9/WEBM. This may changing / improving in time. For example while none of the Internet Explorer versions had WEBM support, Edge does. Apparently, only Apply Safari in major browsers, lacks WEBM support.

MPEG LA in the meantime keep announcing that it will not charge for their formats use on the internet, this in reality does not make the h.264/MP4 format pletely free.

So these make necessary for the sites provide video content to think carefully about their browser / format support. I believe at least an MP4 and a WEBM copy of every video should be created even if MP4 part of the content might be safe to be purged in a few years.

A conversion after upload is nearly a must. Video encoders and wrappers have tons of different parameters and if you accept the videos uploaded as they are, you may end up with a jungle.

Youtube does re-encode the videos and there are some evidences that they are using ffmpeg at least to do some of their tasks.

发布评论

评论列表(0)

  1. 暂无评论