Fix Aspect Ratio of MKV Files
The steps below can be used to fix a video having the incorrect aspect ratio. I don't know what causes such issues, but here is how to fix it.
This tutorial requires mkvmerge which can be installed with:
sudo apt install mkvtoolnix
Firstly, it is useful to know what aspect ratio you need. You could guess, but if the "bad" video is part of a series, then I would get the information from one of the other episodes using:
ffmpeg -i input.mkv
Then look for text similar to below in the output:
Stream #0:0(eng): Video: h264 (High), yuv420p(tv, bt709/unknown/unknown, progressive), 1920x872, SAR 1:1
In this case, my desired aspect ratio is 1920 (width) by 872 (height). We can now plug this information into mkvmerge to create a copy of our bad video file, with a corrected aspect ratio.
mkvmerge \ --aspect-ratio $VIDEO_TRACK_ID:$WIDTH/$HEIGHT \ -o output.mkv \ input.mkv
mkvmerge -i input.mkv and that will output the tracks and their IDs.
For my example, the following command creates the correct file with the name
output.mkv from the
mkvmerge \ --aspect-ratio 0:1920/872 \ -o output.mkv \ input.mkv