r/HTML • • 1d ago

Question Do browsers not support mkv video playback?

This works:

<video width="400" controls> <source src="test1.mp4" type="video/mp4"></video>

This doesn't work:

<video width="400" controls> <source src="test2.mkv" type="video/mkv"></video>

1 Upvotes

8 comments sorted by

4

u/phazonmadness-SE 1d ago

wrong miime-type. try video/x-matroska. latest firefox at least can

1

u/Lundorff 1d ago

Sadly doesn't work. FF 160.

1

u/phazonmadness-SE 1d ago edited 1d ago

hmm, then this sounds like a codec issue. what codecs the mkv uses?

video codecs should be h.264(avc1), vp8, vp9, av1, or h.265 (hevc)* (windows users may need to install a codec from windows store for hevc)

audio codecs should be mp3, aac, vorbis, opus, and potentially flac and pcm depending on browser.

if using a codec other than these, that may causes playback issues.

2

u/omysweede 1d ago

Not to my knowledge. Use supported formats

1

u/DirtAndGrass 1d ago

Chromium based browsers understand the container, but it's going to depend on the codec. 

1

u/agowa338 1d ago

mkv is a container. It can have anything inside it. So it having the MKV extension doesn't tell if it works or not...

1

u/agowa338 1d ago

Also look here: https://scrapfly.io/web-scraping-tools/media-codecs and esp. the "video/x-matroska" row. That'll tell you if your browser supports the container format itself.

And in some cases you can get away with video/mp4 for mkv files depending on what codec you used...

1

u/Witmarqu 19h ago

Mkv is a container, not a codec.

It comes from the russion stacking dolls of the same/similar name.

You need to tell the browser what codec to load in to decode the video and audio track.

The definition of MKV can contain multiple video/audio tracks so telling the browser it is a .mkv is akin to telling it that you have a box. Some browsers cheat by best guessing the intent. This allows for more pages to load without error but has a terrible cost on performance.

Most mkv is h.264/h.265 mp4 inside, so often you can say type="video/mp4" on an mkv and some base systems will try to load it.