Determine iPhone video orientation from server

I am trying to determine the orientation of the iPhone video file (.mov) when uploading via PHP form so that I can use FFMPEG to fix it (many downloaded videos are shown on their side). It seems I can’t find a way to access the orientation of the downloaded file on the server. Any ideas?

+1
source share
2 answers

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
+8
source

I'm not the best with regex, but here's how I will do it

exec(ffmpeg -i uploaded.mov,$output)

, , pregmatch , :

preg_match('/(\d+)x(\d+)/', $output, $dims);

, $dims [1] $dims [2], , .

, - .

0

Source: https://habr.com/ru/post/1532107/


All Articles