Detect orientation of an iPhone video from server

核能气质少年 提交于 2019-12-12 23:38:37

问题


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?


回答1:


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



回答2:


I'm not the best with regex but here is how I would go about doing it

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

Then once you have the output do a pregmatch on it, like so

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

Then check to see if $dims[1] is greater than $dims[2], if it is then it's in landscape, if it's less than its in portrait.

I wasn't able to test it fully but something along those lines should work for you.



来源:https://stackoverflow.com/questions/9334176/detect-orientation-of-an-iphone-video-from-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!