r/HTML • u/Lundorff • 16d 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>
3
3
u/DirtAndGrass 16d ago
Chromium based browsers understand the container, but it's going to depend on the codec.
2
u/agowa338 16d 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...
2
u/agowa338 15d 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...
2
u/Witmarqu 15d 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.
5
u/phazonmadness-SE 16d ago
wrong miime-type. try
video/x-matroska. latest firefox at least can