I\'m looking for a way to rotate videos shot with my Nexus 4 on my Debian Wheezy sytem. The videos are shot in portrait mode and I would like to rotate them to landscape mod
FFmpeg
and similar programs change the metadata even with the -map_metadata
option. exiftool
can read the rotation matrix and rotation flag, and since version 10.89 also write it as described below.
To get true lossless (incl. metadata) rotation, I couldn't find a solution, so I grabbed a hex editor (eg HxD) and analyzed the rotated video files.
vide
to find the metadata of the video track trak...\tkhd
@
sign (HEX 40)no rotation:
00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00
40
180°:
FF FF 00 00 00 00 00 00 00 00 00 00 00 00 00 00
FF FF 00 00 00 00 00 00 00 00 00 00 00 00 00 00
40
90° cw:
00 00 00 00 00 01 00 00 00 00 00 00 FF FF 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
40
90° ccw:
00 00 00 00 FF FF 00 00 00 00 00 00 00 01 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
40
Alter the file as you need it, and it should be rotated in players that support the rotation flag (most current players do).
In case your video contains stereo audio, this is obviously not switched, so in case you want the sound to match with video rotation (180°), you need to switch the left and right channels.