Detect H264 profile and level for HTML5 video

I have a bunch of mp4 files that are all encoded video with a high level profile of H264 4.x. We want to display them with HTML5 video for delivery through the device (from phones to connected TVs). I know that abstract files can play poorly on all devices, especially old ones, so we are considering alternatives (for example, displaying a warning message for a user or creating basic versions for files). I need to check JavaScript if this device can read the given profile and level of H264, and I'm not sure how it works exactly.

I read http://diveintohtml5.info/detect.html , which provides the following function

function supports_h264_baseline_video() {
  if (!supports_video()) { return false; }
  var v = document.createElement("video");
  return v.canPlayType('video/mp4; codecs="avc1.42E01E, mp4a.40.2"');
}  

This tells me about the basic H264 profile - how to define a high level H264 profile 4.1, for example?

+4
source share
1 answer

During my research on video and the HTML5 type, I found this link to whatwg.org. It says:

Video codecs

H.264 Baseline: avc1.42E0xx, where xx is the AVC level
H.264 Main: avc1.4D40xx, where xx is the AVC level
H.264 High: avc1.6400xx, where xx is the AVC level 

XX is expressed as a hexadecimal value. Thus, level 3.0 is 1E, as in your example.

If you want to test the high level of H264 4.1, the mime type for testing is avc1.640029. You can use this function from diveintohtml5.info to test your mime type.

, , H264 , ( , ).

0

All Articles