MKV vs MP4 (M4v)

Charlie98

Diamond Member
Nov 6, 2011
6,292
62
91
I'm hoping I didn't just screw the pooch for the past 6 months... D:

I've been ripping all my DVD's (using AnyDVD to break them, Handbrake to encode them) the past 6 months or so in preparation for my HTPC build. I've been ripping them to .MP4 format. What are the main differences in MP4 vs MKV? Am I giving anything up in quality? Am I missing any sort of audio or subtitle features?

By and large, I've been using Handbrake at default... I bump the video quality up a little (CQ: 17.5) and importing subtitles if I know they are in the movie.

I'm fixing to start ripping my BR disks, I think I have to go to MKV for those, correct?
 

thestrangebrew1

Diamond Member
Dec 7, 2011
3,447
391
126
I don't know if there's a substantial difference in quality between the two. I've always ripped my files to mp4 prior to getting my htpc up and running. For whatever reason, my ps3 wouldn't stream mkvs and pretty much any file over 5Gb. Mp4 seemed to fix this issue so I just used that format. Now that I have an htpc to watch media, I just continue to use mp4 as the preferred format. For BR, I use Make MKV, it's an awesome software that I've been able to throw any movie at to encode to mkv. Then, I use Ripbot to encode them to mp4. I was using Handbrake, but lately been using Ripbot.
 

LoveMachine

Senior member
May 8, 2012
491
3
81
Using Handbrake exclusively (+AnyDVD) for a few years, and comparing mkv to mp4 I really don't see any quality difference. There may be theoretical differences, but to my eyes and ears, I can't tell. I stream movies to an AppleTV, which requires mp4, so that's my default format. WMC requires a plugin or two to play mkv's, but XBMC (used for all my real theater watching) could care less. I do find that mp4s generally take a bit less space vs. an equivalent quality mkv. Handbrake will let you transcode one to another if you ever needed to and will do so very quickly, but there obviously won't be any increase in quality from a transcode.

Also, regarding Handbrake for bluray codes, there was no appreciable difference visually with a quality setting of 20 vs. 17 that I could see, and it results in a much smaller file. But I do usually set DVDs for 17.
 

AkumaX

Lifer
Apr 20, 2000
12,642
3
81
let's take a step back here.

when you encode a video, you use a video compression codec, and an audio compression codec.

then after its done, you stick both parts (or more, such as subtitles), into a container.

in this case, .mp4, .m4v, and .mkv are ALL containers.

typically, you will encode videos using the h.264 codec. the raw file created (container-less) is typically in a .h264 "file".

most players can't play "raw" files. so you have to stick them in a container.

you can always extract raw video from containers.

knowing all this, you can easily go back and forth between .mp4 container and .mkv container, because you would just extract the underlying video (demuxing) into .h264 raw video and change containers (remuxing)

(note: renaming a file from .mp4 to .mkv is not the same thing as "changing" containers - you have to use a program to do that)
 

thestrangebrew1

Diamond Member
Dec 7, 2011
3,447
391
126
let's take a step back here.

when you encode a video, you use a video compression codec, and an audio compression codec.

then after its done, you stick both parts (or more, such as subtitles), into a container.

in this case, .mp4, .m4v, and .mkv are ALL containers.

typically, you will encode videos using the h.264 codec. the raw file created (container-less) is typically in a .h264 "file".

most players can't play "raw" files. so you have to stick them in a container.

you can always extract raw video from containers.

knowing all this, you can easily go back and forth between .mp4 container and .mkv container, because you would just extract the underlying video (demuxing) into .h264 raw video and change containers (remuxing)

(note: renaming a file from .mp4 to .mkv is not the same thing as "changing" containers - you have to use a program to do that)

This makes sense. I was going to mention that they were containers, but couldn't word it properly, and you did a fine job. I guess the OPs question should be, since the raw file is h264, is there a difference in quality between the containers? Any advantages/disadvantages between them?
 

AkumaX

Lifer
Apr 20, 2000
12,642
3
81
This makes sense. I was going to mention that they were containers, but couldn't word it properly, and you did a fine job. I guess the OPs question should be, since the raw file is h264, is there a difference in quality between the containers? Any advantages/disadvantages between them?

.mp4
- more widely used/universal
- can't use dts 5.1 sound (i think, or something like that)

.mkv
- can "mux" (combine) multiple video files (multiple aspect ratios) / audio files (multiple languanges) / subtitles (multiple languages) / chapters file
- not widely accepted

if i have a simple file (say, a "simple" 1080p movie), i'd tend to just use .mp4 because that one file can (most likely) be played with native support in an iphone/ipod/ipad/ps3/itunes/windows 7/etc...

if i had a more complicated file (say, a 1080p movie w/ chapter support, 2ch stereo audio, 5.1 audio, 5.1 audio w/ commentary), then you'd have no choice but to use .mkv (and only be limited to a set amount of players that know how to access each audio file)
 

LoveMachine

Senior member
May 8, 2012
491
3
81
.mp4
- more widely used/universal
- can't use dts 5.1 sound (i think, or something like that)

.mkv
- can "mux" (combine) multiple video files (multiple aspect ratios) / audio files (multiple languanges) / subtitles (multiple languages) / chapters file
- not widely accepted

if i have a simple file (say, a "simple" 1080p movie), i'd tend to just use .mp4 because that one file can (most likely) be played with native support in an iphone/ipod/ipad/ps3/itunes/windows 7/etc...

if i had a more complicated file (say, a 1080p movie w/ chapter support, 2ch stereo audio, 5.1 audio, 5.1 audio w/ commentary), then you'd have no choice but to use .mkv (and only be limited to a set amount of players that know how to access each audio file)

mp4 CAN do 5.1 audio etc., it's just that many players like roku, and software like WMC, only uses the first 2 channel audio track. All of my mp4 files encoded with a Handbrake use a preset that has a second 5.1 Dolby Digital track, and blurays add a third with DTS HD-MA (assuming it's a modern movie with such audio available). HB let's you select which audio tracks/language/subtitles you want. It's all in how you mux it. The tricky part is what the player will choose to recognize, hence why I use XMBC.
 

Charlie98

Diamond Member
Nov 6, 2011
6,292
62
91
Akumax, that makes sense (along with what you others are saying.) My brain still has a problem wrapping around all this computer file stuff... the way he put it, makes sense now... and I never thought about using HB to convert it to .MKV if I needed to.

I have a few movies that I like to listen to the commentary on, things like that, and I'll probably just throw the disk in for that. I've pretty much narrowed it down to WMC/MB and XBMC... I'm in the process of renaming all my files so the artwork will show up properly, too. I wish I would have gotten Assassin's guide earlier rather than later... :(

This is all going through a very old Denon 2-channel amp and into my very old 2-way speakers, so I'm not worried about 5.1, etc right now... but that is something to think about now while I'm encoding all this stuff...
 
Last edited:

thestrangebrew1

Diamond Member
Dec 7, 2011
3,447
391
126
I'm loving how xbmc handles my files right now. I haven't tried WMC since I'm not doing any PVR or anything like that. But I'm interested in trying out JRiver.
 

Charlie98

Diamond Member
Nov 6, 2011
6,292
62
91
Originally I had hoped to go with XBMC, but my W7 media remote (Rosewill) isn't fully functional with XBMC.

Once I get WMC up and running at the least, I'll work with XBMC to see if I like it better.
 

thestrangebrew1

Diamond Member
Dec 7, 2011
3,447
391
126
Originally I had hoped to go with XBMC, but my W7 media remote (Rosewill) isn't fully functional with XBMC.

Once I get WMC up and running at the least, I'll work with XBMC to see if I like it better.

There's guides on how to get the WMC remote to work with XBMC. For the most part, I was able to get it to work except for being able to launch XBMC with the green windows button instead of it launching WMC. I wasn't successful with it but maybe you'll have better luck. Just google WMC remote with XBMC or something similar and you should get a bunch of hits and guides.
 

AnitaPeterson

Diamond Member
Apr 24, 2001
5,947
396
126
if i had a more complicated file (say, a 1080p movie w/ chapter support, 2ch stereo audio, 5.1 audio, 5.1 audio w/ commentary), then you'd have no choice but to use .mkv (and only be limited to a set amount of players that know how to access each audio file)

To each his own.
For the very reasons you mentioned above, I'd take mkv any time.
I'm one of those who appreciates commentaries and extras.
And I couldn't care less about standalone players. Any HTPC will run circles around any dedicated media player (no matter who makes it), from both the quality and codec support points of view.
 
Last edited:

Dirigible

Diamond Member
Apr 26, 2006
5,960
30
91
Originally I had hoped to go with XBMC, but my W7 media remote (Rosewill) isn't fully functional with XBMC.

Once I get WMC up and running at the least, I'll work with XBMC to see if I like it better.

About three years ago or so I used eventghost to make my remote do what I want.

Nowadays there are xbmc remote apps for at least some smartphones.
 

Mark R

Diamond Member
Oct 9, 1999
8,513
14
81
As has been said, both MP4 and MKV are container formats.

MKV is more flexible - it is designed to accept virtually any video and audio compression CODECs, supports embedded subtitles in numerous formats, allows attached metadata such as chapter information, etc.

MP4 is limited only to MPEG4 audio and video. In practice, this mean that you can use H264 video, and AAC audio only. DTS and AC3 audio CODECs are not officially supported, neither are MP3, etc. Some programs may allow you to create MP4 files with DTS/AC3 audio, and some programs/devices may even play them, but these files are not standards compliant and not guaranteed to be playable. MP4 also doesn't support metadata like chapters, etc.
 

AkumaX

Lifer
Apr 20, 2000
12,642
3
81
To each his own.
For the very reasons you mentioned above, I'd take mkv any time.
I'm one of those who appreciates commentaries and extras.
And I couldn't care less about standalone players. Any HTPC will run circles around any dedicated media player (no matter who makes it), from both the quality and codec support points of view.

HTPC here too :p Although I am toying with the idea of an Android on a Stick.. as soon as they make streaming .iso's more robust...

Most of my stuff is mkv, and I'm trying to come up with a streamline way of demuxing/remuxing from mkv to mp4 to give those files away easier.

For example, I have the entire Pixar collection, both on .mkv (for all the extras), and .mp4 (for straight movie/single audio). easier to transport and give to family members to stick on their ipads and such for their kids on road trips :)

