Matroska / MKV lossless auto-rotation during playback
Matroska / MKV lossless auto-rotation during playback
-
So far only MPC-HC, MPC-BE, PotPlayer, and KMPlayer have the ability to auto-rotate the MKV / Matroska video during playback, hence no need to press the shortcut keys every time.
-
Such could be done two ways, and it's better to use both at the same time, since most of the players above only support one method. I think only MPC-HC supports both.
-
First method is to use MKVToolNix GUI's Header Editor and modify the value of Video: Projection Roll Rotation, say a value of 90 to rotate to 90 degrees to the right (270 to rotate to the left, 180 to seemingly flip vertically upside down). Save.
-
Second method is to embed XML tag for the Video track (not Global), which should contain something like this below, say a file
90.xml
.
<?xml version="1.0"?>
<!-- <!DOCTYPE Tags SYSTEM "matroskatags.dtd"> -->
<Tags>
<Tag>
<Targets>
<TargetTypeValue>30</TargetTypeValue>
<TargetType>TRACK</TargetType>
</Targets>
<Simple>
<Name>ROTATE</Name>
<String>90</String>
<TagLanguage>eng</TagLanguage>
<DefaultLanguage>1</DefaultLanguage>
</Simple>
</Tag>
</Tags>
- With a BATCH file, it could be done simultaneously, like below, which uses
mkvmerge.exe
to remux the MKV to a subfolder DONE.
for %%Z in ("*.mkv") do (echo %%~nxZ
(mkvmerge.exe -o "DONE\%%~nZ.mkv" ^
--projection-pose-roll 0:90 ^
--tags 0:"90.xml" ^
"%%~Z")
echo;)
-
With BATCH, you could also make it so that the newly remuxed MKV would be auto-copied over to overwrite the old MKV file. Even auto-delete the BATCH file itself (by simply putting
del "%~f0"
at the very end, last). -
Note, both methods above are lossless, no re-encoding needed. IIRC,
mkvpropedit.exe
could also be used to embed the XML file, but from my own experience, it's always better to usemkvmerge.exe
to remux to a new MKV file, because there is a chance for the Matroska file to have issues like being unresponsive to the seekbar. The same issue could manifest too after using third party tag / metadata editors over and over. And so, you would need to remux anyway. -
Also, although I'm basing it from memory, IIRC, the second method (tag/metadata/XML file) works on old hardware like Windows XP era, which mostly have no EVR / Enhanced Video Renderer back then yet. My assumption is because the rotation is done via software mode. Hence the more reason to use both methods, just in case one fails or is not supported.