HTML5 <video> can play .mkv files?

后端 未结 3 1551
北恋
北恋 2020-12-30 03:33

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

相关标签:
3条回答
  • 2020-12-30 04: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.

    0 讨论(0)
  • 2020-12-30 04:30

    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.

    0 讨论(0)
  • 2020-12-30 04:37

    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
    
    0 讨论(0)
提交回复
热议问题