Author Topic: Lossless rotation of MP4  (Read 3520 times)

beernoo

  • Newbie
  • *
  • Posts: 8
Lossless rotation of MP4
« on: February 04, 2020, 04:08:09 AM »
Hi ExifTool community,

I mistakenly started shooting a video portrait (few seconds) then turned my camera to shoot landscape which was meant to be the orientation of the shooting. As a result, the whole video is set as portrait hence the landscape content shows at a wrong angle (90°CW). Now I would like to fix this and rotate the video -90°CW in a lossless fashion. I came across:
https://stackoverflow.com/questions/25031557/rotate-mp4-videos-without-re-encoding
https://exiftool.org/forum/index.php/topic,6670.msg46809.html

I tried the below commands (Windows Powershell) which successfully execute ("1 image files updated") but the video still shows as portrait when playing in VLC media player:
exiftool.exe -orientation="Rotate 270 CW" "20160617_cptwn.mp4"
exiftool.exe -orientation#=8 "20160617_cptwn.mp4"

Am I doing anything wrong?

Thanks!
« Last Edit: February 04, 2020, 04:20:25 AM by beernoo »

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 18771
    • ExifTool Home Page
Re: Lossless rotation of MP4
« Reply #1 on: February 04, 2020, 08:49:51 AM »
For videos, try writing Rotation instead of Orientation.  ie)

exiftool -rotation=270 FILE.mp4

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

beernoo

  • Newbie
  • *
  • Posts: 8
Re: Lossless rotation of MP4
« Reply #2 on: February 04, 2020, 07:04:52 PM »
Hi Phil, thanks for your reply! It did help a lot but had to tweak the command. I tried rotation=270 but it rotated the image 180°. Then I tried again with rotation=360 which rotated the image 270° and solved my problem. Could this be a bug or maybe my video was recorded in a special way?
Attaching a sample so that you can reproduce the issue.
Here is the command that helped: exiftool -rotation=360 smallfile.mp4
Thanks

StarGeek

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 5862
Re: Lossless rotation of MP4
« Reply #3 on: February 04, 2020, 07:46:24 PM »
The problem was that it already was tagged with Rotation : 90 and that wasn't taken into account. So what you actually wanted was -Rotation=0 for it to be set correctly.
Troubleshooting hints:
* When posting, include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).
* Double all percent signs (%) in a Windows batch file.
* If your GPS coords are negative, make sure and set the GpsLatitudeRef and GpsLongitudeRef tags correctly.

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 18771
    • ExifTool Home Page
Re: Lossless rotation of MP4
« Reply #4 on: February 04, 2020, 09:54:23 PM »
Try this to add 90 degrees to the rotation:

exiftool "-rotation<${rotation;$_ += 90}" FILE

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).