The easiest way to convert all video format into mkv (matroska open source video format) is using ffmpeg.
#ffmpeg -i input.mpg output.mkv
The file is quite good, small enough. But the quality is decreased.
We might try this to preserve the quality but the file size is increase
#ffmpeg -i input.avi -sameq output.mkv
or to lower the quality with various of bitrates : 16, 32, 64, 128, 256, 384, and 512 Kbps.
we might find this bitrate when executing the ffmpeg command like above.
see the input file bitrate. Using the same command we can lower the bitrates
#ffmpeg -i input.avi -b 32 output.mkv
If the input file already contains MPEG-4 and mp3 quality use this to change the container only. But the size is reduced a little.
#ffmpeg -i input.avi -vcodec copy -acodec copy output.mkv