I am attempting to detect the orientation of an iPhone video file (.mov) on upload through a PHP form so that I can use FFMPEG to correct it (a lot of the videos uploaded are shown on their side). I can not seem to find a way of accessing the orientation of the uploaded file on the server. Any ideas?
Using mediainfo
$ mediainfo test.mp4 | grep Rotation
Rotation : 90°
You can use exec() to capture the output of this system call, and apply the orientation fix (90 degrees clockwise):
$ ffmpeg -i test.mp4 -vf "transpose=1" testRotated.mp4
If you have --enable_vfilters
$ ffmpeg -vfilters "rotate=90" -i test.mp4 testRotated.mp4