我已经从iPhone上传了我的照片和电影到我的CentOS网络服务器,现在我想在我的主页上显示它们(我希望它们在本地托管--而不是通过iCloud)。照片没有问题,因为我可以通过exif
访问它们的数据,但电影文件似乎不那么容易。
我的服务器是CentOS和Apache,我正在使用PHP 8.1,现在我计划只包括我的iPhone的东西,但当然,它可以预期,我会从其他相机上传也稍后。
我需要这个方向的原因是我将把它封装到Bootstrap 4.6中,让它自动响应。我将这样做:
横向电影格式(注意16by9
):
<div class='embed-responsive embed-responsive-16by9'>
<video poster='mythumbnail.jpg' controls preload='metadata'>
<source src='mymovie.mov' type='video/mp4' />
<span style='background-color:red;color:white;'>(your browser cannot show this video)</span>
</video>
</div>
人像电影格式(注意9by16
):
<div class='embed-responsive embed-responsive-9by16'>
<video poster='mythumbnail.jpg' controls preload='metadata'>
<source src='mymovie.mov' type='video/mp4' />
<span style='background-color:red;color:white;'>(your browser cannot show this video)</span>
</video>
</div>
有没有人对如何从MOV
文件中获得方向有什么好主意?:-)
1条答案
按热度按时间jaql4c8m1#
直到有人提供了一个更好的,理想的本地PHP解决方案,那么我将接受这个答案的基础上@CBroe的评论。
PHP不容易提供查询视频文件的元数据的可能性,但在
CentOS
(和其他Linux发行版)中使用mediainfo
应用程序是一种可能性,它将能够查询大量文件的媒体类型和一些元信息。这对于图片、视频和音频文件是如此,但也可以是PDF文件和其他文件。要在PHP中实现这一点,可以使用exec--同时确保使用escapeshellarg转义命令参数,以确保shell的安全:
mediainfo
将输出类似于以下内容的内容,其中的每一行都将位于$outputArray
数组变量中:然后,这是你解释-并处理坏元数据的许多可能性,当使用各种相机源或媒体:-)例如,对于图片文件,我只使用
mediainfo
来确定它是一个图片文件,然后我通过exif_read_data传递数据,因为这是更详细的。不过有一个小注意-对于我的特定设置,
exec
似乎在丹麦国家字符方面有一些问题,因为它无法读取包含这些字符的文件。我希望这与一些字符编码问题有关,但从未发现这一点-查看PHP "exec" cannot access filenames which have national Danish characters?了解详细信息。