How to run . mkv files in all browsers?

Asked

Viewed 5,450 times

-1

I’m trying to run a video on .mkv in Firefox, however same error due to file extension.

Is there any way to make the video work?

<video>
    <source src="video.mkv" type="video/mp4">
</video>

Using the above code the returned error is:

Video format or MIME type not Supported

  • And what have you done? Could [Edit] and show what your code is?

  • @Stormwind <video controls="true" autoplay="true">&#xA; <source src="video.mkv" type="video/mp4">&#xA;</video>

  • Do you have this video? It’s in the folder along with the HTML file?

  • have, in google opens, but in firefox not

  • In the MDN says nothing about the element <video> support the fomate .mkv.

  • there is something I can do to run this video in the browser?

  • Same error. But what error? Try dragging this video to the browser and see if it runs normally.

  • Video format or MIME type not Supported

Show 3 more comments

2 answers

5

HTML does not support any video format, and HTML5 does not specify which formats browsers should support.

It’s up to browsers to decide which formats they choose to support. Apparently, Chrome runs .mkv,however it is not an obligation for other browsers to play the same file. So much so that suddenly this support may disappear, and you will have problems to run the video.

You may even find something unofficial, but the guarantee that will work the first time and stay working is something without response.


To real solution, is to use the most recommended format for the tag <video> the Webm, or one of the following:

  • audio/midi,
  • audio/mpeg,
  • audio/webm,
  • audio/ogg,
  • audio/wav

We also have an answered question about this in our Big Brother SO.

  • there is no player I can use ex: Jwplayer, Flow Player etc...

  • 1

    @Carlosdasilva is not the player that "runs" the video, the player internally uses codecs, these codecs can come from the operating system (like xpcodec or klitecodec) or it can be browser native, like in Chrome, so if Chrome or the operating system doesn’t have codec it will never run. The only guaranteed way to make something work is to change the format of the video.

2

The extent .mkv and .mp4 has nothing to do with the format of the video, you could rename a file with the mp4 format to the extent video.foobaz that would still be an archive .mp4.

Videos are not played simply by HTML, the tag <video> depends on the Codecs installed on the machine or viewed with the browser:

Wiki: Codec is the acronym for Encoder/Decoder, hardware device or software that encodes/decodes signals.

If you have a CODEC installed in your computer for MKV that is compatible with the same build architecture type as your browser, which can be x86 or x64 (other times Arm), then it will work in your computer, does not mean that it will work in other browsers.

So if you have an x64 browser, you will need an x64 codec, there is a codec package called k-lite codec, which contains x86/x64 embedded, ie it installs for both, the basic package which is the lightest supports mkv: https://www.codecguide.com/download_k-lite_codec_pack_basic.htm

All supported formats (has nothing to do with extensions) sane:

  • AVI, MKV, MP4, FLV, MPEG, MOV, TS, M2TS, WMV, RM, RMVB, OGM, Webm

When installing it is recommended to restart the computer, of course as I already said this will only make your browser recognize, so that it works on other computers will be necessary to install the codecs as well.


How to work on "all" (almost all) modern browsers

There is no guarantee that it works on all browsers, Chrome already comes with many codecs, but the mkv nay is one of them, the only viable solution is to re-encode the video to a new format that is more common as the MPEG-4 or H.264 format itself (both usually use the extension .mp4), you can convert manually using software like:

  • Freemake (I don’t know the quality of the software, it’s just an example, there are others in the "market")

Or you can convert on the server side, while uploading, using the ffmpeg which is a program aimed at this, for example:

ffmpeg -i videoupado.mkv -vcodec copy -acodec copy videoupado.mp4

In PHP you could use exec, after upload, for example:

exec('ffmpeg -i videoupado.mkv -vcodec copy -acodec copy videoupado.mp4', $output);

print_r($output);
  • I tried this Freemake, but I didn’t like it much. I prefer the AVS. :)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.