3

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?
William
  • 3,335
  • 9
  • 42
  • 74
  • You can use `ffmpeg` to convert media to different format at server, and use `` element as child node of ` – guest271314 Feb 19 '17 at 21:00
  • Yea I was looking at https://github.com/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 Feb 19 '17 at 21:02
  • See [``](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/source) – guest271314 Feb 19 '17 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 Feb 20 '17 at 01:34
  • @William what did you end up implementing for this? – geoboy May 09 '17 at 02:43
  • Hi @geoboy - I installed Hangfire.io - when a user uploads a video it creates a background task that uses MediaToolkit (https://github.com/AydinAdn/MediaToolkit) to convert the uploaded file into MP4, OGG and WEBM. I am using Video.js as a media player and up until all three versions have been converted, a placeholder image is shown in place of the actual Video player. Once the conversion has been completed, the Video.js will be rendered with a reference to the three source files. – William May 09 '17 at 04:01

1 Answers1

8

MP4, (in detail h.264 compression and MP4 container) has a license / rights held by a private company, 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 competition, 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 completely 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.

Bulent Vural
  • 2,630
  • 1
  • 13
  • 18
  • Thanks! This is exactly the type of info I needed - I will make sure that at least an MP4 and WEBM copy of each uploaded file is included in the HTML video - – William Feb 20 '17 at 15:14
  • You are welcome. I made some grammar corrections and added a little more detail on my answer without changing its core meaning to make it even more helpful for everybody. – Bulent Vural Feb 20 '17 at 17:39
  • @BulentVural What about HLS? Is that preferable on the browsers that support it? As I understand it, it will allow browsers to stream the file rather than download the whole file? – geoboy May 09 '17 at 02:44