Remux MTS (AVCHD) files to MKV using mkvmerge in linux

This post came to life because I did not manager to get my newly aquired Raspberry Pi 512MB version revision 2 running raspbmc to play my MTS files without freeze/rebuffering. One solution was to overclock the Arm processor to 1000MHz, but then I struggled to find a way to get the CPU temperature down. The other solution was to convert or remux the MTS file to Matroska format using a Ubuntu linux server using the mkvmerge command.

From a console window install the required package to perform the remux operation
$ sudo apt-get install mkvtoolnix

Then I did a quick test to remux the MTS file to MKV
$ mkvmerge -o OutputFile.MKV InputFile.MTS
mkvmerge v6.1.0 ('Old Devil') built on Mar 4 2013 20:24:55
'InputFile.MTS': Using the demultiplexer for the format 'MPEG transport stream'.
'InputFile.MTS' track 0: Using the output module for the format 'AVC/h.264'.
'InputFile.MTS' track 1: Using the output module for the format 'AC3'.
'InputFile.MTS' track 2: Using the output module for the format 'PGS'.
The file 'OutputFile.MKV' has been opened for writing.
'InputFile.MTS' track 0: Extracted the aspect ratio information from the MPEG-4 layer 10 (AVC) video data and set the display dimensions to 1920/1080.
Progress: 100%
The cue entries (the index) are being written...
Muxing took 19 seconds.

This example remuxed a 339MB MTS file to Matroska in 19 seconds and is a quick and easy fix to perform on my video collection.
Muxing a 1.3GB MTS file took 2 minutes 9 seconds. The resulting MKV file is a little bit smaller than the original MTS file.

I have not experienced any playback problems using raspbmc connected to my Sony Bravidia KDL-40EX711 LED TV even though some people complain that older devices cannot play files remuxed using newer version of mkvmerge because of “Header compression” is enabled by default, ref http://www.mediasmartserver.net/2010/08/09/mkv-mania-header-compression-and-the-side-effects/.

Playback of the MKV file is now without any freeze or rebuffering and the Raspberry Pi is now working as a power efficient media PC directly connected to my TV using a HDMI cable and using a external power suppply.

Playback has been tested on Raspbmc running XBMC 12.2 Git:20130502-32b1a5e using “System Performace Profile – Normal” without any advanced overclocking options enabled.

As a note .MTS files are AVCHD coded and can also end with the .M2TS file suffix.