----

As has been said, both MP4 and MKV are container formats.

MKV is more flexible - it is designed to accept virtually any video and audio compression CODECs, supports embedded subtitles in numerous formats, allows attached metadata such as chapter information, etc.

MP4 is limited only to MPEG4 audio and video. In practice, this mean that you can use H264 video, and AAC audio only. DTS and AC3 audio CODECs are not officially supported, neither are MP3, etc. Some programs may allow you to create MP4 files with DTS/AC3 audio, and some programs/devices may even play them, but these files are not standards compliant and not guaranteed to be playable. MP4 also doesn't support metadata like chapters, etc.

Thanks for your input. I thought that .mp4 could support chapters, but guess not. Also reminded me that .mp4 can't "officially" mux .ac3 and .mp3, so you'd have to convert those to .aac for sure :)
 

Zxian

Senior member
May 26, 2011
579
0
0
and I never thought about using HB to convert it to .MKV if I needed to.

Figured I'd stop you here before you trip yourself over this.

Handbrake does two tasks for you.
1) It encodes the video using the x264 codec (and audio too? I don't use it so I don't know)
2) It puts all the media streams (video, audio, subtitles) into an mp4 or mkv container

If you have a video file that is currently in an mp4 container, you can very easily remux (not reencode) that video into an MKV container using MKVMerge GUI. This process takes all of ~2 minutes - basically as fast as your hard drives can read and write the data.


Think of all of your media in terms of the codec and container separately. An MKV file can contain just about anything - video, audio, pictures, documents, etc etc etc. What codec (or format) those parts are stored in is a separate question.

Personally, I use MKV for everything these days. MP4 is too restrictive of a format IMO. The more support there is for MKV, the better the all-in-one devices will be. The format is completely open-source as well, so there's very little concern with licensing to boot.
 

thestrangebrew1

Diamond Member
Dec 7, 2011
3,447
391
126
Figured I'd stop you here before you trip yourself over this.

Handbrake does two tasks for you.
1) It encodes the video using the x264 codec (and audio too? I don't use it so I don't know)
2) It puts all the media streams (video, audio, subtitles) into an mp4 or mkv container

If you have a video file that is currently in an mp4 container, you can very easily remux (not reencode) that video into an MKV container using MKVMerge GUI. This process takes all of ~2 minutes - basically as fast as your hard drives can read and write the data.


Think of all of your media in terms of the codec and container separately. An MKV file can contain just about anything - video, audio, pictures, documents, etc etc etc. What codec (or format) those parts are stored in is a separate question.

