从服务器检测 iPhone 视频的方向
我正在尝试通过 PHP 表单检测上传的 iPhone 视频文件 (.mov) 的方向,以便我可以使用 FFMPEG 来纠正它(很多上传的视频都显示在其侧面)。我似乎找不到访问服务器上上传文件方向的方法。有什么想法吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用 mediainfo
您可以使用 exec() 捕获此系统调用的输出,并应用方向修复(顺时针 90 度):
如果您有 --enable_vfilters
Using mediainfo
You can use exec() to capture the output of this system call, and apply the orientation fix (90 degrees clockwise):
If you have --enable_vfilters
我不是最擅长使用正则表达式,但这是我的做法
然后一旦你有了输出,就对其进行预匹配,就像这样
然后检查 $dims[1] 是否大于 $dims[2] ,如果是,则为横向,如果小于则为纵向。
我无法完全测试它,但类似的东西应该适合你。
I'm not the best with regex but here is how I would go about doing it
Then once you have the output do a pregmatch on it, like so
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.