16

So I accidentally opened an mkv video file with Chrome, and to my surprise it played it using the native player:

<video src="video.mkv"></video>

It was playing perfectly. HTML5 video supports matroska container?

Mark
  • 39,169
  • 11
  • 42
  • 48

3 Answers3

21

HTML5 doesn't support any video formats, or rather HTML5 doesn't specify what formats browsers should support. It's up to the browsers to decide which formats they choose to support. Apparently Chrome plays .mkv, but I wouldn't be surprised if other browsers didn't play the same file.

JJJ
  • 32,902
  • 20
  • 89
  • 102
  • 30
    @artdias90 [No, it doesn't](http://www.w3.org/html/wg/drafts/html/master/semantics.html#the-video-element). W3schools is not an authoritative reference. – JJJ May 05 '15 at 12:14
2

The website has probably set the mimetype of the file to video/webm. Chrome will open this inline rather than forcing a download (because otherwise it doesnt know what to do with it or how to open it).

E.g., in apache this is done by using the AddType directive (can be done in a htaccess):

    AddType video/webm .mkv
Harry Lewis
  • 488
  • 5
  • 12
  • 3
    Please do not do this. All WebM files are MKV files but the reverse is not true, and one should not serve files with an incorrect MIME type, as the above will end up doing. – Alice Wonder Feb 15 '17 at 00:16
1

I'd be surprised if browsers didn't support mkv, as the webm container is just a restricted version of the matroska format. Beyond that you'd have to check the codec of the video inside, and ensure your browser can handle that. If the video format is VP8 or VP9 and the audio is Opus or Vorbis it's webm compliant and might as well be renamed as such. Note that H.264, H.265 and MP3 are not webm compliant and you should avoid using that extension on files that include those formats, the video would still play but it would technically break the webm specification and is frowned upon.

  • Also note that if you add subtitles to an MKV container itself, even if the video is VP{8,9} and the audio is Vorbis or Opus, it no longer technically is WebM compliant - though browsers still will play it. – Alice Wonder Feb 15 '17 at 00:15