How to run .mkv files in all browsers?

-1

I'm trying to run a video in .mkv in Firefox, but the same error because of 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 error returned is:

  

Video format or MIME type not supported

    
asked by anonymous 09.10.2017 / 21:56

2 answers

4

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

It's up to the browsers to decide which formats they choose to support . Chrome appears to be running .mkv , however it is not an obligation for other browsers to play the same file. So suddenly that support may disappear, and you will have trouble running the video.

You may even find something that is not official, but the guarantee that will work the first time and stay up is something unanswered.

The Truth solution , is to use the most recommended format for the <video> WebM tag. , or one of the following:

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

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

    
09.10.2017 / 22:28
1

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

Videos are not reproduced simply by HTML, the <video> tag depends on the CODECs installed on the machine or the browser:

  

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

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

So if you have an x64 browser, you will need an x64 codec, there is a codec pack called k-lite codec , which contains x86 / x64 built-in, ie it installs for both the basic package which is the lightest supports mkv: link

All supported formats ( no extensions ) are:

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

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

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

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

  • freemake (I do not 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, during upload, using .mp4 which is a program aimed at this, for example:

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

In PHP you could use ffmpeg , after uploading, for example:

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

print_r($output);
    
10.10.2017 / 19:28