Personally, I use MKV for everything these days. MP4 is too restrictive of a format IMO. The more support there is for MKV, the better the all-in-one devices will be. The format is completely open-source as well, so there's very little concern with licensing to boot.

This makes sense. I'd much rather have my files in mkv vs mp4, but when I first got started with streaming, I was having problems streaming mkvs with Plex. Been using mp4 for the last year. Maybe it's time to revisit this issue.
 

AkumaX

Lifer
Apr 20, 2000
12,642
3
81
This makes sense. I'd much rather have my files in mkv vs mp4, but when I first got started with streaming, I was having problems streaming mkvs with Plex. Been using mp4 for the last year. Maybe it's time to revisit this issue.

most likely it's not the mkv or mp4 file, but the video encoding behind it (the h264 video) that was the problem

typically when 'those release groups ;)' release stuff, if its a small file size but still 1080p, they chose a really aggressive algorithm for compression while maintaining quality (example: h264 - high profile @ 5.1).
this may or may not cause issues for streaming though.. also they happen to choose mkv more often than not (due to chapter support, etc..)

since mp4's are typically 'simpler', theyre also typically encoded more 'simply' due to compatibility with more devices (example: h264 - main profile @ 4.0, which is practically universal with iOS devices past 2010, like iphone 4, ipod 4, ipad, etc..)

you could stick that high@5.1 video in an mp4, and possibly get streaming problems, or stick that main@4.0 in an mkv, and have it stream fine. we'd have to figure out what you did though :)
 

Charlie98

Diamond Member
Nov 6, 2011
6,292
62
91
any questions? :p

Well... I tried ripping a test BD to MP4... not only was the file size something like 16GB, it was unplayable, locked my computer up and finally BSOD'ed.

I ripped it to MKV... much smaller file and it plays on VLC, so that's some progress.
 

Zxian

Senior member
May 26, 2011
579
0
0
An unencoded BluRay movie will be large. 16GB is pretty small by my standards. :p

Watching videos shouldn't cause your system to crash - I'm wondering if something else is going on.

As a baseline - let's make sure we're on the same page for playback. You can either use VLC, or install the LAV Filters and MPC-HC. Either of those options will play just about any file you throw at them. Make sure that you've uninstalled any other "codec packs" that you have installed - you don't need them.

What are you using to rip the videos? I'd suggest installing MakeMKV for now to get the content off your discs. MakeMKV is a very simple program that will take the raw data from your DVDs or BluRays, strip any content protection, and store the streams in an MKV file. Note: you'll have to disable AnyDVD while using it - the two don't play nicely together. The output file will be large. For reference, my Gladiator extended edition comes in at ~35GB for just the video and a single English audio track.

Once you've got that file on your system, you should be able to play it using VLC or MPC-HC. If you've managed to cross this milestone, then we can worry about re-encoding the video to save some disk space and make it possible to play back on multiple devices. :)
 

AkumaX

Lifer
Apr 20, 2000
12,642
3
81
Well... I tried ripping a test BD to MP4... not only was the file size something like 16GB, it was unplayable, locked my computer up and finally BSOD'ed.

I ripped it to MKV... much smaller file and it plays on VLC, so that's some progress.


Is this on Windows?

What encoders are you using?

How long does it take to encode each video to each format?

--

With those answers, it still seems that you don't understand what the difference between .mkv and .mp4 is. The whole point is:

1) Using a program, I could take the video portion of the resulting .mkv, and stick it inside a .mp4. File size will be the same as the original (small), and playback will be the same (playable). The entire process of doing this would only take a few seconds.

2) Using a program, I could take the video portion of the resulting .mp4, and stick it inside a .mkv. File size will be the same as the original (large), and playback will be the same (unplayable). The process should take a few seconds. The entire process of doing this would only take a few seconds.

With either 1) or 2), I am NOT encoding the video. I am just changing the file type to each respective one.
 

Zxian

Senior member
May 26, 2011
579
0
0
My guess is that he's using Handbrake to "rip" the videos, and it's doing several things at once making the whole process more confusing in the end. That's why I suggested he simply rip the raw video to MKV format.
 

AkumaX

Lifer
Apr 20, 2000
12,642
3
81
My guess is that he's using Handbrake to "rip" the videos, and it's doing several things at once making the whole process more confusing in the end. That's why I suggested he simply rip the raw video to MKV format.

Anyone know if there's a big difference between Handbrake for Win and OSX?