2017-11-05

Matroska versus fragmented MP4

In an earlier post I was worried that Matroska might have lost its edge compared to MP4 when it comes to overhead size. So I dug a little deeper with some real life samples from no other than Apple to see if what we could improve. It turns out that Matroska is still the best when it comes to overhead (and just about everything else).

Here are some comparison from the Apple adaptive streaming sample page. I don't how they compare to real life files, maybe they are improperly muxed but the results are always in the favor of Matroska even when large padding and tags are left in the file.

Advanced Stream

The lowest bitrate video is 530kbps according to the manifest and 369 kbps according to MediaInfo. Then I remuxed it with mkvmerge. Then go through mkclean and here are the results:
  • 27 672 619 original fMP4 with H264
  • 27 449 794 mkvmerge with default options (we win already)
  • 27 447 068 mkclean with default options
  • 27 439 197 mkclean with --live
  • 27 357 090 mkclean with --remux --optimize
  • 27 349 220 mkclean with --remux --optimize --live
The normal usage when preparing with for streaming would be mkclean with --remux --optimize and that gives a 1.1% size advantage that could be better used for the codec. That stream even includes checksums, tags and is fully seekable.

Advanced Stream HEVC

Here Matroska doesn't have the advantage of using Header Compression as with H264, which saves 3 bytes per frame as they are always the same. The 145 kbps is also closer to the limit of everyday files.
  • 11 492 052 original fMP4 with HEVC
  • 11 410 786 mkvmerge with default options (we win already)
  • 11 407 257 mkclean with default options
  • 11 371 266 mkclean with --remux --optimize
But we're still 1.1% percent smaller than the same content in fragmented MP4.

Advanced Stream H264

This is the same as above but in H264 format, so we get to use header compression.
  • 10 663 861 original fMP4 with H264
  • 10 558 115 mkvmerge with default options (we win already)
  • 10 554 002 mkclean with default options
  • 10 498 886 mkclean with --remux --optimize

Conclusion

So Matroska is still the best when it comes to overhead and still keeps all its advantages. Only very very small fine tuned files might actually go in favor of fMP4. I'd really like to have such real life samples if you have some.

No comments: