Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Update value of Rotation in mov file using Exiftool

Tags:

ios

exiftool

Phil Harvey has provided some excellent examples for using Exiftool to write photo metadata at https://exiftool.org/exiftool_pod.html#WRITING-EXAMPLES.

Following Phil's examples, I've had no problem updating existing metadata fields of JPGs. However, I'm now trying to apply to same logic to video metadata (MOV wrapped H.264) but am not having any success. I've got a video that is upside down according to the iPhone 5 (iOS 7.1) it was shot with - the rotation value is 180 instead of 0. So I'm executing "exiftool -Rotation=0 [file name]" but the result I'm getting is:

0 image files updated

1 image files unchanged

Is there something fundamentally different with video metadata? Could this be a permissions issue? Is my execute statement incorrect? Is there perhaps a better approach?

Thank you!

Update as of July 10: According to the Exiftool website again at https://exiftool.org/TagNames/Composite.html, I found that the Rotation field cannot be edited:

Tag Name: Rotation

Writable: N

Derived From: QuickTime:MatrixStructure, QuickTime:HandlerType

Unfortunately, when I attempted to update MatrixStructure (also displayed as "Matrix Structure") via Exiftool it failed as well with this message - "Warning: Sorry, MatrixStructure is not writable."

So it's looking like it's not possible to edit the relevant metadata here. However, while both VLC and the video transcoder I'm using work with the iPhone file upside down, both Adobe Premiere Pro CC and the QuickTime player work with the file right side up. So it certainly seems like there must be something in the current metadata other than Rotation.

Thanks again.

like image 368
dfyoung Avatar asked Jul 08 '14 16:07

dfyoung


2 Answers

You can use the latest Exiftool to rotate the MOV.

https://exiftool.org/

exiftool -Rotation=0 *.mov 

​ Please refer the table below to set the rotation. It will apply the values in the Track1 of the QuickTime MOV.

MatrixStructure 0 1 0 -1 0 0 1080 0 1

Vertical, Home button is down, Rotation=90

MatrixStructure 1 0 0 0 1 0 0 0 1

Horizontal, Home button is right, Rotation=0

MatrixStructure 0 -1 0 1 0 0 0 1920 1

Vertical, Home button is up, Rotation=270

MatrixStructure -1 0 0 0 -1 0 1920 1080 1

Horizontal, Home button is left, Rotation=180

like image 112
Aping Huang Avatar answered Nov 14 '22 22:11

Aping Huang


Phil Harvey explains the problems with updating that particular tag here.

As an alternative solution I've managed to obtain a lossless rotation of an mp4 file using

ffmpeg -i input.mp4 -metadata:s:v rotate="180" -codec copy output.mp4

It works for my upside down mounted GoPro video.

The video plays the correct way on VLC but not Mediaplayer classic.

like image 29
James Avatar answered Nov 14 '22 22:11

James