Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What codec should I specify for an MP4 in my HTML5 video source tag?

Tags:

html

video

ffmpeg

Based on Dive Into HTML5 I've written HTML something like this:

<video controls>
  <source src="my-video.mp4"  type="video/mp4; codecs=avc1.42E01E,mp4a.40.2">
  <source src="my-video.webm" type="video/webm; codecs=vp8,vorbis">
  <source src="my-video.ogv"  type="video/ogg; codecs=theora,vorbis">
</video>

I know the codecs specified for WebM and OGG are correct... But what about the avc1.42E01E,mp4a.40.2? How do I know if that's correct?

I encoded my video like this:

ffmpeg -i my-video.mov \
  -acodec libfaac -ab 96k \
  -vcodec libx264 \
  -level 21 -refs 2 -b:v 345k -bt 345k \
  -threads 0 -s 1920x780 my-video.mp4

Can you tell from this command, or is there some way I can tell from the video? Media Information in VLC didn't help.

like image 850
callum Avatar asked Oct 19 '22 03:10

callum


1 Answers

mp4a.40.2

  • 40 means mpeg4 and 2 is the Audio Object Type THese numbers are in decimal

avc1 means h.264 encoded video

  • 42 is the h.264 profile in hex where 42 is Baseline 4D is Main and 64 is High
  • E0 is the compatibility flags (see h264 reference for more)
  • 1E is the level (decimal 30 = level 3.0)

These bytes are available from the extradata/sps

like image 198
szatmary Avatar answered Oct 28 '22 21:10

szatmary